@@ -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+ },
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+ },
2858 },
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+ },
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,27 +77,41 @@ 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+ 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+ }
5292 }
5393
54- runBackwardCompatibilityTestWithBlocksStorage (t , previousImage , flags )
94+ runBackwardCompatibilityTestWithBlocksStorage (t , previousImage , flags , flagsForNewImage )
5595 })
5696 }
5797}
5898
5999func TestNewDistributorsCanPushToOldIngestersWithReplication (t * testing.T ) {
60- for previousImage , flagsFn := range previousVersionImages {
100+ for previousImage , imagesFlags := range previousVersionImages {
61101 t .Run (fmt .Sprintf ("Backward compatibility upgrading from %s" , previousImage ), func (t * testing.T ) {
62102 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+ }
65112 }
66113
67- runNewDistributorsCanPushToOldIngestersWithReplication (t , previousImage , flags )
114+ runNewDistributorsCanPushToOldIngestersWithReplication (t , previousImage , flags , flagsForNewImage )
68115 })
69116 }
70117}
@@ -75,7 +122,7 @@ func blocksStorageFlagsWithFlushOnShutdown() map[string]string {
75122 })
76123}
77124
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 ) {
79126 s , err := e2e .NewScenario (networkName )
80127 require .NoError (t , err )
81128 defer s .Close ()
@@ -87,6 +134,10 @@ func runBackwardCompatibilityTestWithBlocksStorage(t *testing.T, previousImage s
87134
88135 flagsForNewImage := blocksStorageFlagsWithFlushOnShutdown ()
89136
137+ if flagsForNewImageFn != nil {
138+ flagsForNewImage = flagsForNewImageFn (flagsForNewImage )
139+ }
140+
90141 // Start other Cortex components (ingester running on previous version).
91142 ingester1 := e2ecortex .NewIngester ("ingester-1" , e2ecortex .RingStoreConsul , consul .NetworkHTTPEndpoint (), flagsForOldImage , previousImage )
92143 distributor := e2ecortex .NewDistributor ("distributor" , "consul" , consul .NetworkHTTPEndpoint (), flagsForNewImage , "" )
@@ -127,7 +178,7 @@ func runBackwardCompatibilityTestWithBlocksStorage(t *testing.T, previousImage s
127178}
128179
129180// 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 ) {
131182 s , err := e2e .NewScenario (networkName )
132183 require .NoError (t , err )
133184 defer s .Close ()
@@ -141,6 +192,10 @@ func runNewDistributorsCanPushToOldIngestersWithReplication(t *testing.T, previo
141192 "-distributor.replication-factor" : "3" ,
142193 })
143194
195+ if flagsForNewImageFn != nil {
196+ flagsForNewImage = flagsForNewImageFn (flagsForNewImage )
197+ }
198+
144199 // Start other Cortex components (ingester running on previous version).
145200 ingester1 := e2ecortex .NewIngester ("ingester-1" , e2ecortex .RingStoreConsul , consul .NetworkHTTPEndpoint (), flagsForPreviousImage , previousImage )
146201 ingester2 := e2ecortex .NewIngester ("ingester-2" , e2ecortex .RingStoreConsul , consul .NetworkHTTPEndpoint (), flagsForPreviousImage , previousImage )
0 commit comments