Skip to content
This repository has been archived by the owner on Oct 22, 2021. It is now read-only.

Commit

Permalink
Merge branch 'master' into v7.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Mario Manno committed Jun 2, 2021
2 parents affa4a5 + 1257be8 commit e3c5b3a
Show file tree
Hide file tree
Showing 13 changed files with 200 additions and 129 deletions.
6 changes: 3 additions & 3 deletions integration/bdpl_update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ var _ = Describe("BDPL updates", func() {
Expect(err).NotTo(HaveOccurred(), "error retrieving clusterIP service")

tearDown, err := env.CreateService(env.Namespace, env.NodePortService("nats-service", "nats", svc.Spec.Ports[0].Port))
defer func(tdf machine.TearDownFunc) { Expect(tdf()).To(Succeed()) }(tearDown)
tearDowns = append(tearDowns, tearDown)
Expect(err).NotTo(HaveOccurred(), "error creating service")

service, err := env.GetService(env.Namespace, "nats-service")
Expand Down Expand Up @@ -554,11 +554,11 @@ var _ = Describe("BDPL updates", func() {
manifestName := "bosh-manifest-two-instance-groups"
tearDown, err := env.CreateConfigMap(env.Namespace, env.BOSHManifestConfigMap("fooconfigmap", bm.BOSHManifestWithTwoInstanceGroups))
Expect(err).NotTo(HaveOccurred())
defer func(tdf machine.TearDownFunc) { Expect(tdf()).To(Succeed()) }(tearDown)
tearDowns = append(tearDowns, tearDown)

_, tearDown, err = env.CreateBOSHDeployment(env.Namespace, env.DefaultBOSHDeployment(manifestName, "fooconfigmap"))
Expect(err).NotTo(HaveOccurred())
defer func(tdf machine.TearDownFunc) { Expect(tdf()).To(Succeed()) }(tearDown)
tearDowns = append(tearDowns, tearDown)

By("checking for nats instance group pods")
err = env.WaitForInstanceGroup(env.Namespace, manifestName, "nats", 2)
Expand Down
9 changes: 7 additions & 2 deletions integration/drain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,26 @@ import (
var _ = Describe("Drain", func() {
var (
boshDeployment bdv1.BOSHDeployment
tearDowns []machine.TearDownFunc
)
BeforeEach(func() {
boshDeployment = env.DefaultBOSHDeployment("test", "manifest")
})

AfterEach(func() {
Expect(env.TearDownAll(tearDowns)).To(Succeed())
})

When("deleting the deployment", func() {
It("executes the job's drain scripts", func() {
cm := env.BOSHManifestConfigMap("manifest", bm.Drains)
tearDown, err := env.CreateConfigMap(env.Namespace, cm)
Expect(err).NotTo(HaveOccurred())
defer func(tdf machine.TearDownFunc) { Expect(tdf()).To(Succeed()) }(tearDown)
tearDowns = append(tearDowns, tearDown)

_, tearDown, err = env.CreateBOSHDeployment(env.Namespace, boshDeployment)
Expect(err).NotTo(HaveOccurred())
defer func(tdf machine.TearDownFunc) { Expect(tdf()).To(Succeed()) }(tearDown)
tearDowns = append(tearDowns, tearDown)

By("checking for instance group pods")
err = env.WaitForInstanceGroup(env.Namespace, "test", "drains", 1)
Expand Down
18 changes: 12 additions & 6 deletions integration/storage/deploy_with_storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ import (
)

var _ = Describe("DeployWithStorage", func() {
var tearDowns []machine.TearDownFunc

AfterEach(func() {
Expect(env.TearDownAll(tearDowns)).To(Succeed())
})

Context("when using multiple processes in BPM", func() {
It("should add multiple containers to a pod", func() {
By("Creating a secret for implicit variable")
Expand All @@ -22,18 +28,18 @@ var _ = Describe("DeployWithStorage", func() {

tearDown, err := env.CreateSecret(env.Namespace, env.StorageClassSecret("var-operator-test-storage-class", storageClass))
Expect(err).NotTo(HaveOccurred())
defer func(tdf machine.TearDownFunc) { Expect(tdf()).To(Succeed()) }(tearDown)
tearDowns = append(tearDowns, tearDown)

tearDown, err = env.CreateConfigMap(env.Namespace, corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{Name: "bpm-manifest"},
Data: map[string]string{"manifest": bm.BPMRelease},
})
Expect(err).NotTo(HaveOccurred())
defer func(tdf machine.TearDownFunc) { Expect(tdf()).To(Succeed()) }(tearDown)
tearDowns = append(tearDowns, tearDown)

_, tearDown, err = env.CreateBOSHDeployment(env.Namespace, env.DefaultBOSHDeployment("test-bdpl", "bpm-manifest"))
Expect(err).NotTo(HaveOccurred())
defer func(tdf machine.TearDownFunc) { Expect(tdf()).To(Succeed()) }(tearDown)
tearDowns = append(tearDowns, tearDown)

By("checking for instance group pods")
err = env.WaitForInstanceGroup(env.Namespace, "test-bdpl", "bpm", 1)
Expand Down Expand Up @@ -77,15 +83,15 @@ var _ = Describe("DeployWithStorage", func() {

tearDown, err := env.CreateSecret(env.Namespace, env.StorageClassSecret("var-operator-test-storage-class", storageClass))
Expect(err).NotTo(HaveOccurred())
defer func(tdf machine.TearDownFunc) { Expect(tdf()).To(Succeed()) }(tearDown)
tearDowns = append(tearDowns, tearDown)

tearDown, err = env.CreateConfigMap(env.Namespace, env.BOSHManifestConfigMap("bpm-affinity", bm.BPMReleaseWithAffinity))
Expect(err).NotTo(HaveOccurred(), "error creating configMap")
defer func(tdf machine.TearDownFunc) { Expect(tdf()).To(Succeed()) }(tearDown)
tearDowns = append(tearDowns, tearDown)

_, tearDown, err = env.CreateBOSHDeployment(env.Namespace, env.DefaultBOSHDeployment("bpm-affinity", "bpm-affinity"))
Expect(err).NotTo(HaveOccurred())
defer func(tdf machine.TearDownFunc) { Expect(tdf()).To(Succeed()) }(tearDown)
tearDowns = append(tearDowns, tearDown)

By("checking for pod")
err = env.WaitForInstanceGroup(env.Namespace, "bpm-affinity", "bpm1", 2)
Expand Down
17 changes: 11 additions & 6 deletions integration/util/tlogs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ import (
)

var _ = Describe("when testing tail-logs subcommand", func() {
var tearDowns []machine.TearDownFunc

AfterEach(func() {
Expect(env.TearDownAll(tearDowns)).To(Succeed())
})

Context("subcommand must be working", func() {
podName := "test-pod-bar-foo"
parentCName := "fake-nats"
Expand All @@ -29,7 +35,7 @@ var _ = Describe("when testing tail-logs subcommand", func() {

tearDown, err := env.CreatePod(env.Namespace, testPod)
Expect(err).NotTo(HaveOccurred())
defer func(tdf machine.TearDownFunc) { Expect(tdf()).To(Succeed()) }(tearDown)
tearDowns = append(tearDowns, tearDown)

err = env.WaitForPod(env.Namespace, podName)
Expect(err).NotTo(HaveOccurred())
Expand All @@ -55,7 +61,7 @@ var _ = Describe("when testing tail-logs subcommand", func() {

tearDown, err := env.CreatePod(env.Namespace, testPod)
Expect(err).NotTo(HaveOccurred())
defer func(tdf machine.TearDownFunc) { Expect(tdf()).To(Succeed()) }(tearDown)
tearDowns = append(tearDowns, tearDown)

err = env.WaitForPod(env.Namespace, podName)
Expect(err).NotTo(HaveOccurred())
Expand All @@ -80,7 +86,7 @@ var _ = Describe("when testing tail-logs subcommand", func() {

tearDown, err := env.CreatePod(env.Namespace, testPod)
Expect(err).NotTo(HaveOccurred())
defer func(tdf machine.TearDownFunc) { Expect(tdf()).To(Succeed()) }(tearDown)
tearDowns = append(tearDowns, tearDown)

err = env.WaitForPod(env.Namespace, podName)
Expect(err).NotTo(HaveOccurred())
Expand All @@ -100,7 +106,7 @@ var _ = Describe("when testing tail-logs subcommand", func() {

tearDown, err := env.CreatePod(env.Namespace, testPod)
Expect(err).NotTo(HaveOccurred())
defer func(tdf machine.TearDownFunc) { Expect(tdf()).To(Succeed()) }(tearDown)
tearDowns = append(tearDowns, tearDown)

err = env.WaitForPod(env.Namespace, podName)
Expect(err).NotTo(HaveOccurred())
Expand All @@ -120,7 +126,7 @@ var _ = Describe("when testing tail-logs subcommand", func() {

tearDown, err := env.CreatePod(env.Namespace, testPod)
Expect(err).NotTo(HaveOccurred())
defer func(tdf machine.TearDownFunc) { Expect(tdf()).To(Succeed()) }(tearDown)
tearDowns = append(tearDowns, tearDown)

err = env.WaitForPod(env.Namespace, podName)
Expect(err).NotTo(HaveOccurred())
Expand All @@ -131,7 +137,6 @@ var _ = Describe("when testing tail-logs subcommand", func() {
time.Sleep(1 * time.Minute)
err = env.WaitForPodContainerLogMsg(env.Namespace, podName, sidecarCName, "running logrotate")
Expect(err).NotTo(HaveOccurred())

})
})
})
6 changes: 4 additions & 2 deletions pkg/bosh/bpmconverter/container_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,18 @@ const (
// ContainerFactoryImpl is a concrete implementation of ContainerFactor.
type ContainerFactoryImpl struct {
instanceGroupName string
errand bool
version string
disableLogSidecar bool
releaseImageProvider bdm.ReleaseImageProvider
bpmConfigs bpm.Configs
}

// NewContainerFactory returns a concrete implementation of ContainerFactory.
func NewContainerFactory(instanceGroupName string, version string, disableLogSidecar bool, releaseImageProvider bdm.ReleaseImageProvider, bpmConfigs bpm.Configs) *ContainerFactoryImpl {
func NewContainerFactory(igName string, errand bool, version string, disableLogSidecar bool, releaseImageProvider bdm.ReleaseImageProvider, bpmConfigs bpm.Configs) ContainerFactory {
return &ContainerFactoryImpl{
instanceGroupName: instanceGroupName,
instanceGroupName: igName,
errand: errand,
version: version,
disableLogSidecar: disableLogSidecar,
releaseImageProvider: releaseImageProvider,
Expand Down
17 changes: 5 additions & 12 deletions pkg/bosh/bpmconverter/container_factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (

var _ = Describe("ContainerFactory", func() {
var (
containerFactory *ContainerFactoryImpl
containerFactory ContainerFactory
bpmConfigs bpm.Configs
releaseImageProvider *fakes.FakeReleaseImageProvider
jobs []bdm.Job
Expand Down Expand Up @@ -165,7 +165,7 @@ var _ = Describe("ContainerFactory", func() {
})

JustBeforeEach(func() {
containerFactory = NewContainerFactory("fake-ig", "v1", false, releaseImageProvider, bpmConfigs)
containerFactory = NewContainerFactory("fake-ig", false, "v1", false, releaseImageProvider, bpmConfigs)
})

Context("JobsToContainers", func() {
Expand Down Expand Up @@ -320,7 +320,7 @@ var _ = Describe("ContainerFactory", func() {
},
},
}
containerFactory = NewContainerFactory("fake-ig", "v1", false, releaseImageProvider, bpmConfigsWithError)
containerFactory = NewContainerFactory("fake-ig", false, "v1", false, releaseImageProvider, bpmConfigsWithError)
actWithError := func() ([]corev1.Container, error) {
return containerFactory.JobsToContainers(jobs, []corev1.VolumeMount{}, bdm.Disks{})
}
Expand Down Expand Up @@ -368,13 +368,6 @@ var _ = Describe("ContainerFactory", func() {
Expect(containers[1].Env).To(HaveLen(5))
})

It("handles an error when jobs is empty", func() {
jobs = []bdm.Job{}
_, err := act()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("instance group 'fake-ig' has no jobs defined"))
})

It("handles an error when getting release image fails", func() {
releaseImageProvider.GetReleaseImageReturns("", errors.New("fake-release-image-error"))
_, err := act()
Expand Down Expand Up @@ -552,7 +545,7 @@ var _ = Describe("ContainerFactory", func() {

disableSideCar := ig.Env.AgentEnvBoshConfig.Agent.Settings.DisableLogSidecar

containerFactory := NewContainerFactory(ig.Name, "v1", disableSideCar, releaseImageProvider, bpmJobConfigs)
containerFactory := NewContainerFactory(ig.Name, false, "v1", disableSideCar, releaseImageProvider, bpmJobConfigs)
act := func() ([]corev1.Container, error) {
return containerFactory.JobsToContainers(ig.Jobs, []corev1.VolumeMount{}, bdm.Disks{})
}
Expand All @@ -579,7 +572,7 @@ var _ = Describe("ContainerFactory", func() {

disableSideCar := ig.Env.AgentEnvBoshConfig.Agent.Settings.DisableLogSidecar

containerFactory := NewContainerFactory(ig.Name, "v1", disableSideCar, releaseImageProvider, bpmJobConfigs)
containerFactory := NewContainerFactory(ig.Name, false, "v1", disableSideCar, releaseImageProvider, bpmJobConfigs)
act := func() ([]corev1.Container, error) {
return containerFactory.JobsToContainers(ig.Jobs, []corev1.VolumeMount{}, bdm.Disks{})
}
Expand Down
Loading

0 comments on commit e3c5b3a

Please sign in to comment.