11package e2e
22
33import (
4- "encoding/json"
54 "fmt"
65 "net/http"
76 "os"
@@ -12,15 +11,6 @@ import (
1211 "github.com/replicatedhq/embedded-cluster/e2e/cluster"
1312)
1413
15- type clusterStatusResponse struct {
16- App string `json:"app"`
17- Cluster string `json:"cluster"`
18- }
19-
20- type nodeJoinResponse struct {
21- Command string `json:"command"`
22- }
23-
2414func TestSingleNodeInstallation (t * testing.T ) {
2515 t .Parallel ()
2616 tc := cluster .NewTestCluster (& cluster.Input {
@@ -37,7 +27,7 @@ func TestSingleNodeInstallation(t *testing.T) {
3727 t .Fatalf ("fail to install embedded-cluster on node %s: %v" , tc .Nodes [0 ], err )
3828 }
3929
40- runPuppeteerAppStatusCheck (t , 0 , tc )
30+ installTestimAndDeploy (t , 0 , tc )
4131
4232 t .Logf ("%s: checking installation state after upgrade" , time .Now ().Format (time .RFC3339 ))
4333 line = []string {"check-postupgrade-state.sh" , os .Getenv ("SHORT_SHA" )}
@@ -217,39 +207,35 @@ func TestMultiNodeInstallation(t *testing.T) {
217207 t .Fatalf ("fail to install embedded-cluster on node %s: %v" , tc .Nodes [0 ], err )
218208 }
219209
220- runPuppeteerAppStatusCheck (t , 0 , tc )
210+ installTestimAndDeploy (t , 0 , tc )
221211
222212 // generate all node join commands (2 for controllers and 1 for worker).
223213 t .Logf ("%s: generating two new controller token commands" , time .Now ().Format (time .RFC3339 ))
224214 controllerCommands := []string {}
225215 for i := 0 ; i < 2 ; i ++ {
226- line := []string {"puppeteer .sh" , "generate-controller-join-token.js" , "10.0.0.2 " }
216+ line := []string {"testim .sh" , os . Getenv ( "TESTIM_ACCESS_TOKEN" ), os . Getenv ( "TESTIM_BRANCH" ) , "get-join-controller-command " }
227217 stdout , stderr , err := RunCommandOnNode (t , tc , 0 , line )
228218 if err != nil {
229- t .Fatalf ("fail to generate controller join token: %s" , stdout )
219+ t .Fatalf ("fail to generate controller join token:\n stdout: %s\n stderr: %s " , stdout , stderr )
230220 }
231- var r nodeJoinResponse
232- if err := json .Unmarshal ([]byte (stdout ), & r ); err != nil {
233- t .Logf ("stdout: %s\n stderr: %s" , stdout , stderr )
234- t .Fatalf ("fail to parse script response: %v" , err )
221+ command , err := findJoinCommandInOutput (stdout )
222+ if err != nil {
223+ t .Fatalf ("fail to find the join command in the output: %v" , err )
235224 }
236- // trim down the "./" and the "sudo" command as those are not needed. we run as
237- // root and the embedded-cluster binary is on the PATH.
238- command := strings .TrimPrefix (r .Command , "sudo ./" )
239225 controllerCommands = append (controllerCommands , command )
240226 t .Log ("controller join token command:" , command )
241227 }
242228 t .Logf ("%s: generating a new worker token command" , time .Now ().Format (time .RFC3339 ))
243- line := []string {"puppeteer .sh" , "generate-worker-join-token.js" , "10.0.0.2 " }
229+ line := []string {"testim .sh" , os . Getenv ( "TESTIM_ACCESS_TOKEN" ), os . Getenv ( "TESTIM_BRANCH" ) , "get-join-worker-command " }
244230 stdout , stderr , err := RunCommandOnNode (t , tc , 0 , line )
245231 if err != nil {
246- t .Fatalf ("fail to generate controller join token: %s" , stdout )
232+ t .Fatalf ("fail to generate controller join token:\n stdout: %s\n stderr: %s " , stdout , stderr )
247233 }
248- var jr nodeJoinResponse
249- if err := json .Unmarshal ([]byte (stdout ), & jr ); err != nil {
250- t .Logf ("stdout: %s\n stderr: %s" , stdout , stderr )
251- t .Fatalf ("fail to parse script response: %v" , err )
234+ command , err := findJoinCommandInOutput (stdout )
235+ if err != nil {
236+ t .Fatalf ("fail to find the join command in the output: %v" , err )
252237 }
238+ t .Log ("worker join token command:" , command )
253239
254240 // join the nodes.
255241 for i , cmd := range controllerCommands {
@@ -267,8 +253,6 @@ func TestMultiNodeInstallation(t *testing.T) {
267253 t .Logf ("node %d joined, sleeping..." , node )
268254 time .Sleep (30 * time .Second )
269255 }
270- command := strings .TrimPrefix (jr .Command , "sudo ./" )
271- t .Log ("worker join token command:" , command )
272256 t .Logf ("%s: joining node 3 to the cluster as a worker" , time .Now ().Format (time .RFC3339 ))
273257 if _ , _ , err := RunCommandOnNode (t , tc , 3 , strings .Split (command , " " )); err != nil {
274258 t .Fatalf ("fail to join node 3 to the cluster as a worker: %v" , err )
@@ -479,14 +463,15 @@ func TestSingleNodeAirgapInstallationUbuntuJammy(t *testing.T) {
479463 t .Logf ("%s: test complete" , time .Now ().Format (time .RFC3339 ))
480464}
481465
482- func runPuppeteerAppStatusCheck (t * testing.T , node int , tc * cluster.Output ) {
483- t .Logf ("%s: installing puppeteer on node %d" , time .Now ().Format (time .RFC3339 ), node )
484- line := []string {"install-puppeteer .sh" }
466+ func installTestimAndDeploy (t * testing.T , node int , tc * cluster.Output ) {
467+ t .Logf ("%s: installing testim on node %d" , time .Now ().Format (time .RFC3339 ), node )
468+ line := []string {"install-testim .sh" }
485469 if _ , _ , err := RunCommandOnNode (t , tc , 0 , line ); err != nil {
486- t .Fatalf ("fail to install puppeteer on node %s: %v" , tc .Nodes [0 ], err )
470+ t .Fatalf ("fail to install testim on node %s: %v" , tc .Nodes [0 ], err )
487471 }
472+
488473 t .Logf ("%s: accessing kotsadm interface and deploying app" , time .Now ().Format (time .RFC3339 ))
489- line = []string {"puppeteer .sh" , "deploy-kots-application.js" , "10.0.0.2 " }
474+ line = []string {"testim .sh" , os . Getenv ( "TESTIM_ACCESS_TOKEN" ), os . Getenv ( "TESTIM_BRANCH" ) , "deploy-kots-application " }
490475 if _ , _ , err := RunCommandOnNode (t , tc , 0 , line ); err != nil {
491476 t .Fatalf ("fail to access kotsadm interface and state: %v" , err )
492477 }
0 commit comments