@@ -18,17 +18,34 @@ import (
18
18
"github.com/cortexproject/cortex/integration/e2ecortex"
19
19
)
20
20
21
+ type versionsImagesFlags struct {
22
+ flagsForOldImage func (map [string ]string ) map [string ]string
23
+ flagsForNewImage func (map [string ]string ) map [string ]string
24
+ }
25
+
21
26
var (
22
27
// If you change the image tag, remember to update it in the preloading done
23
28
// by GitHub Actions too (see .github/workflows/test-build-deploy.yml).
24
- previousVersionImages = map [string ]func (map [string ]string ) map [string ]string {
25
- "quay.io/cortexproject/cortex:v1.13.1" : func (m map [string ]string ) map [string ]string {
26
- m ["-ingester.stream-chunks-when-using-blocks" ] = "true"
27
- return m
29
+ previousVersionImages = map [string ]* versionsImagesFlags {
30
+ "quay.io/cortexproject/cortex:v1.13.1" : {
31
+ flagsForOldImage : func (m map [string ]string ) map [string ]string {
32
+ m ["-ingester.stream-chunks-when-using-blocks" ] = "true"
33
+ return m
34
+ },
35
+ flagsForNewImage : func (m map [string ]string ) map [string ]string {
36
+ m ["-ingester.client.grpc-compression" ] = ""
37
+ return m
38
+ },
28
39
},
29
- "quay.io/cortexproject/cortex:v1.13.2" : func (m map [string ]string ) map [string ]string {
30
- m ["-ingester.stream-chunks-when-using-blocks" ] = "true"
31
- return m
40
+ "quay.io/cortexproject/cortex:v1.13.2" : {
41
+ flagsForOldImage : func (m map [string ]string ) map [string ]string {
42
+ m ["-ingester.stream-chunks-when-using-blocks" ] = "true"
43
+ return m
44
+ },
45
+ flagsForNewImage : func (m map [string ]string ) map [string ]string {
46
+ m ["-ingester.client.grpc-compression" ] = ""
47
+ return m
48
+ },
32
49
},
33
50
"quay.io/cortexproject/cortex:v1.14.0" : nil ,
34
51
"quay.io/cortexproject/cortex:v1.14.1" : nil ,
@@ -44,11 +61,11 @@ var (
44
61
)
45
62
46
63
func TestBackwardCompatibilityWithBlocksStorage (t * testing.T ) {
47
- for previousImage , flagsFn := range previousVersionImages {
64
+ for previousImage , imagesFlags := range previousVersionImages {
48
65
t .Run (fmt .Sprintf ("Backward compatibility upgrading from %s" , previousImage ), func (t * testing.T ) {
49
66
flags := blocksStorageFlagsWithFlushOnShutdown ()
50
- if flagsFn != nil {
51
- flags = flagsFn (flags )
67
+ if imagesFlags != nil && imagesFlags . flagsForOldImage != nil {
68
+ flags = imagesFlags . flagsForOldImage (flags )
52
69
}
53
70
54
71
runBackwardCompatibilityTestWithBlocksStorage (t , previousImage , flags )
@@ -57,14 +74,21 @@ func TestBackwardCompatibilityWithBlocksStorage(t *testing.T) {
57
74
}
58
75
59
76
func TestNewDistributorsCanPushToOldIngestersWithReplication (t * testing.T ) {
60
- for previousImage , flagsFn := range previousVersionImages {
77
+ for previousImage , imagesFlags := range previousVersionImages {
61
78
t .Run (fmt .Sprintf ("Backward compatibility upgrading from %s" , previousImage ), func (t * testing.T ) {
62
79
flags := blocksStorageFlagsWithFlushOnShutdown ()
63
- if flagsFn != nil {
64
- flags = flagsFn (flags )
80
+ var flagsForNewImage func (map [string ]string ) map [string ]string
81
+ if imagesFlags != nil {
82
+ if imagesFlags .flagsForOldImage != nil {
83
+ flags = imagesFlags .flagsForOldImage (flags )
84
+ }
85
+
86
+ if imagesFlags .flagsForNewImage != nil {
87
+ flagsForNewImage = imagesFlags .flagsForNewImage
88
+ }
65
89
}
66
90
67
- runNewDistributorsCanPushToOldIngestersWithReplication (t , previousImage , flags )
91
+ runNewDistributorsCanPushToOldIngestersWithReplication (t , previousImage , flags , flagsForNewImage )
68
92
})
69
93
}
70
94
}
@@ -127,7 +151,7 @@ func runBackwardCompatibilityTestWithBlocksStorage(t *testing.T, previousImage s
127
151
}
128
152
129
153
// Check for issues like https://github.com/cortexproject/cortex/issues/2356
130
- func runNewDistributorsCanPushToOldIngestersWithReplication (t * testing.T , previousImage string , flagsForPreviousImage map [string ]string ) {
154
+ func runNewDistributorsCanPushToOldIngestersWithReplication (t * testing.T , previousImage string , flagsForPreviousImage map [string ]string , flagsForNewImageFn func ( map [ string ] string ) map [ string ] string ) {
131
155
s , err := e2e .NewScenario (networkName )
132
156
require .NoError (t , err )
133
157
defer s .Close ()
@@ -141,6 +165,10 @@ func runNewDistributorsCanPushToOldIngestersWithReplication(t *testing.T, previo
141
165
"-distributor.replication-factor" : "3" ,
142
166
})
143
167
168
+ if flagsForNewImageFn != nil {
169
+ flagsForNewImage = flagsForNewImageFn (flagsForNewImage )
170
+ }
171
+
144
172
// Start other Cortex components (ingester running on previous version).
145
173
ingester1 := e2ecortex .NewIngester ("ingester-1" , e2ecortex .RingStoreConsul , consul .NetworkHTTPEndpoint (), flagsForPreviousImage , previousImage )
146
174
ingester2 := e2ecortex .NewIngester ("ingester-2" , e2ecortex .RingStoreConsul , consul .NetworkHTTPEndpoint (), flagsForPreviousImage , previousImage )
0 commit comments