Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add e2e tests for ConfigMap feature #558

Merged
merged 5 commits into from
Jan 12, 2024
Merged

Add e2e tests for ConfigMap feature #558

merged 5 commits into from
Jan 12, 2024

Conversation

katyanna
Copy link
Member

@linki linki marked this pull request as ready for review December 18, 2023 16:27
@linki
Copy link
Member

linki commented Dec 18, 2023

👍

@mikkeloscar
Copy link
Contributor

mikkeloscar commented Dec 19, 2023

@linki I was thinking it could make sense to have a test showing the behavior when it fails e.g. the configmap is not there.

Basically traffic switching should not succeed if configmap is missing.

You could be inspired by this test:

func TestBrokenStacks(t *testing.T) {
t.Parallel()
stacksetName := "stackset-broken-stacks"
factory := NewTestStacksetSpecFactory(stacksetName).Ingress().StackGC(1, 30)
firstVersion := "v1"
firstStack := fmt.Sprintf("%s-%s", stacksetName, firstVersion)
spec := factory.Create(firstVersion)
err := createStackSet(stacksetName, 0, spec)
require.NoError(t, err)
_, err = waitForStack(t, stacksetName, firstVersion)
require.NoError(t, err)
unhealthyVersion := "v2"
unhealthyStack := fmt.Sprintf("%s-%s", stacksetName, unhealthyVersion)
spec = factory.Create(unhealthyVersion)
spec.StackTemplate.Spec.Service.Ports = []corev1.ServicePort{
{
Protocol: corev1.ProtocolTCP,
TargetPort: intstr.FromString("foobar"),
},
}
err = updateStackset(stacksetName, spec)
require.NoError(t, err)
_, err = waitForStack(t, stacksetName, unhealthyVersion)
require.NoError(t, err)
_, err = waitForIngress(t, stacksetName)
require.NoError(t, err)
initialWeights := map[string]float64{firstStack: 100}
err = trafficWeightsUpdatedStackset(t, stacksetName, weightKindActual, initialWeights, nil).await()
require.NoError(t, err)
// Switch traffic to the second stack, this should fail
desiredWeights := map[string]float64{unhealthyStack: 100}
err = setDesiredTrafficWeightsStackset(stacksetName, desiredWeights)
require.NoError(t, err)
err = trafficWeightsUpdatedStackset(t, stacksetName, weightKindActual, desiredWeights, nil).await()
require.Error(t, err)

},
},
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This stuff makes sure that if you configure your Stackset to have a versioned ConfigMap (via the factory and calling ConfigMap()) that it will end up with a working configuration (name pattern matches, external ConfigMap exists).

@linki
Copy link
Member

linki commented Jan 12, 2024

👍

1 similar comment
@katyanna
Copy link
Member Author

👍

@katyanna katyanna merged commit 23dae59 into master Jan 12, 2024
7 checks passed
@katyanna katyanna deleted the config-rsc-e2e branch January 12, 2024 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants