Skip to content

Commit 6beebb8

Browse files
authored
add reset and reinstall test (#398)
1 parent 16decd8 commit 6beebb8

File tree

4 files changed

+77
-0
lines changed

4 files changed

+77
-0
lines changed

.github/workflows/pull-request.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ jobs:
124124
- TestMultiNodeReset
125125
- TestCommandsRequireSudo
126126
- TestInstallWithoutEmbed
127+
- TestResetAndReinstall
127128
steps:
128129
- name: Checkout
129130
uses: actions/checkout@v4

.github/workflows/release-dev.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ jobs:
105105
- TestCommandsRequireSudo
106106
- TestInstallWithoutEmbed
107107
- TestInstallFromReplicatedApp
108+
- TestResetAndReinstall
108109
steps:
109110
- name: Checkout
110111
uses: actions/checkout@v4

e2e/install_test.go

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,62 @@ func TestInstallFromReplicatedApp(t *testing.T) {
401401
t.Logf("%s: test complete", time.Now().Format(time.RFC3339))
402402
}
403403

404+
func TestResetAndReinstall(t *testing.T) {
405+
t.Parallel()
406+
tc := cluster.NewTestCluster(&cluster.Input{
407+
T: t,
408+
Nodes: 1,
409+
Image: "ubuntu/jammy",
410+
LicensePath: "license.yaml",
411+
EmbeddedClusterPath: "../output/bin/embedded-cluster",
412+
})
413+
defer tc.Destroy()
414+
t.Logf("%s: installing embedded-cluster on node 0", time.Now().Format(time.RFC3339))
415+
line := []string{"single-node-install.sh"}
416+
if stdout, stderr, err := RunCommandOnNode(t, tc, 0, line); err != nil {
417+
t.Log("install stdout:", stdout)
418+
t.Log("install stderr:", stderr)
419+
t.Fatalf("fail to install embedded-cluster on node %s: %v", tc.Nodes[0], err)
420+
}
421+
422+
t.Logf("%s: checking installation state", time.Now().Format(time.RFC3339))
423+
line = []string{"check-installation-state.sh"}
424+
stdout, stderr, err := RunCommandOnNode(t, tc, 0, line)
425+
if err != nil {
426+
t.Log("stdout:", stdout)
427+
t.Log("stderr:", stderr)
428+
t.Fatalf("fail to check installation state: %v", err)
429+
}
430+
431+
t.Logf("%s: resetting the installation", time.Now().Format(time.RFC3339))
432+
line = []string{"reset-installation.sh"}
433+
stdout, stderr, err = RunCommandOnNode(t, tc, 0, line)
434+
if err != nil {
435+
t.Log("stdout:", stdout)
436+
t.Log("stderr:", stderr)
437+
t.Fatalf("fail to reset the installation: %v", err)
438+
}
439+
440+
t.Logf("%s: installing embedded-cluster on node 0 after reset", time.Now().Format(time.RFC3339))
441+
line = []string{"single-node-install.sh"}
442+
if stdout, stderr, err = RunCommandOnNode(t, tc, 0, line); err != nil {
443+
t.Log("install stdout:", stdout)
444+
t.Log("install stderr:", stderr)
445+
t.Fatalf("fail to install embedded-cluster on node %s: %v", tc.Nodes[0], err)
446+
}
447+
448+
t.Logf("%s: checking installation state after reinstall", time.Now().Format(time.RFC3339))
449+
line = []string{"check-installation-state.sh"}
450+
stdout, stderr, err = RunCommandOnNode(t, tc, 0, line)
451+
if err != nil {
452+
t.Log("stdout:", stdout)
453+
t.Log("stderr:", stderr)
454+
t.Fatalf("fail to check installation state: %v", err)
455+
}
456+
457+
t.Logf("%s: test complete", time.Now().Format(time.RFC3339))
458+
}
459+
404460
func runPuppeteerAppStatusCheck(t *testing.T, node int, tc *cluster.Output) {
405461
t.Logf("%s: installing puppeteer on node %d", time.Now().Format(time.RFC3339), node)
406462
line := []string{"install-puppeteer.sh"}

e2e/scripts/reset-installation.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
main() {
5+
if ! embedded-cluster node reset --no-prompt | tee /tmp/log ; then
6+
echo "Failed to reset embedded-cluster"
7+
exit 1
8+
fi
9+
10+
if systemctl status embedded-cluster; then
11+
echo "Unexpectedly got status of embedded-cluster service"
12+
exit 1
13+
fi
14+
}
15+
16+
export EMBEDDED_CLUSTER_METRICS_BASEURL="https://staging.replicated.app"
17+
export KUBECONFIG=/var/lib/k0s/pki/admin.conf
18+
export PATH=$PATH:/var/lib/embedded-cluster/bin
19+
main

0 commit comments

Comments
 (0)