Skip to content

Commit f3ddce8

Browse files
authored
fix random order for pod environment tests (zalando#1085)
1 parent 47b11f7 commit f3ddce8

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

pkg/cluster/k8sres.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ func deduplicateEnvVars(input []v1.EnvVar, containerName string, logger *logrus.
780780
} else if names[va.Name] == 1 {
781781
names[va.Name]++
782782

783-
// Some variables (those to configure the WAL_ and LOG_ shipping) may be overriden, only log as info
783+
// Some variables (those to configure the WAL_ and LOG_ shipping) may be overwritten, only log as info
784784
if strings.HasPrefix(va.Name, "WAL_") || strings.HasPrefix(va.Name, "LOG_") {
785785
logger.Infof("global variable %q has been overwritten by configmap/secret for container %q",
786786
va.Name, containerName)

pkg/cluster/k8sres_test.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"errors"
66
"fmt"
77
"reflect"
8+
"sort"
89

910
"testing"
1011

@@ -749,7 +750,8 @@ func (c *mockConfigMap) Get(ctx context.Context, name string, options metav1.Get
749750
configmap := &v1.ConfigMap{}
750751
configmap.Name = testPodEnvironmentConfigMapName
751752
configmap.Data = map[string]string{
752-
"foo": "bar",
753+
"foo1": "bar1",
754+
"foo2": "bar2",
753755
}
754756
return configmap, nil
755757
}
@@ -816,15 +818,20 @@ func TestPodEnvironmentConfigMapVariables(t *testing.T) {
816818
},
817819
envVars: []v1.EnvVar{
818820
{
819-
Name: "foo",
820-
Value: "bar",
821+
Name: "foo1",
822+
Value: "bar1",
823+
},
824+
{
825+
Name: "foo2",
826+
Value: "bar2",
821827
},
822828
},
823829
},
824830
}
825831
for _, tt := range tests {
826832
c := newMockCluster(tt.opConfig)
827833
vars, err := c.getPodEnvironmentConfigMapVariables()
834+
sort.Slice(vars, func(i, j int) bool { return vars[i].Name < vars[j].Name })
828835
if !reflect.DeepEqual(vars, tt.envVars) {
829836
t.Errorf("%s %s: expected `%v` but got `%v`",
830837
testName, tt.subTest, tt.envVars, vars)
@@ -902,6 +909,7 @@ func TestPodEnvironmentSecretVariables(t *testing.T) {
902909
for _, tt := range tests {
903910
c := newMockCluster(tt.opConfig)
904911
vars, err := c.getPodEnvironmentSecretVariables()
912+
sort.Slice(vars, func(i, j int) bool { return vars[i].Name < vars[j].Name })
905913
if !reflect.DeepEqual(vars, tt.envVars) {
906914
t.Errorf("%s %s: expected `%v` but got `%v`",
907915
testName, tt.subTest, tt.envVars, vars)

0 commit comments

Comments
 (0)