Skip to content

Commit

Permalink
wip - ensure e2e tests for configmap versioning
Browse files Browse the repository at this point in the history
Signed-off-by: Katyanna Moura <[email protected]>
  • Loading branch information
katyanna committed Dec 14, 2023
1 parent 4278725 commit 46d5293
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
20 changes: 20 additions & 0 deletions cmd/e2e/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type TestStacksetSpecFactory struct {
ingress bool
routegroup bool
externalIngress bool
configMap bool
limit int32
scaleDownTTL int64
replicas int32
Expand Down Expand Up @@ -134,6 +135,16 @@ func (f *TestStacksetSpecFactory) Create(stackVersion string) zv1.StackSetSpec {
},
}

if f.configMap {
result.StackTemplate.Spec.ConfigurationResources = []zv1.ConfigurationResourcesSpec{
{
ConfigMapRef: corev1.LocalObjectReference{
Name: "foo-v1-test-configmap",
},
},
}
}

if f.autoscaler {
result.StackTemplate.Spec.Autoscaler = &zv1.Autoscaler{
MaxReplicas: f.hpaMaxReplicas,
Expand Down Expand Up @@ -287,6 +298,15 @@ func verifyStack(t *testing.T, stacksetName, currentVersion string, stacksetSpec
require.EqualValues(t, expectedRef, hpa.Spec.ScaleTargetRef)
}

// Verify ConfigMaps
for _, rsc := range stacksetSpec.StackTemplate.Spec.ConfigurationResources {
configMap, err := waitForConfigMap(t, rsc.ConfigMapRef.Name)
require.NoError(t, err)
require.EqualValues(t, stackResourceLabels, configMap.Labels)
require.Contains(t, configMap.Name, stack.Name)
require.NotEmpty(t, configMap.Data)
}

verifyStackIngressSources(
t,
stack,
Expand Down
4 changes: 4 additions & 0 deletions cmd/e2e/test_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ func routegroupInterface() rgv1client.RouteGroupInterface {
return routegroupClient.ZalandoV1().RouteGroups(namespace)
}

func configmapInterface() corev1typed.ConfigMapInterface {
return kubernetesClient.CoreV1().ConfigMaps(namespace)
}

func requiredEnvar(envar string) string {
namespace := os.Getenv(envar)
if namespace == "" {
Expand Down
8 changes: 8 additions & 0 deletions cmd/e2e/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,14 @@ func waitForRouteGroup(t *testing.T, name string) (*rgv1.RouteGroup, error) {
return routegroupInterface().Get(context.Background(), name, metav1.GetOptions{})
}

func waitForConfigMap(t *testing.T, configMapName string) (*corev1.ConfigMap, error) {
err := resourceCreated(t, "configmap", configMapName, configmapInterface()).await()
if err != nil {
return nil, err
}
return configmapInterface().Get(context.Background(), configMapName, metav1.GetOptions{})
}

func waitForUpdatedRouteGroup(t *testing.T, name string, oldTimestamp string) (*rgv1.RouteGroup, error) {
err := newAwaiter(t, fmt.Sprintf("updated RouteGroup %s", name)).withPoll(func() (bool, error) {
rg, err := routegroupInterface().Get(context.Background(), name, metav1.GetOptions{})
Expand Down

0 comments on commit 46d5293

Please sign in to comment.