@@ -4,7 +4,10 @@ import { Werft } from "./util/werft";
4
4
5
5
const testConfig : string = process . argv . length > 2 ? process . argv [ 2 ] : "STANDARD_K3S_TEST" ;
6
6
// we can provide the version of the gitpod to install (eg: 2022.4.2)
7
- const version : string = process . argv . length > 3 ? process . argv [ 3 ] : "" ;
7
+ // "-" is the default value which will install the latest version
8
+ const version : string = process . argv . length > 3 ? process . argv [ 3 ] : "-" ;
9
+
10
+ const channel : string = process . argv . length > 4 ? process . argv [ 4 ] : "unstable" ;
8
11
9
12
const makefilePath : string = join ( "install/tests" ) ;
10
13
@@ -16,6 +19,78 @@ interface InfraConfig {
16
19
description : string ;
17
20
}
18
21
22
+ interface TestConfig {
23
+ DESCRIPTION : string ;
24
+ PHASES : string [ ] ;
25
+ CLOUD : string ;
26
+ }
27
+
28
+ // Each of the TEST_CONFIGURATIONS define an integration test end-to-end
29
+ // It should be a combination of multiple INFRA_PHASES, order of PHASES slice is important
30
+ const TEST_CONFIGURATIONS : { [ name : string ] : TestConfig } = {
31
+ STANDARD_GKE_TEST : {
32
+ CLOUD : "gcp" ,
33
+ DESCRIPTION : "Deploy Gitpod on GKE, with managed DNS, and run integration tests" ,
34
+ PHASES : [
35
+ "STANDARD_GKE_CLUSTER" ,
36
+ "CERT_MANAGER" ,
37
+ "GCP_MANAGED_DNS" ,
38
+ "GENERATE_KOTS_CONFIG" ,
39
+ "INSTALL_GITPOD" ,
40
+ "CHECK_INSTALLATION" ,
41
+ "RUN_INTEGRATION_TESTS" ,
42
+ "RESULTS" ,
43
+ "DESTROY" ,
44
+ ] ,
45
+ } ,
46
+ STANDARD_GKE_UPGRADE_TEST : {
47
+ CLOUD : "gcp" ,
48
+ DESCRIPTION : `Deploy Gitpod on GKE, and test upgrade from ${ version } to latest version` ,
49
+ PHASES : [
50
+ "STANDARD_GKE_CLUSTER" ,
51
+ "CERT_MANAGER" ,
52
+ "GCP_MANAGED_DNS" ,
53
+ "GENERATE_KOTS_CONFIG" ,
54
+ "INSTALL_GITPOD" ,
55
+ "CHECK_INSTALLATION" ,
56
+ "KOTS_UPGRADE" ,
57
+ "CHECK_INSTALLATION" ,
58
+ "DESTROY" ,
59
+ ] ,
60
+ } ,
61
+ STANDARD_K3S_TEST : {
62
+ CLOUD : "gcp" , // the cloud provider is still GCP
63
+ DESCRIPTION :
64
+ "Deploy Gitpod on a K3s cluster, created on a GCP instance," +
65
+ " with managed DNS and run integrations tests" ,
66
+ PHASES : [
67
+ "STANDARD_K3S_CLUSTER_ON_GCP" ,
68
+ "CERT_MANAGER" ,
69
+ "GENERATE_KOTS_CONFIG" ,
70
+ "INSTALL_GITPOD" ,
71
+ "CHECK_INSTALLATION" ,
72
+ "RUN_INTEGRATION_TESTS" ,
73
+ "RESULTS" ,
74
+ "DESTROY" ,
75
+ ] ,
76
+ } ,
77
+ STANDARD_K3S_PREVIEW : {
78
+ CLOUD : "gcp" ,
79
+ DESCRIPTION : "Create a SH Gitpod preview environment on a K3s cluster, created on a GCP instance" ,
80
+ PHASES : [
81
+ "STANDARD_K3S_CLUSTER_ON_GCP" ,
82
+ "CERT_MANAGER" ,
83
+ "GENERATE_KOTS_CONFIG" ,
84
+ "INSTALL_GITPOD" ,
85
+ "CHECK_INSTALLATION" ,
86
+ "RESULTS" ,
87
+ ] ,
88
+ } ,
89
+ } ;
90
+
91
+ const config : TestConfig = TEST_CONFIGURATIONS [ testConfig ] ;
92
+ const cloud : string = config . CLOUD ;
93
+
19
94
// `INFRA_PHASES` describe the phases that can be mixed
20
95
// and matched to form a test configuration
21
96
// Each phase should contain a `makeTarget` which
@@ -41,14 +116,22 @@ const INFRA_PHASES: { [name: string]: InfraConfig } = {
41
116
makeTarget : "managed-dns" ,
42
117
description : "Sets up external-dns & cloudDNS config" ,
43
118
} ,
119
+ GENERATE_KOTS_CONFIG : {
120
+ phase : "generate-kots-config" ,
121
+ makeTarget : `generate-kots-config storage=${ randomize ( "storage" , cloud ) } registry=${ randomize (
122
+ "registry" ,
123
+ cloud ,
124
+ ) } db=${ randomize ( "db" , cloud ) } `,
125
+ description : `Generate KOTS Config file` ,
126
+ } ,
44
127
INSTALL_GITPOD_IGNORE_PREFLIGHTS : {
45
128
phase : "install-gitpod-without-preflights" ,
46
- makeTarget : `kots-install channel=unstable version=${ version } preflights=false` , // this is a bit of a hack, for now we pass params like this
129
+ makeTarget : `kots-install channel=${ channel } version=${ version } preflights=false` , // this is a bit of a hack, for now we pass params like this
47
130
description : "Install gitpod using kots community edition without preflights" ,
48
131
} ,
49
132
INSTALL_GITPOD : {
50
133
phase : "install-gitpod" ,
51
- makeTarget : `kots-install channel=unstable version=${ version } preflights=true` ,
134
+ makeTarget : `kots-install channel=${ channel } version=${ version } preflights=true` ,
52
135
description : "Install gitpod using kots community edition" ,
53
136
} ,
54
137
CHECK_INSTALLATION : {
@@ -57,6 +140,11 @@ const INFRA_PHASES: { [name: string]: InfraConfig } = {
57
140
makeTarget : "check-gitpod-installation" ,
58
141
description : "Check gitpod installation" ,
59
142
} ,
143
+ KOTS_UPGRADE : {
144
+ phase : "kots-upgrade" ,
145
+ makeTarget : "kots-upgrade" ,
146
+ description : "Upgrade Gitpod installation to latest version using KOTS CLI" ,
147
+ } ,
60
148
RUN_INTEGRATION_TESTS : {
61
149
phase : "run-integration-tests" ,
62
150
makeTarget : "run-tests" ,
@@ -74,56 +162,6 @@ const INFRA_PHASES: { [name: string]: InfraConfig } = {
74
162
} ,
75
163
} ;
76
164
77
- interface TestConfig {
78
- DESCRIPTION : string ;
79
- PHASES : string [ ] ;
80
- }
81
-
82
- // Each of the TEST_CONFIGURATIONS define an integration test end-to-end
83
- // It should be a combination of multiple INFRA_PHASES, order of PHASES slice is important
84
- const TEST_CONFIGURATIONS : { [ name : string ] : TestConfig } = {
85
- STANDARD_GKE_TEST : {
86
- DESCRIPTION : "Deploy Gitpod on GKE, with managed DNS, and run integration tests" ,
87
- PHASES : [
88
- "STANDARD_GKE_CLUSTER" ,
89
- "CERT_MANAGER" ,
90
- "GCP_MANAGED_DNS" ,
91
- "INSTALL_GITPOD" ,
92
- "CHECK_INSTALLATION" ,
93
- "RUN_INTEGRATION_TESTS" ,
94
- "RESULTS" ,
95
- "DESTROY" ,
96
- ] ,
97
- } ,
98
- STANDARD_K3S_TEST : {
99
- DESCRIPTION :
100
- "Deploy Gitpod on a K3s cluster, created on a GCP instance," +
101
- " with managed DNS and run integrations tests" ,
102
- PHASES : [
103
- "STANDARD_K3S_CLUSTER_ON_GCP" ,
104
- "CERT_MANAGER" ,
105
- "INSTALL_GITPOD_IGNORE_PREFLIGHTS" ,
106
- "CHECK_INSTALLATION" ,
107
- "RUN_INTEGRATION_TESTS" ,
108
- "RESULTS" ,
109
- "DESTROY" ,
110
- ] ,
111
- } ,
112
- STANDARD_K3S_PREVIEW : {
113
- DESCRIPTION : "Create a SH Gitpod preview environment on a K3s cluster, created on a GCP instance" ,
114
- PHASES : [
115
- "STANDARD_K3S_CLUSTER_ON_GCP" ,
116
- "GCP_MANAGED_DNS" ,
117
- "INSTALL_GITPOD_IGNORE_PREFLIGHTS" ,
118
- "CHECK_INSTALLATION" ,
119
- "RESULTS" ,
120
- ] ,
121
- } ,
122
- } ;
123
-
124
- // TODO better way to clean up
125
- const config : TestConfig = TEST_CONFIGURATIONS [ testConfig ] ;
126
-
127
165
if ( config === undefined ) {
128
166
console . log ( `Unknown configuration specified: "${ testConfig } ", Exiting...` ) ;
129
167
process . exit ( 1 ) ;
@@ -135,12 +173,6 @@ installerTests(TEST_CONFIGURATIONS[testConfig]).catch((err) => {
135
173
process . exit ( 1 ) ;
136
174
} ) ;
137
175
138
- function getKubeconfig ( ) {
139
- const ret = exec ( `make -C ${ makefilePath } get-kubeconfig` ) ;
140
- const filename = ret . stdout . toString ( ) . split ( "\n" ) . slice ( 1 , - 1 ) ;
141
- exec ( `echo ${ filename } ` ) ;
142
- }
143
-
144
176
export async function installerTests ( config : TestConfig ) {
145
177
console . log ( config . DESCRIPTION ) ;
146
178
for ( let phase of config . PHASES ) {
@@ -155,9 +187,13 @@ export async function installerTests(config: TestConfig) {
155
187
}
156
188
157
189
function callMakeTargets ( phase : string , description : string , makeTarget : string ) {
158
- werft . phase ( phase , description ) ;
190
+ werft . phase ( phase , `${ description } ` ) ;
191
+ werft . log ( phase , `calling ${ makeTarget } ` ) ;
159
192
160
- const response = exec ( `make -C ${ makefilePath } ${ makeTarget } ` , { slice : "call-make-target" , dontCheckRc : true } ) ;
193
+ const response = exec ( `make -C ${ makefilePath } ${ makeTarget } ` , {
194
+ slice : "call-make-target" ,
195
+ dontCheckRc : true ,
196
+ } ) ;
161
197
162
198
if ( response . code ) {
163
199
console . error ( `Error: ${ response . stderr } ` ) ;
@@ -170,6 +206,13 @@ function callMakeTargets(phase: string, description: string, makeTarget: string)
170
206
return response . code ;
171
207
}
172
208
209
+ function randomize ( resource : string , platform : string ) : string {
210
+ // in the follow-up PR we will add `${platform}-${resource}` as an option here to
211
+ // test against resource dependencies(storage, db, registry) for each cloud platform
212
+ const options = [ "incluster" ] ;
213
+ return options [ Math . floor ( Math . random ( ) * options . length ) ] ;
214
+ }
215
+
173
216
function cleanup ( ) {
174
217
const phase = "destroy-infrastructure" ;
175
218
werft . phase ( phase , "Destroying all the created resources" ) ;
0 commit comments