@@ -18,20 +18,53 @@ 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" ] = "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+ },
2849 },
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
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+ },
58+ },
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+ },
3267 },
33- "quay.io/cortexproject/cortex:v1.14.0" : nil ,
34- "quay.io/cortexproject/cortex:v1.14.1" : nil ,
3568 "quay.io/cortexproject/cortex:v1.15.0" : nil ,
3669 "quay.io/cortexproject/cortex:v1.15.1" : nil ,
3770 "quay.io/cortexproject/cortex:v1.15.2" : nil ,
@@ -44,11 +77,11 @@ var (
4477)
4578
4679func TestBackwardCompatibilityWithBlocksStorage (t * testing.T ) {
47- for previousImage , flagsFn := range previousVersionImages {
80+ for previousImage , imagesFlags := range previousVersionImages {
4881 t .Run (fmt .Sprintf ("Backward compatibility upgrading from %s" , previousImage ), func (t * testing.T ) {
4982 flags := blocksStorageFlagsWithFlushOnShutdown ()
50- if flagsFn != nil {
51- flags = flagsFn (flags )
83+ if imagesFlags != nil && imagesFlags . flagsForOldImage != nil {
84+ flags = imagesFlags . flagsForOldImage (flags )
5285 }
5386
5487 runBackwardCompatibilityTestWithBlocksStorage (t , previousImage , flags )
@@ -57,14 +90,21 @@ func TestBackwardCompatibilityWithBlocksStorage(t *testing.T) {
5790}
5891
5992func TestNewDistributorsCanPushToOldIngestersWithReplication (t * testing.T ) {
60- for previousImage , flagsFn := range previousVersionImages {
93+ for previousImage , imagesFlags := range previousVersionImages {
6194 t .Run (fmt .Sprintf ("Backward compatibility upgrading from %s" , previousImage ), func (t * testing.T ) {
6295 flags := blocksStorageFlagsWithFlushOnShutdown ()
63- if flagsFn != nil {
64- flags = flagsFn (flags )
96+ var flagsForNewImage func (map [string ]string ) map [string ]string
97+ if imagesFlags != nil {
98+ if imagesFlags .flagsForOldImage != nil {
99+ flags = imagesFlags .flagsForOldImage (flags )
100+ }
101+
102+ if imagesFlags .flagsForNewImage != nil {
103+ flagsForNewImage = imagesFlags .flagsForNewImage
104+ }
65105 }
66106
67- runNewDistributorsCanPushToOldIngestersWithReplication (t , previousImage , flags )
107+ runNewDistributorsCanPushToOldIngestersWithReplication (t , previousImage , flags , flagsForNewImage )
68108 })
69109 }
70110}
@@ -127,7 +167,7 @@ func runBackwardCompatibilityTestWithBlocksStorage(t *testing.T, previousImage s
127167}
128168
129169// Check for issues like https://github.com/cortexproject/cortex/issues/2356
130- func runNewDistributorsCanPushToOldIngestersWithReplication (t * testing.T , previousImage string , flagsForPreviousImage map [string ]string ) {
170+ func runNewDistributorsCanPushToOldIngestersWithReplication (t * testing.T , previousImage string , flagsForPreviousImage map [string ]string , flagsForNewImageFn func ( map [ string ] string ) map [ string ] string ) {
131171 s , err := e2e .NewScenario (networkName )
132172 require .NoError (t , err )
133173 defer s .Close ()
@@ -141,6 +181,10 @@ func runNewDistributorsCanPushToOldIngestersWithReplication(t *testing.T, previo
141181 "-distributor.replication-factor" : "3" ,
142182 })
143183
184+ if flagsForNewImageFn != nil {
185+ flagsForNewImage = flagsForNewImageFn (flagsForNewImage )
186+ }
187+
144188 // Start other Cortex components (ingester running on previous version).
145189 ingester1 := e2ecortex .NewIngester ("ingester-1" , e2ecortex .RingStoreConsul , consul .NetworkHTTPEndpoint (), flagsForPreviousImage , previousImage )
146190 ingester2 := e2ecortex .NewIngester ("ingester-2" , e2ecortex .RingStoreConsul , consul .NetworkHTTPEndpoint (), flagsForPreviousImage , previousImage )
0 commit comments