Auto update referenced resource (#45)

* Add implementation for create event

Signed-off-by: faizanahmad055 <faizan.ahmad55@outlook.com>

* Add sleep in testcase

Signed-off-by: faizanahmad055 <faizan.ahmad55@outlook.com>

* Fix test case data

Signed-off-by: faizanahmad055 <faizan.ahmad55@outlook.com>

* Remove unnecessary dashes from chart

Signed-off-by: faizanahmad055 <faizan.ahmad55@outlook.com>

* Fix new env var creation issue

Signed-off-by: faizanahmad055 <faizan.ahmad55@outlook.com>

* Optimize upgrade code

Signed-off-by: faizanahmad055 <faizan.ahmad55@outlook.com>

* Update logs

Signed-off-by: faizanahmad055 <faizan.ahmad55@outlook.com>

* Initial implementation to perform rolling upgrades by auto referencing the resources

Signed-off-by: faizanahmad055 <faizan.ahmad55@outlook.com>

* Fix nil pointer exception

Signed-off-by: faizanahmad055 <faizan.ahmad55@outlook.com>

* Fix test cases

Signed-off-by: faizanahmad055 <faizan.ahmad55@outlook.com>

* Add test cases

Signed-off-by: faizanahmad055 <faizan.ahmad55@outlook.com>

* Update test case verify method

Signed-off-by: faizanahmad055 <faizan.ahmad55@outlook.com>

* Add missing name for envs

Signed-off-by: faizanahmad055 <faizan.ahmad55@outlook.com>

* Update annotation name

Signed-off-by: faizanahmad055 <faizan.ahmad55@outlook.com>

* Update readme

Signed-off-by: faizanahmad055 <faizan.ahmad55@outlook.com>

* Update readme

Signed-off-by: faizanahmad055 <faizan.ahmad55@outlook.com>

* Implement Golang CI comment

Signed-off-by: faizanahmad055 <faizan.ahmad55@outlook.com>

* Implement Golang CI comment

Signed-off-by: faizanahmad055 <faizan.ahmad55@outlook.com>
This commit is contained in:
Faizan Ahmad
2019-01-25 14:00:21 +01:00
committed by Rasheed Amir
parent cd19d739ab
commit 130741480e
19 changed files with 1172 additions and 676 deletions
+1 -1
View File
@@ -64,7 +64,7 @@ func (c *Controller) Update(old interface{}, new interface{}) {
// Delete function to add an object to the queue in case of deleting a resource
func (c *Controller) Delete(old interface{}) {
logrus.Infof("Resource deletion has been detected but no further implementation found to take action")
// Todo: Any future delete event can be handled here
}
//Run function for controller which handles the queue
+211 -110
View File
@@ -6,8 +6,8 @@ import (
"time"
"github.com/sirupsen/logrus"
"github.com/stakater/Reloader/internal/pkg/callbacks"
"github.com/stakater/Reloader/internal/pkg/constants"
"github.com/stakater/Reloader/internal/pkg/handler"
"github.com/stakater/Reloader/internal/pkg/testutil"
"github.com/stakater/Reloader/internal/pkg/util"
"github.com/stakater/Reloader/pkg/kube"
@@ -60,7 +60,7 @@ func TestControllerUpdatingConfigmapShouldCreateEnvInDeployment(t *testing.T) {
}
// Creating deployment
_, err = testutil.CreateDeployment(client, configmapName, namespace)
_, err = testutil.CreateDeployment(client, configmapName, namespace, true)
if err != nil {
t.Errorf("Error in deployment creation: %v", err)
}
@@ -80,12 +80,120 @@ func TestControllerUpdatingConfigmapShouldCreateEnvInDeployment(t *testing.T) {
SHAValue: shaData,
Annotation: constants.ConfigmapUpdateOnChangeAnnotation,
}
deploymentFuncs := callbacks.RollingUpgradeFuncs{
ItemsFunc: callbacks.GetDeploymentItems,
ContainersFunc: callbacks.GetDeploymentContainers,
UpdateFunc: callbacks.UpdateDeployment,
ResourceType: "Deployment",
deploymentFuncs := handler.GetDeploymentRollingUpgradeFuncs()
updated := testutil.VerifyResourceUpdate(client, config, constants.ConfigmapEnvVarPostfix, deploymentFuncs)
if !updated {
t.Errorf("Deployment was not updated")
}
time.Sleep(5 * time.Second)
// Deleting deployment
err = testutil.DeleteDeployment(client, namespace, configmapName)
if err != nil {
logrus.Errorf("Error while deleting the deployment %v", err)
}
// Deleting configmap
err = testutil.DeleteConfigMap(client, namespace, configmapName)
if err != nil {
logrus.Errorf("Error while deleting the configmap %v", err)
}
time.Sleep(5 * time.Second)
}
// Perform rolling upgrade on deployment and create env var upon updating the configmap
func TestControllerUpdatingConfigmapShouldAutoCreateEnvInDeployment(t *testing.T) {
// Creating configmap
configmapName := configmapNamePrefix + "-update-" + testutil.RandSeq(5)
configmapClient, err := testutil.CreateConfigMap(client, namespace, configmapName, "www.google.com")
if err != nil {
t.Errorf("Error while creating the configmap %v", err)
}
// Creating deployment
_, err = testutil.CreateDeployment(client, configmapName, namespace, false)
if err != nil {
t.Errorf("Error in deployment creation: %v", err)
}
// Updating configmap for first time
updateErr := testutil.UpdateConfigMap(configmapClient, namespace, configmapName, "", "www.stakater.com")
if updateErr != nil {
t.Errorf("Configmap was not updated")
}
// Verifying deployment update
logrus.Infof("Verifying env var has been created")
shaData := testutil.ConvertResourceToSHA(testutil.ConfigmapResourceType, namespace, configmapName, "www.stakater.com")
config := util.Config{
Namespace: namespace,
ResourceName: configmapName,
SHAValue: shaData,
Annotation: constants.ConfigmapUpdateOnChangeAnnotation,
}
deploymentFuncs := handler.GetDeploymentRollingUpgradeFuncs()
updated := testutil.VerifyResourceUpdate(client, config, constants.ConfigmapEnvVarPostfix, deploymentFuncs)
if !updated {
t.Errorf("Deployment was not updated")
}
time.Sleep(5 * time.Second)
// Deleting deployment
err = testutil.DeleteDeployment(client, namespace, configmapName)
if err != nil {
logrus.Errorf("Error while deleting the deployment %v", err)
}
// Deleting configmap
err = testutil.DeleteConfigMap(client, namespace, configmapName)
if err != nil {
logrus.Errorf("Error while deleting the configmap %v", err)
}
time.Sleep(5 * time.Second)
}
// Perform rolling upgrade on deployment and create env var upon creating the configmap
func TestControllerCreatingConfigmapShouldCreateEnvInDeployment(t *testing.T) {
// Creating configmap
configmapName := configmapNamePrefix + "-create-" + testutil.RandSeq(5)
_, err := testutil.CreateConfigMap(client, namespace, configmapName, "www.google.com")
if err != nil {
t.Errorf("Error while creating the configmap %v", err)
}
// Creating deployment
_, err = testutil.CreateDeployment(client, configmapName, namespace, true)
if err != nil {
t.Errorf("Error in deployment creation: %v", err)
}
// Deleting configmap for first time
err = testutil.DeleteConfigMap(client, namespace, configmapName)
if err != nil {
logrus.Errorf("Error while deleting the configmap %v", err)
}
time.Sleep(5 * time.Second)
_, err = testutil.CreateConfigMap(client, namespace, configmapName, "www.stakater.com")
if err != nil {
t.Errorf("Error while creating the configmap second time %v", err)
}
time.Sleep(5 * time.Second)
// Verifying deployment update
logrus.Infof("Verifying env var has been created")
shaData := testutil.ConvertResourceToSHA(testutil.ConfigmapResourceType, namespace, configmapName, "www.stakater.com")
config := util.Config{
Namespace: namespace,
ResourceName: configmapName,
SHAValue: shaData,
Annotation: constants.ConfigmapUpdateOnChangeAnnotation,
}
deploymentFuncs := handler.GetDeploymentRollingUpgradeFuncs()
updated := testutil.VerifyResourceUpdate(client, config, constants.ConfigmapEnvVarPostfix, deploymentFuncs)
if !updated {
t.Errorf("Deployment was not updated")
@@ -116,7 +224,7 @@ func TestControllerForUpdatingConfigmapShouldUpdateDeployment(t *testing.T) {
}
// Creating deployment
_, err = testutil.CreateDeployment(client, configmapName, namespace)
_, err = testutil.CreateDeployment(client, configmapName, namespace, true)
if err != nil {
t.Errorf("Error in deployment creation: %v", err)
}
@@ -143,12 +251,7 @@ func TestControllerForUpdatingConfigmapShouldUpdateDeployment(t *testing.T) {
Annotation: constants.ConfigmapUpdateOnChangeAnnotation,
}
deploymentFuncs := callbacks.RollingUpgradeFuncs{
ItemsFunc: callbacks.GetDeploymentItems,
ContainersFunc: callbacks.GetDeploymentContainers,
UpdateFunc: callbacks.UpdateDeployment,
ResourceType: "Deployment",
}
deploymentFuncs := handler.GetDeploymentRollingUpgradeFuncs()
updated := testutil.VerifyResourceUpdate(client, config, constants.ConfigmapEnvVarPostfix, deploymentFuncs)
if !updated {
@@ -180,7 +283,7 @@ func TestControllerUpdatingConfigmapLabelsShouldNotCreateorUpdateEnvInDeployment
}
// Creating deployment
_, err = testutil.CreateDeployment(client, configmapName, namespace)
_, err = testutil.CreateDeployment(client, configmapName, namespace, true)
if err != nil {
t.Errorf("Error in deployment creation: %v", err)
}
@@ -200,12 +303,7 @@ func TestControllerUpdatingConfigmapLabelsShouldNotCreateorUpdateEnvInDeployment
SHAValue: shaData,
Annotation: constants.ConfigmapUpdateOnChangeAnnotation,
}
deploymentFuncs := callbacks.RollingUpgradeFuncs{
ItemsFunc: callbacks.GetDeploymentItems,
ContainersFunc: callbacks.GetDeploymentContainers,
UpdateFunc: callbacks.UpdateDeployment,
ResourceType: "Deployment",
}
deploymentFuncs := handler.GetDeploymentRollingUpgradeFuncs()
updated := testutil.VerifyResourceUpdate(client, config, constants.ConfigmapEnvVarPostfix, deploymentFuncs)
if updated {
t.Errorf("Deployment should not be updated by changing label")
@@ -226,7 +324,66 @@ func TestControllerUpdatingConfigmapLabelsShouldNotCreateorUpdateEnvInDeployment
time.Sleep(5 * time.Second)
}
// Perform rolling upgrade on secret and create a env var upon updating the secret
// Perform rolling upgrade on pod and create a env var upon creating the secret
func TestControllerCreatingSecretShouldCreateEnvInDeployment(t *testing.T) {
// Creating secret
secretName := secretNamePrefix + "-create-" + testutil.RandSeq(5)
_, err := testutil.CreateSecret(client, namespace, secretName, data)
if err != nil {
t.Errorf("Error in secret creation: %v", err)
}
// Creating deployment
_, err = testutil.CreateDeployment(client, secretName, namespace, true)
if err != nil {
t.Errorf("Error in deployment creation: %v", err)
}
//Deleting Secret
err = testutil.DeleteSecret(client, namespace, secretName)
if err != nil {
logrus.Errorf("Error while deleting the secret %v", err)
}
time.Sleep(5 * time.Second)
_, err = testutil.CreateSecret(client, namespace, secretName, newData)
if err != nil {
t.Errorf("Error in secret creation: %v", err)
}
time.Sleep(5 * time.Second)
// Verifying Upgrade
logrus.Infof("Verifying env var has been created")
shaData := testutil.ConvertResourceToSHA(testutil.SecretResourceType, namespace, secretName, newData)
config := util.Config{
Namespace: namespace,
ResourceName: secretName,
SHAValue: shaData,
Annotation: constants.SecretUpdateOnChangeAnnotation,
}
deploymentFuncs := handler.GetDeploymentRollingUpgradeFuncs()
time.Sleep(5 * time.Second)
updated := testutil.VerifyResourceUpdate(client, config, constants.SecretEnvVarPostfix, deploymentFuncs)
if !updated {
t.Errorf("Deployment was not updated")
}
// Deleting Deployment
err = testutil.DeleteDeployment(client, namespace, secretName)
if err != nil {
logrus.Errorf("Error while deleting the deployment %v", err)
}
//Deleting Secret
err = testutil.DeleteSecret(client, namespace, secretName)
if err != nil {
logrus.Errorf("Error while deleting the secret %v", err)
}
time.Sleep(5 * time.Second)
}
// Perform rolling upgrade on pod and create a env var upon updating the secret
func TestControllerUpdatingSecretShouldCreateEnvInDeployment(t *testing.T) {
// Creating secret
secretName := secretNamePrefix + "-update-" + testutil.RandSeq(5)
@@ -236,7 +393,7 @@ func TestControllerUpdatingSecretShouldCreateEnvInDeployment(t *testing.T) {
}
// Creating deployment
_, err = testutil.CreateDeployment(client, secretName, namespace)
_, err = testutil.CreateDeployment(client, secretName, namespace, true)
if err != nil {
t.Errorf("Error in deployment creation: %v", err)
}
@@ -256,12 +413,7 @@ func TestControllerUpdatingSecretShouldCreateEnvInDeployment(t *testing.T) {
SHAValue: shaData,
Annotation: constants.SecretUpdateOnChangeAnnotation,
}
deploymentFuncs := callbacks.RollingUpgradeFuncs{
ItemsFunc: callbacks.GetDeploymentItems,
ContainersFunc: callbacks.GetDeploymentContainers,
UpdateFunc: callbacks.UpdateDeployment,
ResourceType: "Deployment",
}
deploymentFuncs := handler.GetDeploymentRollingUpgradeFuncs()
updated := testutil.VerifyResourceUpdate(client, config, constants.SecretEnvVarPostfix, deploymentFuncs)
if !updated {
t.Errorf("Deployment was not updated")
@@ -291,7 +443,7 @@ func TestControllerUpdatingSecretShouldUpdateEnvInDeployment(t *testing.T) {
}
// Creating deployment
_, err = testutil.CreateDeployment(client, secretName, namespace)
_, err = testutil.CreateDeployment(client, secretName, namespace, true)
if err != nil {
t.Errorf("Error in deployment creation: %v", err)
}
@@ -317,12 +469,7 @@ func TestControllerUpdatingSecretShouldUpdateEnvInDeployment(t *testing.T) {
SHAValue: shaData,
Annotation: constants.SecretUpdateOnChangeAnnotation,
}
deploymentFuncs := callbacks.RollingUpgradeFuncs{
ItemsFunc: callbacks.GetDeploymentItems,
ContainersFunc: callbacks.GetDeploymentContainers,
UpdateFunc: callbacks.UpdateDeployment,
ResourceType: "Deployment",
}
deploymentFuncs := handler.GetDeploymentRollingUpgradeFuncs()
updated := testutil.VerifyResourceUpdate(client, config, constants.SecretEnvVarPostfix, deploymentFuncs)
if !updated {
t.Errorf("Deployment was not updated")
@@ -342,7 +489,7 @@ func TestControllerUpdatingSecretShouldUpdateEnvInDeployment(t *testing.T) {
time.Sleep(5 * time.Second)
}
// Do not Perform rolling upgrade on secret and create or update a env var upon updating the label in secret
// Do not Perform rolling upgrade on pod and create or update a env var upon updating the label in secret
func TestControllerUpdatingSecretLabelsShouldNotCreateorUpdateEnvInDeployment(t *testing.T) {
// Creating secret
secretName := secretNamePrefix + "-update-" + testutil.RandSeq(5)
@@ -352,7 +499,7 @@ func TestControllerUpdatingSecretLabelsShouldNotCreateorUpdateEnvInDeployment(t
}
// Creating deployment
_, err = testutil.CreateDeployment(client, secretName, namespace)
_, err = testutil.CreateDeployment(client, secretName, namespace, true)
if err != nil {
t.Errorf("Error in deployment creation: %v", err)
}
@@ -371,12 +518,7 @@ func TestControllerUpdatingSecretLabelsShouldNotCreateorUpdateEnvInDeployment(t
SHAValue: shaData,
Annotation: constants.SecretUpdateOnChangeAnnotation,
}
deploymentFuncs := callbacks.RollingUpgradeFuncs{
ItemsFunc: callbacks.GetDeploymentItems,
ContainersFunc: callbacks.GetDeploymentContainers,
UpdateFunc: callbacks.UpdateDeployment,
ResourceType: "Deployment",
}
deploymentFuncs := handler.GetDeploymentRollingUpgradeFuncs()
updated := testutil.VerifyResourceUpdate(client, config, constants.SecretEnvVarPostfix, deploymentFuncs)
if updated {
t.Errorf("Deployment should not be updated by changing label in secret")
@@ -406,7 +548,7 @@ func TestControllerUpdatingConfigmapShouldCreateEnvInDaemonSet(t *testing.T) {
}
// Creating DaemonSet
_, err = testutil.CreateDaemonSet(client, configmapName, namespace)
_, err = testutil.CreateDaemonSet(client, configmapName, namespace, true)
if err != nil {
t.Errorf("Error in DaemonSet creation: %v", err)
}
@@ -426,12 +568,7 @@ func TestControllerUpdatingConfigmapShouldCreateEnvInDaemonSet(t *testing.T) {
SHAValue: shaData,
Annotation: constants.ConfigmapUpdateOnChangeAnnotation,
}
daemonSetFuncs := callbacks.RollingUpgradeFuncs{
ItemsFunc: callbacks.GetDaemonSetItems,
ContainersFunc: callbacks.GetDaemonSetContainers,
UpdateFunc: callbacks.UpdateDaemonSet,
ResourceType: "DaemonSet",
}
daemonSetFuncs := handler.GetDaemonSetRollingUpgradeFuncs()
updated := testutil.VerifyResourceUpdate(client, config, constants.ConfigmapEnvVarPostfix, daemonSetFuncs)
if !updated {
t.Errorf("DaemonSet was not updated")
@@ -462,7 +599,7 @@ func TestControllerForUpdatingConfigmapShouldUpdateDaemonSet(t *testing.T) {
}
// Creating DaemonSet
_, err = testutil.CreateDaemonSet(client, configmapName, namespace)
_, err = testutil.CreateDaemonSet(client, configmapName, namespace, true)
if err != nil {
t.Errorf("Error in DaemonSet creation: %v", err)
}
@@ -473,12 +610,16 @@ func TestControllerForUpdatingConfigmapShouldUpdateDaemonSet(t *testing.T) {
t.Errorf("Configmap was not updated")
}
time.Sleep(5 * time.Second)
// Updating configmap for second time
updateErr = testutil.UpdateConfigMap(configmapClient, namespace, configmapName, "", "aurorasolutions.io")
if updateErr != nil {
t.Errorf("Configmap was not updated")
}
time.Sleep(5 * time.Second)
// Verifying DaemonSet update
logrus.Infof("Verifying env var has been updated")
shaData := testutil.ConvertResourceToSHA(testutil.ConfigmapResourceType, namespace, configmapName, "aurorasolutions.io")
@@ -488,12 +629,7 @@ func TestControllerForUpdatingConfigmapShouldUpdateDaemonSet(t *testing.T) {
SHAValue: shaData,
Annotation: constants.ConfigmapUpdateOnChangeAnnotation,
}
daemonSetFuncs := callbacks.RollingUpgradeFuncs{
ItemsFunc: callbacks.GetDaemonSetItems,
ContainersFunc: callbacks.GetDaemonSetContainers,
UpdateFunc: callbacks.UpdateDaemonSet,
ResourceType: "DaemonSet",
}
daemonSetFuncs := handler.GetDaemonSetRollingUpgradeFuncs()
updated := testutil.VerifyResourceUpdate(client, config, constants.ConfigmapEnvVarPostfix, daemonSetFuncs)
if !updated {
t.Errorf("DaemonSet was not updated")
@@ -514,7 +650,7 @@ func TestControllerForUpdatingConfigmapShouldUpdateDaemonSet(t *testing.T) {
time.Sleep(5 * time.Second)
}
// Perform rolling upgrade on secret and create a env var upon updating the secret
// Perform rolling upgrade on pod and create a env var upon updating the secret
func TestControllerUpdatingSecretShouldCreateEnvInDaemonSet(t *testing.T) {
// Creating secret
secretName := secretNamePrefix + "-update-" + testutil.RandSeq(5)
@@ -524,7 +660,7 @@ func TestControllerUpdatingSecretShouldCreateEnvInDaemonSet(t *testing.T) {
}
// Creating DaemonSet
_, err = testutil.CreateDaemonSet(client, secretName, namespace)
_, err = testutil.CreateDaemonSet(client, secretName, namespace, true)
if err != nil {
t.Errorf("Error in DaemonSet creation: %v", err)
}
@@ -544,12 +680,7 @@ func TestControllerUpdatingSecretShouldCreateEnvInDaemonSet(t *testing.T) {
SHAValue: shaData,
Annotation: constants.SecretUpdateOnChangeAnnotation,
}
daemonSetFuncs := callbacks.RollingUpgradeFuncs{
ItemsFunc: callbacks.GetDaemonSetItems,
ContainersFunc: callbacks.GetDaemonSetContainers,
UpdateFunc: callbacks.UpdateDaemonSet,
ResourceType: "DaemonSet",
}
daemonSetFuncs := handler.GetDaemonSetRollingUpgradeFuncs()
updated := testutil.VerifyResourceUpdate(client, config, constants.SecretEnvVarPostfix, daemonSetFuncs)
if !updated {
t.Errorf("DaemonSet was not updated")
@@ -579,7 +710,7 @@ func TestControllerUpdatingSecretShouldUpdateEnvInDaemonSet(t *testing.T) {
}
// Creating DaemonSet
_, err = testutil.CreateDaemonSet(client, secretName, namespace)
_, err = testutil.CreateDaemonSet(client, secretName, namespace, true)
if err != nil {
t.Errorf("Error in DaemonSet creation: %v", err)
}
@@ -606,12 +737,7 @@ func TestControllerUpdatingSecretShouldUpdateEnvInDaemonSet(t *testing.T) {
SHAValue: shaData,
Annotation: constants.SecretUpdateOnChangeAnnotation,
}
daemonSetFuncs := callbacks.RollingUpgradeFuncs{
ItemsFunc: callbacks.GetDaemonSetItems,
ContainersFunc: callbacks.GetDaemonSetContainers,
UpdateFunc: callbacks.UpdateDaemonSet,
ResourceType: "DaemonSet",
}
daemonSetFuncs := handler.GetDaemonSetRollingUpgradeFuncs()
updated := testutil.VerifyResourceUpdate(client, config, constants.SecretEnvVarPostfix, daemonSetFuncs)
if !updated {
t.Errorf("DaemonSet was not updated")
@@ -631,7 +757,7 @@ func TestControllerUpdatingSecretShouldUpdateEnvInDaemonSet(t *testing.T) {
time.Sleep(5 * time.Second)
}
// Do not Perform rolling upgrade on secret and create or update a env var upon updating the label in secret
// Do not Perform rolling upgrade on pod and create or update a env var upon updating the label in secret
func TestControllerUpdatingSecretLabelsShouldNotCreateorUpdateEnvInDaemonSet(t *testing.T) {
// Creating secret
secretName := secretNamePrefix + "-update-" + testutil.RandSeq(5)
@@ -641,7 +767,7 @@ func TestControllerUpdatingSecretLabelsShouldNotCreateorUpdateEnvInDaemonSet(t *
}
// Creating DaemonSet
_, err = testutil.CreateDaemonSet(client, secretName, namespace)
_, err = testutil.CreateDaemonSet(client, secretName, namespace, true)
if err != nil {
t.Errorf("Error in DaemonSet creation: %v", err)
}
@@ -660,12 +786,7 @@ func TestControllerUpdatingSecretLabelsShouldNotCreateorUpdateEnvInDaemonSet(t *
SHAValue: shaData,
Annotation: constants.SecretUpdateOnChangeAnnotation,
}
daemonSetFuncs := callbacks.RollingUpgradeFuncs{
ItemsFunc: callbacks.GetDaemonSetItems,
ContainersFunc: callbacks.GetDaemonSetContainers,
UpdateFunc: callbacks.UpdateDaemonSet,
ResourceType: "DaemonSet",
}
daemonSetFuncs := handler.GetDaemonSetRollingUpgradeFuncs()
updated := testutil.VerifyResourceUpdate(client, config, constants.SecretEnvVarPostfix, daemonSetFuncs)
if updated {
t.Errorf("DaemonSet should not be updated by changing label in secret")
@@ -695,7 +816,7 @@ func TestControllerUpdatingConfigmapShouldCreateEnvInStatefulSet(t *testing.T) {
}
// Creating StatefulSet
_, err = testutil.CreateStatefulSet(client, configmapName, namespace)
_, err = testutil.CreateStatefulSet(client, configmapName, namespace, true)
if err != nil {
t.Errorf("Error in StatefulSet creation: %v", err)
}
@@ -715,12 +836,7 @@ func TestControllerUpdatingConfigmapShouldCreateEnvInStatefulSet(t *testing.T) {
SHAValue: shaData,
Annotation: constants.ConfigmapUpdateOnChangeAnnotation,
}
statefulSetFuncs := callbacks.RollingUpgradeFuncs{
ItemsFunc: callbacks.GetStatefulSetItems,
ContainersFunc: callbacks.GetStatefulsetContainers,
UpdateFunc: callbacks.UpdateStatefulset,
ResourceType: "StatefulSet",
}
statefulSetFuncs := handler.GetStatefulSetRollingUpgradeFuncs()
updated := testutil.VerifyResourceUpdate(client, config, constants.ConfigmapEnvVarPostfix, statefulSetFuncs)
if !updated {
t.Errorf("StatefulSet was not updated")
@@ -751,7 +867,7 @@ func TestControllerForUpdatingConfigmapShouldUpdateStatefulSet(t *testing.T) {
}
// Creating StatefulSet
_, err = testutil.CreateStatefulSet(client, configmapName, namespace)
_, err = testutil.CreateStatefulSet(client, configmapName, namespace, true)
if err != nil {
t.Errorf("Error in StatefulSet creation: %v", err)
}
@@ -777,12 +893,7 @@ func TestControllerForUpdatingConfigmapShouldUpdateStatefulSet(t *testing.T) {
SHAValue: shaData,
Annotation: constants.ConfigmapUpdateOnChangeAnnotation,
}
statefulSetFuncs := callbacks.RollingUpgradeFuncs{
ItemsFunc: callbacks.GetStatefulSetItems,
ContainersFunc: callbacks.GetStatefulsetContainers,
UpdateFunc: callbacks.UpdateStatefulset,
ResourceType: "StatefulSet",
}
statefulSetFuncs := handler.GetStatefulSetRollingUpgradeFuncs()
updated := testutil.VerifyResourceUpdate(client, config, constants.ConfigmapEnvVarPostfix, statefulSetFuncs)
if !updated {
t.Errorf("StatefulSet was not updated")
@@ -803,7 +914,7 @@ func TestControllerForUpdatingConfigmapShouldUpdateStatefulSet(t *testing.T) {
time.Sleep(5 * time.Second)
}
// Perform rolling upgrade on secret and create a env var upon updating the secret
// Perform rolling upgrade on pod and create a env var upon updating the secret
func TestControllerUpdatingSecretShouldCreateEnvInStatefulSet(t *testing.T) {
// Creating secret
secretName := secretNamePrefix + "-update-" + testutil.RandSeq(5)
@@ -813,7 +924,7 @@ func TestControllerUpdatingSecretShouldCreateEnvInStatefulSet(t *testing.T) {
}
// Creating StatefulSet
_, err = testutil.CreateStatefulSet(client, secretName, namespace)
_, err = testutil.CreateStatefulSet(client, secretName, namespace, true)
if err != nil {
t.Errorf("Error in StatefulSet creation: %v", err)
}
@@ -833,12 +944,7 @@ func TestControllerUpdatingSecretShouldCreateEnvInStatefulSet(t *testing.T) {
SHAValue: shaData,
Annotation: constants.SecretUpdateOnChangeAnnotation,
}
statefulSetFuncs := callbacks.RollingUpgradeFuncs{
ItemsFunc: callbacks.GetStatefulSetItems,
ContainersFunc: callbacks.GetStatefulsetContainers,
UpdateFunc: callbacks.UpdateStatefulset,
ResourceType: "StatefulSet",
}
statefulSetFuncs := handler.GetStatefulSetRollingUpgradeFuncs()
updated := testutil.VerifyResourceUpdate(client, config, constants.SecretEnvVarPostfix, statefulSetFuncs)
if !updated {
t.Errorf("StatefulSet was not updated")
@@ -868,7 +974,7 @@ func TestControllerUpdatingSecretShouldUpdateEnvInStatefulSet(t *testing.T) {
}
// Creating StatefulSet
_, err = testutil.CreateStatefulSet(client, secretName, namespace)
_, err = testutil.CreateStatefulSet(client, secretName, namespace, true)
if err != nil {
t.Errorf("Error in StatefulSet creation: %v", err)
}
@@ -894,12 +1000,7 @@ func TestControllerUpdatingSecretShouldUpdateEnvInStatefulSet(t *testing.T) {
SHAValue: shaData,
Annotation: constants.SecretUpdateOnChangeAnnotation,
}
statefulSetFuncs := callbacks.RollingUpgradeFuncs{
ItemsFunc: callbacks.GetStatefulSetItems,
ContainersFunc: callbacks.GetStatefulsetContainers,
UpdateFunc: callbacks.UpdateStatefulset,
ResourceType: "StatefulSet",
}
statefulSetFuncs := handler.GetStatefulSetRollingUpgradeFuncs()
updated := testutil.VerifyResourceUpdate(client, config, constants.SecretEnvVarPostfix, statefulSetFuncs)
if !updated {
t.Errorf("StatefulSet was not updated")