From 4bbd40441fe475843e3d66e991338f3a2aa38ae5 Mon Sep 17 00:00:00 2001 From: shashidharatd Date: Mon, 31 Oct 2016 10:58:44 +0530 Subject: [PATCH] Add ConfigMaps to k8s upgrade tests --- test/e2e/cluster_upgrade.go | 42 ++++++++++++++++++++++++++++++++++++ test/e2e/common/configmap.go | 13 +++++++++-- 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/test/e2e/cluster_upgrade.go b/test/e2e/cluster_upgrade.go index 1468fed58d1..5c7c934b38d 100644 --- a/test/e2e/cluster_upgrade.go +++ b/test/e2e/cluster_upgrade.go @@ -49,6 +49,7 @@ var _ = framework.KubeDescribe("Upgrade [Feature:Upgrade]", func() { // Close over f. testServiceRemainsUp(f, sem) testSecretsDuringUpgrade(f, sem) + testConfigMapsDuringUpgrade(f, sem) }) cm.Do() }) @@ -66,6 +67,7 @@ var _ = framework.KubeDescribe("Upgrade [Feature:Upgrade]", func() { // Close over f. testServiceUpBeforeAndAfter(f, sem) testSecretsBeforeAndAfterUpgrade(f, sem) + testConfigMapsBeforeAndAfterUpgrade(f, sem) }) cm.Do() }) @@ -81,6 +83,7 @@ var _ = framework.KubeDescribe("Upgrade [Feature:Upgrade]", func() { // Close over f. testServiceRemainsUp(f, sem) testSecretsDuringUpgrade(f, sem) + testConfigMapsDuringUpgrade(f, sem) }) cm.Do() }) @@ -100,6 +103,7 @@ var _ = framework.KubeDescribe("Upgrade [Feature:Upgrade]", func() { // Close over f. testServiceUpBeforeAndAfter(f, sem) testSecretsBeforeAndAfterUpgrade(f, sem) + testConfigMapsBeforeAndAfterUpgrade(f, sem) }) cm.Do() }) @@ -117,6 +121,7 @@ var _ = framework.KubeDescribe("Upgrade [Feature:Upgrade]", func() { // Close over f. testServiceRemainsUp(f, sem) testSecretsDuringUpgrade(f, sem) + testConfigMapsDuringUpgrade(f, sem) }) cm.Do() }) @@ -270,3 +275,40 @@ func testSecrets(f *framework.Framework, sem *chaosmonkey.Semaphore, testDuringD // Teardown } + +func testConfigMapsBeforeAndAfterUpgrade(f *framework.Framework, sem *chaosmonkey.Semaphore) { + testConfigMaps(f, sem, false) +} + +func testConfigMapsDuringUpgrade(f *framework.Framework, sem *chaosmonkey.Semaphore) { + testConfigMaps(f, sem, true) +} + +func testConfigMaps(f *framework.Framework, sem *chaosmonkey.Semaphore, testDuringDisruption bool) { + // Setup + pod, expectedOutput := common.DoConfigMapE2EWithoutMappingsSetup(f, 0, 0, nil) + + // Validate + By("consume config-maps before upgrade") + common.DoConfigMapE2EWithoutMappingsValidate(f, pod, expectedOutput) + + sem.Ready() + + if testDuringDisruption { + // Continuously validate + wait.Until(func() { + By("consume config-maps during upgrade") + common.DoConfigMapE2EWithoutMappingsValidate(f, pod, expectedOutput) + }, framework.Poll, sem.StopCh) + } else { + // Block until chaosmonkey is done + By("waiting for upgrade to finish without consuming config-maps") + <-sem.StopCh + } + + // Validate after upgrade + By("consume config-maps after upgrade") + common.DoConfigMapE2EWithoutMappingsValidate(f, pod, expectedOutput) + + // Teardown +} diff --git a/test/e2e/common/configmap.go b/test/e2e/common/configmap.go index 47780ff977f..8d6bb28f7b3 100644 --- a/test/e2e/common/configmap.go +++ b/test/e2e/common/configmap.go @@ -278,7 +278,7 @@ func newConfigMap(f *framework.Framework, name string) *api.ConfigMap { } } -func doConfigMapE2EWithoutMappings(f *framework.Framework, uid, fsGroup int64, defaultMode *int32) { +func DoConfigMapE2EWithoutMappingsSetup(f *framework.Framework, uid, fsGroup int64, defaultMode *int32) (*api.Pod, []string) { var ( name = "configmap-test-volume-" + string(uuid.NewUUID()) volumeName = "configmap-volume" @@ -352,8 +352,17 @@ func doConfigMapE2EWithoutMappings(f *framework.Framework, uid, fsGroup int64, d modeString := fmt.Sprintf("%v", os.FileMode(*defaultMode)) output = append(output, "mode of file \"/etc/configmap-volume/data-1\": "+modeString) } - f.TestContainerOutput("consume configMaps", pod, 0, output) + return pod, output +} + +func DoConfigMapE2EWithoutMappingsValidate(f *framework.Framework, pod *api.Pod, output []string) { + f.TestContainerOutput("consume configMaps", pod, 0, output) +} + +func doConfigMapE2EWithoutMappings(f *framework.Framework, uid, fsGroup int64, defaultMode *int32) { + pod, output := DoConfigMapE2EWithoutMappingsSetup(f, uid, fsGroup, defaultMode) + DoConfigMapE2EWithoutMappingsValidate(f, pod, output) } func doConfigMapE2EWithMappings(f *framework.Framework, uid, fsGroup int64, itemMode *int32) {