feat: Switch to using watches instead of manual sleeps

This commit is contained in:
TheiLLeniumStudios
2026-01-14 19:41:04 +01:00
parent b28f1abfe4
commit c45b416458
38 changed files with 1111 additions and 859 deletions

View File

@@ -14,12 +14,14 @@ var _ = Describe("Auto Reload All Flag Tests", func() {
deploymentName string
configMapName string
autoNamespace string
adapter *utils.DeploymentAdapter
)
BeforeEach(func() {
deploymentName = utils.RandName("deploy")
configMapName = utils.RandName("cm")
autoNamespace = "auto-" + utils.RandName("ns")
adapter = utils.NewDeploymentAdapter(kubeClient)
})
AfterEach(func() {
@@ -59,7 +61,7 @@ var _ = Describe("Auto Reload All Flag Tests", func() {
Expect(err).NotTo(HaveOccurred())
By("Waiting for Deployment to be ready")
err = utils.WaitForDeploymentReady(ctx, kubeClient, autoNamespace, deploymentName, utils.DeploymentReady)
err = adapter.WaitReady(ctx, autoNamespace, deploymentName, utils.DeploymentReady)
Expect(err).NotTo(HaveOccurred())
By("Updating the ConfigMap")
@@ -67,7 +69,7 @@ var _ = Describe("Auto Reload All Flag Tests", func() {
Expect(err).NotTo(HaveOccurred())
By("Waiting for Deployment to be reloaded (autoReloadAll=true)")
reloaded, err := utils.WaitForDeploymentReloaded(ctx, kubeClient, autoNamespace, deploymentName,
reloaded, err := adapter.WaitReloaded(ctx, autoNamespace, deploymentName,
utils.AnnotationLastReloadedFrom, utils.ReloadTimeout)
Expect(err).NotTo(HaveOccurred())
Expect(reloaded).To(BeTrue(), "Deployment without annotations should reload when autoReloadAll=true")
@@ -87,7 +89,7 @@ var _ = Describe("Auto Reload All Flag Tests", func() {
Expect(err).NotTo(HaveOccurred())
By("Waiting for Deployment to be ready")
err = utils.WaitForDeploymentReady(ctx, kubeClient, autoNamespace, deploymentName, utils.DeploymentReady)
err = adapter.WaitReady(ctx, autoNamespace, deploymentName, utils.DeploymentReady)
Expect(err).NotTo(HaveOccurred())
By("Updating the ConfigMap")
@@ -96,7 +98,7 @@ var _ = Describe("Auto Reload All Flag Tests", func() {
By("Verifying Deployment was NOT reloaded (auto=false overrides autoReloadAll)")
time.Sleep(utils.NegativeTestWait)
reloaded, err := utils.WaitForDeploymentReloaded(ctx, kubeClient, autoNamespace, deploymentName,
reloaded, err := adapter.WaitReloaded(ctx, autoNamespace, deploymentName,
utils.AnnotationLastReloadedFrom, utils.ShortTimeout)
Expect(err).NotTo(HaveOccurred())
Expect(reloaded).To(BeFalse(), "Deployment with auto=false should NOT reload even with autoReloadAll=true")

View File

@@ -15,6 +15,7 @@ var _ = Describe("Ignore Resources Flag Tests", func() {
configMapName string
secretName string
ignoreNS string
adapter *utils.DeploymentAdapter
)
BeforeEach(func() {
@@ -22,6 +23,7 @@ var _ = Describe("Ignore Resources Flag Tests", func() {
configMapName = utils.RandName("cm")
secretName = utils.RandName("secret")
ignoreNS = "ignore-" + utils.RandName("ns")
adapter = utils.NewDeploymentAdapter(kubeClient)
})
AfterEach(func() {
@@ -65,7 +67,7 @@ var _ = Describe("Ignore Resources Flag Tests", func() {
Expect(err).NotTo(HaveOccurred())
By("Waiting for Deployment to be ready")
err = utils.WaitForDeploymentReady(ctx, kubeClient, ignoreNS, deploymentName, utils.DeploymentReady)
err = adapter.WaitReady(ctx, ignoreNS, deploymentName, utils.DeploymentReady)
Expect(err).NotTo(HaveOccurred())
By("Updating the Secret")
@@ -74,7 +76,7 @@ var _ = Describe("Ignore Resources Flag Tests", func() {
By("Verifying Deployment was NOT reloaded (ignoreSecrets=true)")
time.Sleep(utils.NegativeTestWait)
reloaded, err := utils.WaitForDeploymentReloaded(ctx, kubeClient, ignoreNS, deploymentName,
reloaded, err := adapter.WaitReloaded(ctx, ignoreNS, deploymentName,
utils.AnnotationLastReloadedFrom, utils.ShortTimeout)
Expect(err).NotTo(HaveOccurred())
Expect(reloaded).To(BeFalse(), "Deployment should NOT reload when ignoreSecrets=true")
@@ -94,7 +96,7 @@ var _ = Describe("Ignore Resources Flag Tests", func() {
Expect(err).NotTo(HaveOccurred())
By("Waiting for Deployment to be ready")
err = utils.WaitForDeploymentReady(ctx, kubeClient, ignoreNS, deploymentName, utils.DeploymentReady)
err = adapter.WaitReady(ctx, ignoreNS, deploymentName, utils.DeploymentReady)
Expect(err).NotTo(HaveOccurred())
By("Updating the ConfigMap")
@@ -102,7 +104,7 @@ var _ = Describe("Ignore Resources Flag Tests", func() {
Expect(err).NotTo(HaveOccurred())
By("Waiting for Deployment to be reloaded (ConfigMap should still work)")
reloaded, err := utils.WaitForDeploymentReloaded(ctx, kubeClient, ignoreNS, deploymentName,
reloaded, err := adapter.WaitReloaded(ctx, ignoreNS, deploymentName,
utils.AnnotationLastReloadedFrom, utils.ReloadTimeout)
Expect(err).NotTo(HaveOccurred())
Expect(reloaded).To(BeTrue(), "ConfigMap changes should still trigger reload with ignoreSecrets=true")
@@ -144,7 +146,7 @@ var _ = Describe("Ignore Resources Flag Tests", func() {
Expect(err).NotTo(HaveOccurred())
By("Waiting for Deployment to be ready")
err = utils.WaitForDeploymentReady(ctx, kubeClient, ignoreNS, deploymentName, utils.DeploymentReady)
err = adapter.WaitReady(ctx, ignoreNS, deploymentName, utils.DeploymentReady)
Expect(err).NotTo(HaveOccurred())
By("Updating the ConfigMap")
@@ -153,7 +155,7 @@ var _ = Describe("Ignore Resources Flag Tests", func() {
By("Verifying Deployment was NOT reloaded (ignoreConfigMaps=true)")
time.Sleep(utils.NegativeTestWait)
reloaded, err := utils.WaitForDeploymentReloaded(ctx, kubeClient, ignoreNS, deploymentName,
reloaded, err := adapter.WaitReloaded(ctx, ignoreNS, deploymentName,
utils.AnnotationLastReloadedFrom, utils.ShortTimeout)
Expect(err).NotTo(HaveOccurred())
Expect(reloaded).To(BeFalse(), "Deployment should NOT reload when ignoreConfigMaps=true")
@@ -173,7 +175,7 @@ var _ = Describe("Ignore Resources Flag Tests", func() {
Expect(err).NotTo(HaveOccurred())
By("Waiting for Deployment to be ready")
err = utils.WaitForDeploymentReady(ctx, kubeClient, ignoreNS, deploymentName, utils.DeploymentReady)
err = adapter.WaitReady(ctx, ignoreNS, deploymentName, utils.DeploymentReady)
Expect(err).NotTo(HaveOccurred())
By("Updating the Secret")
@@ -181,7 +183,7 @@ var _ = Describe("Ignore Resources Flag Tests", func() {
Expect(err).NotTo(HaveOccurred())
By("Waiting for Deployment to be reloaded (Secret should still work)")
reloaded, err := utils.WaitForDeploymentReloaded(ctx, kubeClient, ignoreNS, deploymentName,
reloaded, err := adapter.WaitReloaded(ctx, ignoreNS, deploymentName,
utils.AnnotationLastReloadedFrom, utils.ReloadTimeout)
Expect(err).NotTo(HaveOccurred())
Expect(reloaded).To(BeTrue(), "Secret changes should still trigger reload with ignoreConfigMaps=true")

View File

@@ -11,15 +11,19 @@ import (
var _ = Describe("Ignored Workloads Flag Tests", func() {
var (
cronJobName string
configMapName string
ignoreNS string
cronJobName string
configMapName string
ignoreNS string
cronJobAdapter *utils.CronJobAdapter
deploymentAdater *utils.DeploymentAdapter
)
BeforeEach(func() {
cronJobName = utils.RandName("cj")
configMapName = utils.RandName("cm")
ignoreNS = "ignore-wl-" + utils.RandName("ns")
cronJobAdapter = utils.NewCronJobAdapter(kubeClient)
deploymentAdater = utils.NewDeploymentAdapter(kubeClient)
})
AfterEach(func() {
@@ -67,7 +71,7 @@ var _ = Describe("Ignored Workloads Flag Tests", func() {
By("Verifying CronJob was NOT reloaded (ignoreCronJobs=true)")
time.Sleep(utils.NegativeTestWait)
reloaded, err := utils.WaitForCronJobReloaded(ctx, kubeClient, ignoreNS, cronJobName,
reloaded, err := cronJobAdapter.WaitReloaded(ctx, ignoreNS, cronJobName,
utils.AnnotationLastReloadedFrom, utils.ShortTimeout)
Expect(err).NotTo(HaveOccurred())
Expect(reloaded).To(BeFalse(), "CronJob should NOT reload when ignoreCronJobs=true")
@@ -92,7 +96,7 @@ var _ = Describe("Ignored Workloads Flag Tests", func() {
}()
By("Waiting for Deployment to be ready")
err = utils.WaitForDeploymentReady(ctx, kubeClient, ignoreNS, deploymentName, utils.DeploymentReady)
err = deploymentAdater.WaitReady(ctx, ignoreNS, deploymentName, utils.DeploymentReady)
Expect(err).NotTo(HaveOccurred())
By("Updating the ConfigMap")
@@ -100,7 +104,7 @@ var _ = Describe("Ignored Workloads Flag Tests", func() {
Expect(err).NotTo(HaveOccurred())
By("Waiting for Deployment to be reloaded (Deployment should still work)")
reloaded, err := utils.WaitForDeploymentReloaded(ctx, kubeClient, ignoreNS, deploymentName,
reloaded, err := deploymentAdater.WaitReloaded(ctx, ignoreNS, deploymentName,
utils.AnnotationLastReloadedFrom, utils.ReloadTimeout)
Expect(err).NotTo(HaveOccurred())
Expect(reloaded).To(BeTrue(), "Deployment should still reload with ignoreCronJobs=true")
@@ -148,7 +152,7 @@ var _ = Describe("Ignored Workloads Flag Tests", func() {
By("Verifying CronJob was NOT reloaded")
time.Sleep(utils.NegativeTestWait)
reloaded, err := utils.WaitForCronJobReloaded(ctx, kubeClient, ignoreNS, cronJobName,
reloaded, err := cronJobAdapter.WaitReloaded(ctx, ignoreNS, cronJobName,
utils.AnnotationLastReloadedFrom, utils.ShortTimeout)
Expect(err).NotTo(HaveOccurred())
Expect(reloaded).To(BeFalse(), "CronJob should NOT reload when ignoreCronJobs=true and ignoreJobs=true")

View File

@@ -15,6 +15,7 @@ var _ = Describe("Namespace Ignore Flag Tests", func() {
configMapName string
ignoredNamespace string
watchedNamespace string
adapter *utils.DeploymentAdapter
)
BeforeEach(func() {
@@ -22,6 +23,7 @@ var _ = Describe("Namespace Ignore Flag Tests", func() {
configMapName = utils.RandName("cm")
ignoredNamespace = "ignored-" + utils.RandName("ns")
watchedNamespace = "watched-" + utils.RandName("ns")
adapter = utils.NewDeploymentAdapter(kubeClient)
})
AfterEach(func() {
@@ -67,7 +69,7 @@ var _ = Describe("Namespace Ignore Flag Tests", func() {
Expect(err).NotTo(HaveOccurred())
By("Waiting for Deployment to be ready")
err = utils.WaitForDeploymentReady(ctx, kubeClient, ignoredNamespace, deploymentName, utils.DeploymentReady)
err = adapter.WaitReady(ctx, ignoredNamespace, deploymentName, utils.DeploymentReady)
Expect(err).NotTo(HaveOccurred())
By("Updating the ConfigMap")
@@ -76,7 +78,7 @@ var _ = Describe("Namespace Ignore Flag Tests", func() {
By("Verifying Deployment was NOT reloaded (ignored namespace)")
time.Sleep(utils.NegativeTestWait)
reloaded, err := utils.WaitForDeploymentReloaded(ctx, kubeClient, ignoredNamespace, deploymentName,
reloaded, err := adapter.WaitReloaded(ctx, ignoredNamespace, deploymentName,
utils.AnnotationLastReloadedFrom, utils.ShortTimeout)
Expect(err).NotTo(HaveOccurred())
Expect(reloaded).To(BeFalse(), "Deployment in ignored namespace should NOT be reloaded")
@@ -96,7 +98,7 @@ var _ = Describe("Namespace Ignore Flag Tests", func() {
Expect(err).NotTo(HaveOccurred())
By("Waiting for Deployment to be ready")
err = utils.WaitForDeploymentReady(ctx, kubeClient, watchedNamespace, deploymentName, utils.DeploymentReady)
err = adapter.WaitReady(ctx, watchedNamespace, deploymentName, utils.DeploymentReady)
Expect(err).NotTo(HaveOccurred())
By("Updating the ConfigMap")
@@ -104,7 +106,7 @@ var _ = Describe("Namespace Ignore Flag Tests", func() {
Expect(err).NotTo(HaveOccurred())
By("Waiting for Deployment to be reloaded")
reloaded, err := utils.WaitForDeploymentReloaded(ctx, kubeClient, watchedNamespace, deploymentName,
reloaded, err := adapter.WaitReloaded(ctx, watchedNamespace, deploymentName,
utils.AnnotationLastReloadedFrom, utils.ReloadTimeout)
Expect(err).NotTo(HaveOccurred())
Expect(reloaded).To(BeTrue(), "Deployment in non-ignored namespace should be reloaded")

View File

@@ -15,6 +15,7 @@ var _ = Describe("Namespace Selector Flag Tests", func() {
configMapName string
matchingNS string
nonMatchingNS string
adapter *utils.DeploymentAdapter
)
BeforeEach(func() {
@@ -22,6 +23,7 @@ var _ = Describe("Namespace Selector Flag Tests", func() {
configMapName = utils.RandName("cm")
matchingNS = "match-" + utils.RandName("ns")
nonMatchingNS = "nomatch-" + utils.RandName("ns")
adapter = utils.NewDeploymentAdapter(kubeClient)
})
AfterEach(func() {
@@ -68,7 +70,7 @@ var _ = Describe("Namespace Selector Flag Tests", func() {
Expect(err).NotTo(HaveOccurred())
By("Waiting for Deployment to be ready")
err = utils.WaitForDeploymentReady(ctx, kubeClient, matchingNS, deploymentName, utils.DeploymentReady)
err = adapter.WaitReady(ctx, matchingNS, deploymentName, utils.DeploymentReady)
Expect(err).NotTo(HaveOccurred())
By("Updating the ConfigMap")
@@ -76,7 +78,7 @@ var _ = Describe("Namespace Selector Flag Tests", func() {
Expect(err).NotTo(HaveOccurred())
By("Waiting for Deployment to be reloaded")
reloaded, err := utils.WaitForDeploymentReloaded(ctx, kubeClient, matchingNS, deploymentName,
reloaded, err := adapter.WaitReloaded(ctx, matchingNS, deploymentName,
utils.AnnotationLastReloadedFrom, utils.ReloadTimeout)
Expect(err).NotTo(HaveOccurred())
Expect(reloaded).To(BeTrue(), "Deployment in matching namespace should be reloaded")
@@ -96,7 +98,7 @@ var _ = Describe("Namespace Selector Flag Tests", func() {
Expect(err).NotTo(HaveOccurred())
By("Waiting for Deployment to be ready")
err = utils.WaitForDeploymentReady(ctx, kubeClient, nonMatchingNS, deploymentName, utils.DeploymentReady)
err = adapter.WaitReady(ctx, nonMatchingNS, deploymentName, utils.DeploymentReady)
Expect(err).NotTo(HaveOccurred())
By("Updating the ConfigMap")
@@ -105,7 +107,7 @@ var _ = Describe("Namespace Selector Flag Tests", func() {
By("Verifying Deployment was NOT reloaded (non-matching namespace)")
time.Sleep(utils.NegativeTestWait)
reloaded, err := utils.WaitForDeploymentReloaded(ctx, kubeClient, nonMatchingNS, deploymentName,
reloaded, err := adapter.WaitReloaded(ctx, nonMatchingNS, deploymentName,
utils.AnnotationLastReloadedFrom, utils.ShortTimeout)
Expect(err).NotTo(HaveOccurred())
Expect(reloaded).To(BeFalse(), "Deployment in non-matching namespace should NOT be reloaded")

View File

@@ -14,12 +14,14 @@ var _ = Describe("Reload On Create Flag Tests", func() {
deploymentName string
configMapName string
createNamespace string
adapter *utils.DeploymentAdapter
)
BeforeEach(func() {
deploymentName = utils.RandName("deploy")
configMapName = utils.RandName("cm")
createNamespace = "create-" + utils.RandName("ns")
adapter = utils.NewDeploymentAdapter(kubeClient)
})
AfterEach(func() {
@@ -56,7 +58,7 @@ var _ = Describe("Reload On Create Flag Tests", func() {
Expect(err).NotTo(HaveOccurred())
By("Waiting for Deployment to be ready")
err = utils.WaitForDeploymentReady(ctx, kubeClient, createNamespace, deploymentName, utils.DeploymentReady)
err = adapter.WaitReady(ctx, createNamespace, deploymentName, utils.DeploymentReady)
Expect(err).NotTo(HaveOccurred())
By("Creating the ConfigMap that the Deployment references")
@@ -65,7 +67,7 @@ var _ = Describe("Reload On Create Flag Tests", func() {
Expect(err).NotTo(HaveOccurred())
By("Waiting for Deployment to be reloaded (reloadOnCreate=true)")
reloaded, err := utils.WaitForDeploymentReloaded(ctx, kubeClient, createNamespace, deploymentName,
reloaded, err := adapter.WaitReloaded(ctx, createNamespace, deploymentName,
utils.AnnotationLastReloadedFrom, utils.ReloadTimeout)
Expect(err).NotTo(HaveOccurred())
Expect(reloaded).To(BeTrue(), "Deployment should reload when referenced ConfigMap is created")
@@ -82,7 +84,7 @@ var _ = Describe("Reload On Create Flag Tests", func() {
Expect(err).NotTo(HaveOccurred())
By("Waiting for Deployment to be ready")
err = utils.WaitForDeploymentReady(ctx, kubeClient, createNamespace, deploymentName, utils.DeploymentReady)
err = adapter.WaitReady(ctx, createNamespace, deploymentName, utils.DeploymentReady)
Expect(err).NotTo(HaveOccurred())
By("Creating the Secret that the Deployment references")
@@ -91,7 +93,7 @@ var _ = Describe("Reload On Create Flag Tests", func() {
Expect(err).NotTo(HaveOccurred())
By("Waiting for Deployment to be reloaded (reloadOnCreate=true)")
reloaded, err := utils.WaitForDeploymentReloaded(ctx, kubeClient, createNamespace, deploymentName,
reloaded, err := adapter.WaitReloaded(ctx, createNamespace, deploymentName,
utils.AnnotationLastReloadedFrom, utils.ReloadTimeout)
Expect(err).NotTo(HaveOccurred())
Expect(reloaded).To(BeTrue(), "Deployment should reload when referenced Secret is created")
@@ -125,7 +127,7 @@ var _ = Describe("Reload On Create Flag Tests", func() {
Expect(err).NotTo(HaveOccurred())
By("Waiting for Deployment to be ready")
err = utils.WaitForDeploymentReady(ctx, kubeClient, createNamespace, deploymentName, utils.DeploymentReady)
err = adapter.WaitReady(ctx, createNamespace, deploymentName, utils.DeploymentReady)
Expect(err).NotTo(HaveOccurred())
By("Creating the ConfigMap that the Deployment references")
@@ -135,7 +137,7 @@ var _ = Describe("Reload On Create Flag Tests", func() {
By("Verifying Deployment was NOT reloaded (reloadOnCreate=false)")
time.Sleep(utils.NegativeTestWait)
reloaded, err := utils.WaitForDeploymentReloaded(ctx, kubeClient, createNamespace, deploymentName,
reloaded, err := adapter.WaitReloaded(ctx, createNamespace, deploymentName,
utils.AnnotationLastReloadedFrom, utils.ShortTimeout)
Expect(err).NotTo(HaveOccurred())
Expect(reloaded).To(BeFalse(), "Deployment should NOT reload on create when reloadOnCreate=false")

View File

@@ -14,12 +14,14 @@ var _ = Describe("Reload On Delete Flag Tests", func() {
deploymentName string
configMapName string
deleteNamespace string
adapter *utils.DeploymentAdapter
)
BeforeEach(func() {
deploymentName = utils.RandName("deploy")
configMapName = utils.RandName("cm")
deleteNamespace = "delete-" + utils.RandName("ns")
adapter = utils.NewDeploymentAdapter(kubeClient)
})
AfterEach(func() {
@@ -61,7 +63,7 @@ var _ = Describe("Reload On Delete Flag Tests", func() {
Expect(err).NotTo(HaveOccurred())
By("Waiting for Deployment to be ready")
err = utils.WaitForDeploymentReady(ctx, kubeClient, deleteNamespace, deploymentName, utils.DeploymentReady)
err = adapter.WaitReady(ctx, deleteNamespace, deploymentName, utils.DeploymentReady)
Expect(err).NotTo(HaveOccurred())
By("Deleting the ConfigMap")
@@ -69,7 +71,7 @@ var _ = Describe("Reload On Delete Flag Tests", func() {
Expect(err).NotTo(HaveOccurred())
By("Waiting for Deployment to be reloaded (reloadOnDelete=true)")
reloaded, err := utils.WaitForDeploymentReloaded(ctx, kubeClient, deleteNamespace, deploymentName,
reloaded, err := adapter.WaitReloaded(ctx, deleteNamespace, deploymentName,
utils.AnnotationLastReloadedFrom, utils.ReloadTimeout)
Expect(err).NotTo(HaveOccurred())
Expect(reloaded).To(BeTrue(), "Deployment should reload when referenced ConfigMap is deleted")
@@ -90,7 +92,7 @@ var _ = Describe("Reload On Delete Flag Tests", func() {
Expect(err).NotTo(HaveOccurred())
By("Waiting for Deployment to be ready")
err = utils.WaitForDeploymentReady(ctx, kubeClient, deleteNamespace, deploymentName, utils.DeploymentReady)
err = adapter.WaitReady(ctx, deleteNamespace, deploymentName, utils.DeploymentReady)
Expect(err).NotTo(HaveOccurred())
By("Deleting the Secret")
@@ -98,7 +100,7 @@ var _ = Describe("Reload On Delete Flag Tests", func() {
Expect(err).NotTo(HaveOccurred())
By("Waiting for Deployment to be reloaded (reloadOnDelete=true)")
reloaded, err := utils.WaitForDeploymentReloaded(ctx, kubeClient, deleteNamespace, deploymentName,
reloaded, err := adapter.WaitReloaded(ctx, deleteNamespace, deploymentName,
utils.AnnotationLastReloadedFrom, utils.ReloadTimeout)
Expect(err).NotTo(HaveOccurred())
Expect(reloaded).To(BeTrue(), "Deployment should reload when referenced Secret is deleted")
@@ -137,7 +139,7 @@ var _ = Describe("Reload On Delete Flag Tests", func() {
Expect(err).NotTo(HaveOccurred())
By("Waiting for Deployment to be ready")
err = utils.WaitForDeploymentReady(ctx, kubeClient, deleteNamespace, deploymentName, utils.DeploymentReady)
err = adapter.WaitReady(ctx, deleteNamespace, deploymentName, utils.DeploymentReady)
Expect(err).NotTo(HaveOccurred())
By("Deleting the ConfigMap")
@@ -146,7 +148,7 @@ var _ = Describe("Reload On Delete Flag Tests", func() {
By("Verifying Deployment was NOT reloaded (reloadOnDelete=false)")
time.Sleep(utils.NegativeTestWait)
reloaded, err := utils.WaitForDeploymentReloaded(ctx, kubeClient, deleteNamespace, deploymentName,
reloaded, err := adapter.WaitReloaded(ctx, deleteNamespace, deploymentName,
utils.AnnotationLastReloadedFrom, utils.ShortTimeout)
Expect(err).NotTo(HaveOccurred())
Expect(reloaded).To(BeFalse(), "Deployment should NOT reload on delete when reloadOnDelete=false")

View File

@@ -15,6 +15,7 @@ var _ = Describe("Resource Label Selector Flag Tests", func() {
matchingCM string
nonMatchingCM string
resourceNS string
adapter *utils.DeploymentAdapter
)
BeforeEach(func() {
@@ -22,6 +23,7 @@ var _ = Describe("Resource Label Selector Flag Tests", func() {
matchingCM = utils.RandName("match-cm")
nonMatchingCM = utils.RandName("nomatch-cm")
resourceNS = "resource-" + utils.RandName("ns")
adapter = utils.NewDeploymentAdapter(kubeClient)
})
AfterEach(func() {
@@ -66,7 +68,7 @@ var _ = Describe("Resource Label Selector Flag Tests", func() {
Expect(err).NotTo(HaveOccurred())
By("Waiting for Deployment to be ready")
err = utils.WaitForDeploymentReady(ctx, kubeClient, resourceNS, deploymentName, utils.DeploymentReady)
err = adapter.WaitReady(ctx, resourceNS, deploymentName, utils.DeploymentReady)
Expect(err).NotTo(HaveOccurred())
By("Updating the labeled ConfigMap")
@@ -74,7 +76,7 @@ var _ = Describe("Resource Label Selector Flag Tests", func() {
Expect(err).NotTo(HaveOccurred())
By("Waiting for Deployment to be reloaded")
reloaded, err := utils.WaitForDeploymentReloaded(ctx, kubeClient, resourceNS, deploymentName,
reloaded, err := adapter.WaitReloaded(ctx, resourceNS, deploymentName,
utils.AnnotationLastReloadedFrom, utils.ReloadTimeout)
Expect(err).NotTo(HaveOccurred())
Expect(reloaded).To(BeTrue(), "Deployment should be reloaded when labeled ConfigMap changes")
@@ -94,7 +96,7 @@ var _ = Describe("Resource Label Selector Flag Tests", func() {
Expect(err).NotTo(HaveOccurred())
By("Waiting for Deployment to be ready")
err = utils.WaitForDeploymentReady(ctx, kubeClient, resourceNS, deploymentName, utils.DeploymentReady)
err = adapter.WaitReady(ctx, resourceNS, deploymentName, utils.DeploymentReady)
Expect(err).NotTo(HaveOccurred())
By("Updating the unlabeled ConfigMap")
@@ -103,7 +105,7 @@ var _ = Describe("Resource Label Selector Flag Tests", func() {
By("Verifying Deployment was NOT reloaded (unlabeled ConfigMap)")
time.Sleep(utils.NegativeTestWait)
reloaded, err := utils.WaitForDeploymentReloaded(ctx, kubeClient, resourceNS, deploymentName,
reloaded, err := adapter.WaitReloaded(ctx, resourceNS, deploymentName,
utils.AnnotationLastReloadedFrom, utils.ShortTimeout)
Expect(err).NotTo(HaveOccurred())
Expect(reloaded).To(BeFalse(), "Deployment should NOT reload when unlabeled ConfigMap changes")

View File

@@ -14,12 +14,14 @@ var _ = Describe("Watch Globally Flag Tests", func() {
deploymentName string
configMapName string
otherNS string
adapter *utils.DeploymentAdapter
)
BeforeEach(func() {
deploymentName = utils.RandName("deploy")
configMapName = utils.RandName("cm")
otherNS = "other-" + utils.RandName("ns")
adapter = utils.NewDeploymentAdapter(kubeClient)
})
AfterEach(func() {
@@ -66,7 +68,7 @@ var _ = Describe("Watch Globally Flag Tests", func() {
Expect(err).NotTo(HaveOccurred())
By("Waiting for Deployment to be ready")
err = utils.WaitForDeploymentReady(ctx, kubeClient, testNamespace, deploymentName, utils.DeploymentReady)
err = adapter.WaitReady(ctx, testNamespace, deploymentName, utils.DeploymentReady)
Expect(err).NotTo(HaveOccurred())
By("Updating the ConfigMap")
@@ -74,7 +76,7 @@ var _ = Describe("Watch Globally Flag Tests", func() {
Expect(err).NotTo(HaveOccurred())
By("Waiting for Deployment to be reloaded (same namespace should work)")
reloaded, err := utils.WaitForDeploymentReloaded(ctx, kubeClient, testNamespace, deploymentName,
reloaded, err := adapter.WaitReloaded(ctx, testNamespace, deploymentName,
utils.AnnotationLastReloadedFrom, utils.ReloadTimeout)
Expect(err).NotTo(HaveOccurred())
Expect(reloaded).To(BeTrue(), "Deployment in Reloader's namespace should reload with watchGlobally=false")
@@ -94,7 +96,7 @@ var _ = Describe("Watch Globally Flag Tests", func() {
Expect(err).NotTo(HaveOccurred())
By("Waiting for Deployment to be ready")
err = utils.WaitForDeploymentReady(ctx, kubeClient, otherNS, deploymentName, utils.DeploymentReady)
err = adapter.WaitReady(ctx, otherNS, deploymentName, utils.DeploymentReady)
Expect(err).NotTo(HaveOccurred())
By("Updating the ConfigMap in the other namespace")
@@ -103,7 +105,7 @@ var _ = Describe("Watch Globally Flag Tests", func() {
By("Verifying Deployment was NOT reloaded (different namespace with watchGlobally=false)")
time.Sleep(utils.NegativeTestWait)
reloaded, err := utils.WaitForDeploymentReloaded(ctx, kubeClient, otherNS, deploymentName,
reloaded, err := adapter.WaitReloaded(ctx, otherNS, deploymentName,
utils.AnnotationLastReloadedFrom, utils.ShortTimeout)
Expect(err).NotTo(HaveOccurred())
Expect(reloaded).To(BeFalse(), "Deployment in other namespace should NOT reload with watchGlobally=false")
@@ -151,7 +153,7 @@ var _ = Describe("Watch Globally Flag Tests", func() {
Expect(err).NotTo(HaveOccurred())
By("Waiting for Deployment to be ready")
err = utils.WaitForDeploymentReady(ctx, kubeClient, globalNS, deploymentName, utils.DeploymentReady)
err = adapter.WaitReady(ctx, globalNS, deploymentName, utils.DeploymentReady)
Expect(err).NotTo(HaveOccurred())
By("Updating the ConfigMap")
@@ -159,7 +161,7 @@ var _ = Describe("Watch Globally Flag Tests", func() {
Expect(err).NotTo(HaveOccurred())
By("Waiting for Deployment to be reloaded (watchGlobally=true)")
reloaded, err := utils.WaitForDeploymentReloaded(ctx, kubeClient, globalNS, deploymentName,
reloaded, err := adapter.WaitReloaded(ctx, globalNS, deploymentName,
utils.AnnotationLastReloadedFrom, utils.ReloadTimeout)
Expect(err).NotTo(HaveOccurred())
Expect(reloaded).To(BeTrue(), "Deployment in any namespace should reload with watchGlobally=true")