From a737c82207b9b5829b9958d4fc694bc145cb364a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grzegorz=20Burzy=C5=84ski?= Date: Thu, 31 Oct 2024 22:07:57 +0100 Subject: [PATCH 1/2] tests: bump version in e2e upgrade tests --- test/e2e/test_helm_install_upgrade.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/test/e2e/test_helm_install_upgrade.go b/test/e2e/test_helm_install_upgrade.go index b9165fd3d..586915ae0 100644 --- a/test/e2e/test_helm_install_upgrade.go +++ b/test/e2e/test_helm_install_upgrade.go @@ -203,19 +203,19 @@ func TestHelmUpgrade(t *testing.T) { }, }, { - name: "upgrade from 1.3.0 to current", - fromVersion: "1.3.0", + name: "upgrade from 1.4.0 to current", + fromVersion: "1.4.0", upgradeToCurrent: true, objectsToDeploy: []client.Object{ &operatorv1beta1.GatewayConfiguration{ ObjectMeta: metav1.ObjectMeta{ - Name: "gwconf-upgrade-130-current", + Name: "gwconf-upgrade-140-current", }, Spec: baseGatewayConfigurationSpec(), }, &gatewayv1.GatewayClass{ ObjectMeta: metav1.ObjectMeta{ - Name: "gwclass-upgrade-130-current", + Name: "gwclass-upgrade-140-current", }, Spec: gatewayv1.GatewayClassSpec{ ParametersRef: &gatewayv1.ParametersReference{ @@ -229,13 +229,13 @@ func TestHelmUpgrade(t *testing.T) { }, &gatewayv1.Gateway{ ObjectMeta: metav1.ObjectMeta{ - GenerateName: "gw-upgrade-130-current-", + GenerateName: "gw-upgrade-140-current-", Labels: map[string]string{ - "gw-upgrade-130-current": "true", + "gw-upgrade-140-current": "true", }, }, Spec: gatewayv1.GatewaySpec{ - GatewayClassName: gatewayv1.ObjectName("gwclass-upgrade-130-current"), + GatewayClassName: gatewayv1.ObjectName("gwclass-upgrade-140-current"), Listeners: []gatewayv1.Listener{{ Name: "http", Protocol: gatewayv1.HTTPProtocolType, @@ -248,7 +248,7 @@ func TestHelmUpgrade(t *testing.T) { { Name: "Gateway is programmed", Func: func(c *assert.CollectT, cl *testutils.K8sClients) { - gatewayAndItsListenersAreProgrammedAssertion("gw-upgrade-130-current=true")(ctx, c, cl.MgrClient) + gatewayAndItsListenersAreProgrammedAssertion("gw-upgrade-140-current=true")(ctx, c, cl.MgrClient) }, }, }, @@ -256,20 +256,20 @@ func TestHelmUpgrade(t *testing.T) { { Name: "Gateway is programmed", Func: func(c *assert.CollectT, cl *testutils.K8sClients) { - gatewayAndItsListenersAreProgrammedAssertion("gw-upgrade-130-current=true")(ctx, c, cl.MgrClient) + gatewayAndItsListenersAreProgrammedAssertion("gw-upgrade-140-current=true")(ctx, c, cl.MgrClient) }, }, { Name: fmt.Sprintf("DataPlane deployment is patched after operator upgrade (due to change in default Kong image version to %q)", helpers.GetDefaultDataPlaneImage()), Func: func(c *assert.CollectT, cl *testutils.K8sClients) { - gatewayDataPlaneDeploymentIsPatched("gw-upgrade-130-current=true")(ctx, c, cl.MgrClient) - gatewayDataPlaneDeploymentHasImageSetTo("gw-upgrade-130-current=true", helpers.GetDefaultDataPlaneImage())(ctx, c, cl.MgrClient) + gatewayDataPlaneDeploymentIsPatched("gw-upgrade-140-current=true")(ctx, c, cl.MgrClient) + gatewayDataPlaneDeploymentHasImageSetTo("gw-upgrade-140-current=true", helpers.GetDefaultDataPlaneImage())(ctx, c, cl.MgrClient) }, }, { Name: "Cluster wide resources owned by the ControlPlane get the proper set of labels", Func: func(c *assert.CollectT, cl *testutils.K8sClients) { - clusterWideResourcesAreProperlyManaged("gw-upgrade-130-current=true")(ctx, c, cl.MgrClient) + clusterWideResourcesAreProperlyManaged("gw-upgrade-140-current=true")(ctx, c, cl.MgrClient) }, }, }, From 72ab20ac12f67f82580d54d2d50f49c5d06d3745 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grzegorz=20Burzy=C5=84ski?= Date: Mon, 4 Nov 2024 12:02:12 +0100 Subject: [PATCH 2/2] generalize test cases names --- test/e2e/test_helm_install_upgrade.go | 129 +++++++------------------- 1 file changed, 32 insertions(+), 97 deletions(-) diff --git a/test/e2e/test_helm_install_upgrade.go b/test/e2e/test_helm_install_upgrade.go index 586915ae0..9b6e79694 100644 --- a/test/e2e/test_helm_install_upgrade.go +++ b/test/e2e/test_helm_install_upgrade.go @@ -62,44 +62,42 @@ func TestHelmUpgrade(t *testing.T) { assertionsAfterInstall []assertion assertionsAfterUpgrade []assertion }{ - // NOTE: We do not support versions earlier than 1.2 with the helm chart. - // The initial version of the chart contained CRDs from KGO 1.2. which - // introduced a breaking change which makes it impossible to upgrade from - // automatically (without manually deleting the CRDs). { - name: "upgrade from 1.2.0 to 1.2.3", - fromVersion: "1.2.0", - toVersion: "1.2.3", + name: "upgrade from one before latest to latest minor", + // TODO: use renovate to bump the version in these 2 lines. + // https://github.com/Kong/gateway-operator/issues/121 + fromVersion: "1.3.0", + toVersion: "1.4.0", objectsToDeploy: []client.Object{ &operatorv1beta1.GatewayConfiguration{ ObjectMeta: metav1.ObjectMeta{ - Name: "gwconf-upgrade-120-123", + Name: "gwconf-upgrade-onebeforelatestminor-latestminor", }, Spec: baseGatewayConfigurationSpec(), }, &gatewayv1.GatewayClass{ ObjectMeta: metav1.ObjectMeta{ - Name: "gwclass-upgrade-120-123", + Name: "gwclass-upgrade-onebeforelatestminor-latestminor", }, Spec: gatewayv1.GatewayClassSpec{ ParametersRef: &gatewayv1.ParametersReference{ Group: gatewayv1.Group(operatorv1beta1.SchemeGroupVersion.Group), Kind: gatewayv1.Kind("GatewayConfiguration"), Namespace: (*gatewayv1.Namespace)(&e.Namespace.Name), - Name: "gwconf-upgrade-120-123", + Name: "gwconf-upgrade-onebeforelatestminor-latestminor", }, ControllerName: gatewayv1.GatewayController(vars.ControllerName()), }, }, &gatewayv1.Gateway{ ObjectMeta: metav1.ObjectMeta{ - GenerateName: "gw-upgrade-120-123-", + GenerateName: "gw-upgrade-onebeforelatestminor-latestminor-", Labels: map[string]string{ - "gw-upgrade-120-123": "true", + "gw-upgrade-onebeforelatestminor-latestminor": "true", }, }, Spec: gatewayv1.GatewaySpec{ - GatewayClassName: gatewayv1.ObjectName("gwclass-upgrade-120-123"), + GatewayClassName: gatewayv1.ObjectName("gwclass-upgrade-onebeforelatestminor-latestminor"), Listeners: []gatewayv1.Listener{{ Name: "http", Protocol: gatewayv1.HTTPProtocolType, @@ -112,7 +110,7 @@ func TestHelmUpgrade(t *testing.T) { { Name: "Gateway is programmed", Func: func(c *assert.CollectT, cl *testutils.K8sClients) { - gatewayAndItsListenersAreProgrammedAssertion("gw-upgrade-120-123=true")(ctx, c, cl.MgrClient) + gatewayAndItsListenersAreProgrammedAssertion("gw-upgrade-onebeforelatestminor-latestminor=true")(ctx, c, cl.MgrClient) }, }, }, @@ -120,122 +118,60 @@ func TestHelmUpgrade(t *testing.T) { { Name: "Gateway is programmed", Func: func(c *assert.CollectT, cl *testutils.K8sClients) { - gatewayAndItsListenersAreProgrammedAssertion("gw-upgrade-120-123=true")(ctx, c, cl.MgrClient) - }, - }, - { - Name: "DataPlane deployment is not patched after operator upgrade", - Func: func(c *assert.CollectT, cl *testutils.K8sClients) { - gatewayDataPlaneDeploymentIsNotPatched("gw-upgrade-120-123=true")(ctx, c, cl.MgrClient) - }, - }, - }, - }, - { - // TODO: use renovate to bump the version in these 2 lines. - // https://github.com/Kong/gateway-operator/issues/121 - name: "upgrade from 1.2.3 to 1.3.0", - fromVersion: "1.2.3", - toVersion: "1.3.0", - objectsToDeploy: []client.Object{ - &operatorv1beta1.GatewayConfiguration{ - ObjectMeta: metav1.ObjectMeta{ - Name: "gwconf-upgrade-123-130", - }, - Spec: baseGatewayConfigurationSpec(), - }, - &gatewayv1.GatewayClass{ - ObjectMeta: metav1.ObjectMeta{ - Name: "gwclass-upgrade-123-130", - }, - Spec: gatewayv1.GatewayClassSpec{ - ParametersRef: &gatewayv1.ParametersReference{ - Group: gatewayv1.Group(operatorv1beta1.SchemeGroupVersion.Group), - Kind: gatewayv1.Kind("GatewayConfiguration"), - Namespace: (*gatewayv1.Namespace)(&e.Namespace.Name), - Name: "gwconf-upgrade-123-130", - }, - ControllerName: gatewayv1.GatewayController(vars.ControllerName()), - }, - }, - &gatewayv1.Gateway{ - ObjectMeta: metav1.ObjectMeta{ - GenerateName: "gw-upgrade-123-130-", - Labels: map[string]string{ - "gw-upgrade-123-130": "true", - }, - }, - Spec: gatewayv1.GatewaySpec{ - GatewayClassName: gatewayv1.ObjectName("gwclass-upgrade-123-130"), - Listeners: []gatewayv1.Listener{{ - Name: "http", - Protocol: gatewayv1.HTTPProtocolType, - Port: gatewayv1.PortNumber(80), - }}, - }, - }, - }, - assertionsAfterInstall: []assertion{ - { - Name: "Gateway is programmed", - Func: func(c *assert.CollectT, cl *testutils.K8sClients) { - gatewayAndItsListenersAreProgrammedAssertion("gw-upgrade-123-130=true")(ctx, c, cl.MgrClient) + gatewayAndItsListenersAreProgrammedAssertion("gw-upgrade-onebeforelatestminor-latestminor=true")(ctx, c, cl.MgrClient) }, }, - }, - assertionsAfterUpgrade: []assertion{ { - Name: "Gateway is programmed", + Name: fmt.Sprintf("DataPlane deployment is patched after operator upgrade (due to change in default Kong image version to %q)", helpers.GetDefaultDataPlaneImage()), Func: func(c *assert.CollectT, cl *testutils.K8sClients) { - gatewayAndItsListenersAreProgrammedAssertion("gw-upgrade-123-130=true")(ctx, c, cl.MgrClient) + gatewayDataPlaneDeploymentIsPatched("gw-upgrade-onebeforelatestminor-latestminor=true")(ctx, c, cl.MgrClient) + gatewayDataPlaneDeploymentHasImageSetTo("gw-upgrade-onebeforelatestminor-latestminor=true", helpers.GetDefaultDataPlaneImage())(ctx, c, cl.MgrClient) }, }, { - Name: fmt.Sprintf("DataPlane deployment is patched after operator upgrade (due to change in default Kong image version to %q)", helpers.GetDefaultDataPlaneImagePreviousMinor()), + Name: "Cluster wide resources owned by the ControlPlane get the proper set of labels", Func: func(c *assert.CollectT, cl *testutils.K8sClients) { - gatewayDataPlaneDeploymentIsPatched("gw-upgrade-123-130=true")(ctx, c, cl.MgrClient) - gatewayDataPlaneDeploymentHasImageSetTo("gw-upgrade-123-130=true", helpers.GetDefaultDataPlaneImagePreviousMinor())(ctx, c, cl.MgrClient) + clusterWideResourcesAreProperlyManaged("gw-upgrade-onebeforelatestminor-latestminor=true")(ctx, c, cl.MgrClient) }, }, - // NOTE: We do not check managed cluster wide resource labels because the fix for migrating - // labels from older versions to new has been merged after 1.3.0 release: - // https://github.com/Kong/gateway-operator/pull/369 }, }, { - name: "upgrade from 1.4.0 to current", + name: "upgrade from latest minor to current", + // TODO: use renovate to bump the version below + // https://github.com/Kong/gateway-operator/issues/121 fromVersion: "1.4.0", upgradeToCurrent: true, objectsToDeploy: []client.Object{ &operatorv1beta1.GatewayConfiguration{ ObjectMeta: metav1.ObjectMeta{ - Name: "gwconf-upgrade-140-current", + Name: "gwconf-upgrade-latestminor-current", }, Spec: baseGatewayConfigurationSpec(), }, &gatewayv1.GatewayClass{ ObjectMeta: metav1.ObjectMeta{ - Name: "gwclass-upgrade-140-current", + Name: "gwclass-upgrade-latestminor-current", }, Spec: gatewayv1.GatewayClassSpec{ ParametersRef: &gatewayv1.ParametersReference{ Group: gatewayv1.Group(operatorv1beta1.SchemeGroupVersion.Group), Kind: gatewayv1.Kind("GatewayConfiguration"), Namespace: (*gatewayv1.Namespace)(&e.Namespace.Name), - Name: "gwconf-upgrade-130-current", + Name: "gwconf-upgrade-latestminor-current", }, ControllerName: gatewayv1.GatewayController(vars.ControllerName()), }, }, &gatewayv1.Gateway{ ObjectMeta: metav1.ObjectMeta{ - GenerateName: "gw-upgrade-140-current-", + GenerateName: "gw-upgrade-latestminor-current-", Labels: map[string]string{ - "gw-upgrade-140-current": "true", + "gw-upgrade-latestminor-current": "true", }, }, Spec: gatewayv1.GatewaySpec{ - GatewayClassName: gatewayv1.ObjectName("gwclass-upgrade-140-current"), + GatewayClassName: gatewayv1.ObjectName("gwclass-upgrade-latestminor-current"), Listeners: []gatewayv1.Listener{{ Name: "http", Protocol: gatewayv1.HTTPProtocolType, @@ -248,7 +184,7 @@ func TestHelmUpgrade(t *testing.T) { { Name: "Gateway is programmed", Func: func(c *assert.CollectT, cl *testutils.K8sClients) { - gatewayAndItsListenersAreProgrammedAssertion("gw-upgrade-140-current=true")(ctx, c, cl.MgrClient) + gatewayAndItsListenersAreProgrammedAssertion("gw-upgrade-latestminor-current=true")(ctx, c, cl.MgrClient) }, }, }, @@ -256,20 +192,19 @@ func TestHelmUpgrade(t *testing.T) { { Name: "Gateway is programmed", Func: func(c *assert.CollectT, cl *testutils.K8sClients) { - gatewayAndItsListenersAreProgrammedAssertion("gw-upgrade-140-current=true")(ctx, c, cl.MgrClient) + gatewayAndItsListenersAreProgrammedAssertion("gw-upgrade-latestminor-current=true")(ctx, c, cl.MgrClient) }, }, { - Name: fmt.Sprintf("DataPlane deployment is patched after operator upgrade (due to change in default Kong image version to %q)", helpers.GetDefaultDataPlaneImage()), + Name: "DataPlane deployment is not patched after operator upgrade", Func: func(c *assert.CollectT, cl *testutils.K8sClients) { - gatewayDataPlaneDeploymentIsPatched("gw-upgrade-140-current=true")(ctx, c, cl.MgrClient) - gatewayDataPlaneDeploymentHasImageSetTo("gw-upgrade-140-current=true", helpers.GetDefaultDataPlaneImage())(ctx, c, cl.MgrClient) + gatewayDataPlaneDeploymentIsNotPatched("gw-upgrade-latestminor-current=true")(ctx, c, cl.MgrClient) }, }, { Name: "Cluster wide resources owned by the ControlPlane get the proper set of labels", Func: func(c *assert.CollectT, cl *testutils.K8sClients) { - clusterWideResourcesAreProperlyManaged("gw-upgrade-140-current=true")(ctx, c, cl.MgrClient) + clusterWideResourcesAreProperlyManaged("gw-upgrade-latestminor-current=true")(ctx, c, cl.MgrClient) }, }, },