@@ -18,17 +18,34 @@ import (
1818 "github.com/cortexproject/cortex/integration/e2ecortex"
1919)
2020
21+ type versionsImagesFlags struct {
22+ flagsForOldImage func (map [string ]string ) map [string ]string
23+ flagsForNewImage func (map [string ]string ) map [string ]string
24+ }
25+
2126var (
2227 // If you change the image tag, remember to update it in the preloading done
2328 // 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+ },
2839 },
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+ },
3249 },
3350 "quay.io/cortexproject/cortex:v1.14.0" : nil ,
3451 "quay.io/cortexproject/cortex:v1.14.1" : nil ,
@@ -44,11 +61,11 @@ var (
4461)
4562
4663func TestBackwardCompatibilityWithBlocksStorage (t * testing.T ) {
47- for previousImage , flagsFn := range previousVersionImages {
64+ for previousImage , imagesFlags := range previousVersionImages {
4865 t .Run (fmt .Sprintf ("Backward compatibility upgrading from %s" , previousImage ), func (t * testing.T ) {
4966 flags := blocksStorageFlagsWithFlushOnShutdown ()
50- if flagsFn != nil {
51- flags = flagsFn (flags )
67+ if imagesFlags != nil && imagesFlags . flagsForOldImage != nil {
68+ flags = imagesFlags . flagsForOldImage (flags )
5269 }
5370
5471 runBackwardCompatibilityTestWithBlocksStorage (t , previousImage , flags )
@@ -57,14 +74,21 @@ func TestBackwardCompatibilityWithBlocksStorage(t *testing.T) {
5774}
5875
5976func TestNewDistributorsCanPushToOldIngestersWithReplication (t * testing.T ) {
60- for previousImage , flagsFn := range previousVersionImages {
77+ for previousImage , imagesFlags := range previousVersionImages {
6178 t .Run (fmt .Sprintf ("Backward compatibility upgrading from %s" , previousImage ), func (t * testing.T ) {
6279 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+ }
6589 }
6690
67- runNewDistributorsCanPushToOldIngestersWithReplication (t , previousImage , flags )
91+ runNewDistributorsCanPushToOldIngestersWithReplication (t , previousImage , flags , flagsForNewImage )
6892 })
6993 }
7094}
@@ -127,7 +151,7 @@ func runBackwardCompatibilityTestWithBlocksStorage(t *testing.T, previousImage s
127151}
128152
129153// 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 ) {
131155 s , err := e2e .NewScenario (networkName )
132156 require .NoError (t , err )
133157 defer s .Close ()
@@ -141,6 +165,10 @@ func runNewDistributorsCanPushToOldIngestersWithReplication(t *testing.T, previo
141165 "-distributor.replication-factor" : "3" ,
142166 })
143167
168+ if flagsForNewImageFn != nil {
169+ flagsForNewImage = flagsForNewImageFn (flagsForNewImage )
170+ }
171+
144172 // Start other Cortex components (ingester running on previous version).
145173 ingester1 := e2ecortex .NewIngester ("ingester-1" , e2ecortex .RingStoreConsul , consul .NetworkHTTPEndpoint (), flagsForPreviousImage , previousImage )
146174 ingester2 := e2ecortex .NewIngester ("ingester-2" , e2ecortex .RingStoreConsul , consul .NetworkHTTPEndpoint (), flagsForPreviousImage , previousImage )
0 commit comments