@@ -18,20 +18,53 @@ 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" ] = "snappy"
37
+ return m
38
+ },
39
+ },
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" ] = "snappy"
47
+ return m
48
+ },
49
+ },
50
+ "quay.io/cortexproject/cortex:v1.14.0" : {
51
+ flagsForOldImage : func (m map [string ]string ) map [string ]string {
52
+ return m
53
+ },
54
+ flagsForNewImage : func (m map [string ]string ) map [string ]string {
55
+ m ["-ingester.client.grpc-compression" ] = "snappy"
56
+ return m
57
+ },
28
58
},
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
59
+ "quay.io/cortexproject/cortex:v1.14.1" : {
60
+ flagsForOldImage : func (m map [string ]string ) map [string ]string {
61
+ return m
62
+ },
63
+ flagsForNewImage : func (m map [string ]string ) map [string ]string {
64
+ m ["-ingester.client.grpc-compression" ] = "snappy"
65
+ return m
66
+ },
32
67
},
33
- "quay.io/cortexproject/cortex:v1.14.0" : nil ,
34
- "quay.io/cortexproject/cortex:v1.14.1" : nil ,
35
68
"quay.io/cortexproject/cortex:v1.15.0" : nil ,
36
69
"quay.io/cortexproject/cortex:v1.15.1" : nil ,
37
70
"quay.io/cortexproject/cortex:v1.15.2" : nil ,
@@ -44,27 +77,41 @@ var (
44
77
)
45
78
46
79
func TestBackwardCompatibilityWithBlocksStorage (t * testing.T ) {
47
- for previousImage , flagsFn := range previousVersionImages {
80
+ for previousImage , imagesFlags := range previousVersionImages {
48
81
t .Run (fmt .Sprintf ("Backward compatibility upgrading from %s" , previousImage ), func (t * testing.T ) {
49
82
flags := blocksStorageFlagsWithFlushOnShutdown ()
50
- if flagsFn != nil {
51
- flags = flagsFn (flags )
83
+ var flagsForNewImage func (map [string ]string ) map [string ]string
84
+ if imagesFlags != nil {
85
+ if imagesFlags .flagsForOldImage != nil {
86
+ flags = imagesFlags .flagsForOldImage (flags )
87
+ }
88
+
89
+ if imagesFlags .flagsForNewImage != nil {
90
+ flagsForNewImage = imagesFlags .flagsForNewImage
91
+ }
52
92
}
53
93
54
- runBackwardCompatibilityTestWithBlocksStorage (t , previousImage , flags )
94
+ runBackwardCompatibilityTestWithBlocksStorage (t , previousImage , flags , flagsForNewImage )
55
95
})
56
96
}
57
97
}
58
98
59
99
func TestNewDistributorsCanPushToOldIngestersWithReplication (t * testing.T ) {
60
- for previousImage , flagsFn := range previousVersionImages {
100
+ for previousImage , imagesFlags := range previousVersionImages {
61
101
t .Run (fmt .Sprintf ("Backward compatibility upgrading from %s" , previousImage ), func (t * testing.T ) {
62
102
flags := blocksStorageFlagsWithFlushOnShutdown ()
63
- if flagsFn != nil {
64
- flags = flagsFn (flags )
103
+ var flagsForNewImage func (map [string ]string ) map [string ]string
104
+ if imagesFlags != nil {
105
+ if imagesFlags .flagsForOldImage != nil {
106
+ flags = imagesFlags .flagsForOldImage (flags )
107
+ }
108
+
109
+ if imagesFlags .flagsForNewImage != nil {
110
+ flagsForNewImage = imagesFlags .flagsForNewImage
111
+ }
65
112
}
66
113
67
- runNewDistributorsCanPushToOldIngestersWithReplication (t , previousImage , flags )
114
+ runNewDistributorsCanPushToOldIngestersWithReplication (t , previousImage , flags , flagsForNewImage )
68
115
})
69
116
}
70
117
}
@@ -75,7 +122,7 @@ func blocksStorageFlagsWithFlushOnShutdown() map[string]string {
75
122
})
76
123
}
77
124
78
- func runBackwardCompatibilityTestWithBlocksStorage (t * testing.T , previousImage string , flagsForOldImage map [string ]string ) {
125
+ func runBackwardCompatibilityTestWithBlocksStorage (t * testing.T , previousImage string , flagsForOldImage map [string ]string , flagsForNewImageFn func ( map [ string ] string ) map [ string ] string ) {
79
126
s , err := e2e .NewScenario (networkName )
80
127
require .NoError (t , err )
81
128
defer s .Close ()
@@ -87,6 +134,10 @@ func runBackwardCompatibilityTestWithBlocksStorage(t *testing.T, previousImage s
87
134
88
135
flagsForNewImage := blocksStorageFlagsWithFlushOnShutdown ()
89
136
137
+ if flagsForNewImageFn != nil {
138
+ flagsForNewImage = flagsForNewImageFn (flagsForNewImage )
139
+ }
140
+
90
141
// Start other Cortex components (ingester running on previous version).
91
142
ingester1 := e2ecortex .NewIngester ("ingester-1" , e2ecortex .RingStoreConsul , consul .NetworkHTTPEndpoint (), flagsForOldImage , previousImage )
92
143
distributor := e2ecortex .NewDistributor ("distributor" , "consul" , consul .NetworkHTTPEndpoint (), flagsForNewImage , "" )
@@ -127,7 +178,7 @@ func runBackwardCompatibilityTestWithBlocksStorage(t *testing.T, previousImage s
127
178
}
128
179
129
180
// Check for issues like https://github.com/cortexproject/cortex/issues/2356
130
- func runNewDistributorsCanPushToOldIngestersWithReplication (t * testing.T , previousImage string , flagsForPreviousImage map [string ]string ) {
181
+ func runNewDistributorsCanPushToOldIngestersWithReplication (t * testing.T , previousImage string , flagsForPreviousImage map [string ]string , flagsForNewImageFn func ( map [ string ] string ) map [ string ] string ) {
131
182
s , err := e2e .NewScenario (networkName )
132
183
require .NoError (t , err )
133
184
defer s .Close ()
@@ -141,6 +192,10 @@ func runNewDistributorsCanPushToOldIngestersWithReplication(t *testing.T, previo
141
192
"-distributor.replication-factor" : "3" ,
142
193
})
143
194
195
+ if flagsForNewImageFn != nil {
196
+ flagsForNewImage = flagsForNewImageFn (flagsForNewImage )
197
+ }
198
+
144
199
// Start other Cortex components (ingester running on previous version).
145
200
ingester1 := e2ecortex .NewIngester ("ingester-1" , e2ecortex .RingStoreConsul , consul .NetworkHTTPEndpoint (), flagsForPreviousImage , previousImage )
146
201
ingester2 := e2ecortex .NewIngester ("ingester-2" , e2ecortex .RingStoreConsul , consul .NetworkHTTPEndpoint (), flagsForPreviousImage , previousImage )
0 commit comments