Skip to content

Commit

Permalink
tests: bump version in e2e upgrade tests (#838)
Browse files Browse the repository at this point in the history
* tests: bump version in e2e upgrade tests

* generalize test cases names
  • Loading branch information
czeslavo authored Nov 4, 2024
1 parent 459d43e commit 4e75008
Showing 1 changed file with 33 additions and 98 deletions.
131 changes: 33 additions & 98 deletions test/e2e/test_helm_install_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -112,130 +110,68 @@ 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)
},
},
},
assertionsAfterUpgrade: []assertion{
{
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.3.0 to current",
fromVersion: "1.3.0",
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-130-current",
Name: "gwconf-upgrade-latestminor-current",
},
Spec: baseGatewayConfigurationSpec(),
},
&gatewayv1.GatewayClass{
ObjectMeta: metav1.ObjectMeta{
Name: "gwclass-upgrade-130-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-130-current-",
GenerateName: "gw-upgrade-latestminor-current-",
Labels: map[string]string{
"gw-upgrade-130-current": "true",
"gw-upgrade-latestminor-current": "true",
},
},
Spec: gatewayv1.GatewaySpec{
GatewayClassName: gatewayv1.ObjectName("gwclass-upgrade-130-current"),
GatewayClassName: gatewayv1.ObjectName("gwclass-upgrade-latestminor-current"),
Listeners: []gatewayv1.Listener{{
Name: "http",
Protocol: gatewayv1.HTTPProtocolType,
Expand All @@ -248,28 +184,27 @@ 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-latestminor-current=true")(ctx, c, cl.MgrClient)
},
},
},
assertionsAfterUpgrade: []assertion{
{
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-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-130-current=true")(ctx, c, cl.MgrClient)
gatewayDataPlaneDeploymentHasImageSetTo("gw-upgrade-130-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-130-current=true")(ctx, c, cl.MgrClient)
clusterWideResourcesAreProperlyManaged("gw-upgrade-latestminor-current=true")(ctx, c, cl.MgrClient)
},
},
},
Expand Down

0 comments on commit 4e75008

Please sign in to comment.