Skip to content

Commit 1e2e64f

Browse files
authored
test installation without anything embedded in the binary (#363)
* test installation without anything embedded in the binary * noop * do not test if the install with no customization respects customization
1 parent f0c80a1 commit 1e2e64f

File tree

4 files changed

+115
-0
lines changed

4 files changed

+115
-0
lines changed

.github/workflows/pull-request.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ jobs:
8181
echo "# channel release object" > e2e/kots-release-install/release.yaml
8282
echo "versionLabel: \"${SHORT_SHA}\"" >> e2e/kots-release-install/release.yaml
8383
cat e2e/kots-release-install/release.yaml
84+
cp output/bin/embedded-cluster output/bin/embedded-cluster-original
8485
make embedded-release # this is done after the metadata.json is generated so as to not include additional charts
8586
- name: Cache files for integration test
8687
if: github.actor != 'dependabot[bot]'
@@ -101,6 +102,7 @@ jobs:
101102
name: embedded-release
102103
path: |
103104
output/bin/embedded-cluster
105+
output/bin/embedded-cluster-original
104106
output/bin/embedded-cluster-release-builder
105107
106108
e2e:
@@ -121,6 +123,7 @@ jobs:
121123
- TestMultiNodeInstallation
122124
- TestMultiNodeReset
123125
- TestCommandsRequireSudo
126+
- TestInstallWithoutEmbed
124127
steps:
125128
- name: Checkout
126129
uses: actions/checkout@v4

.github/workflows/release-dev.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ jobs:
6262
echo "# channel release object" > e2e/kots-release-install/release.yaml
6363
echo "versionLabel: \"${SHORT_SHA}\"" >> e2e/kots-release-install/release.yaml
6464
cat e2e/kots-release-install/release.yaml
65+
cp output/bin/embedded-cluster output/bin/embedded-cluster-original
6566
make embedded-release # this is done after the metadata.json is generated so as to not include additional charts
6667
- name: Cache files for integration test
6768
if: github.actor != 'dependabot[bot]'
@@ -82,6 +83,7 @@ jobs:
8283
name: embedded-release
8384
path: |
8485
output/bin/embedded-cluster
86+
output/bin/embedded-cluster-original
8587
output/bin/embedded-cluster-release-builder
8688
e2e:
8789
runs-on: ubuntu-latest
@@ -101,6 +103,7 @@ jobs:
101103
- TestMultiNodeInstallation
102104
- TestMultiNodeReset
103105
- TestCommandsRequireSudo
106+
- TestInstallWithoutEmbed
104107
steps:
105108
- name: Checkout
106109
uses: actions/checkout@v4

e2e/install_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,26 @@ func TestMultiNodeInstallation(t *testing.T) {
336336
t.Logf("%s: test complete", time.Now().Format(time.RFC3339))
337337
}
338338

339+
func TestInstallWithoutEmbed(t *testing.T) {
340+
t.Parallel()
341+
tc := cluster.NewTestCluster(&cluster.Input{
342+
T: t,
343+
Nodes: 1,
344+
Image: "rockylinux/8",
345+
EmbeddedClusterPath: "../output/bin/embedded-cluster-original",
346+
})
347+
defer tc.Destroy()
348+
t.Logf("%s: installing embedded-cluster on node 0", time.Now().Format(time.RFC3339))
349+
line := []string{"default-install.sh"}
350+
if stdout, stderr, err := RunCommandOnNode(t, tc, 0, line); err != nil {
351+
t.Log("stdout:", stdout)
352+
t.Log("stderr:", stderr)
353+
t.Fatalf("fail to install embedded-cluster on node %s: %v", tc.Nodes[0], err)
354+
}
355+
356+
t.Logf("%s: test complete", time.Now().Format(time.RFC3339))
357+
}
358+
339359
func runPuppeteerAppStatusCheck(t *testing.T, node int, tc *cluster.Output) {
340360
t.Logf("%s: installing puppeteer on node %d", time.Now().Format(time.RFC3339), node)
341361
line := []string{"install-puppeteer.sh"}

e2e/scripts/default-install.sh

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
wait_for_healthy_node() {
5+
ready=$(kubectl get nodes | grep -v NotReady | grep -c Ready || true)
6+
counter=0
7+
while [ "$ready" -lt "1" ]; do
8+
if [ "$counter" -gt 36 ]; then
9+
return 1
10+
fi
11+
sleep 5
12+
counter=$((counter+1))
13+
echo "Waiting for node to be ready"
14+
ready=$(kubectl get nodes | grep -v NotReady | grep -c Ready || true)
15+
kubectl get nodes || true
16+
done
17+
18+
return 0
19+
}
20+
21+
wait_for_pods_running() {
22+
local timeout="$1"
23+
local start_time
24+
local current_time
25+
local elapsed_time
26+
start_time=$(date +%s)
27+
while true; do
28+
current_time=$(date +%s)
29+
elapsed_time=$((current_time - start_time))
30+
if [ "$elapsed_time" -ge "$timeout" ]; then
31+
kubectl get pods -A -o yaml || true
32+
kubectl describe nodes || true
33+
echo "Timed out waiting for all pods to be running."
34+
return 1
35+
fi
36+
local non_running_pods
37+
non_running_pods=$(kubectl get pods --all-namespaces --no-headers 2>/dev/null | awk '$4 != "Running" && $4 != "Completed" { print $0 }' | wc -l || echo 1)
38+
if [ "$non_running_pods" -ne 0 ]; then
39+
echo "Not all pods are running. Waiting."
40+
kubectl get pods,nodes -A || true
41+
sleep 5
42+
continue
43+
fi
44+
echo "All pods are running."
45+
return 0
46+
done
47+
}
48+
49+
check_openebs_storage_class() {
50+
scs=$(kubectl get sc --no-headers | wc -l)
51+
if [ "$scs" -ne "1" ]; then
52+
echo "Expected 1 storage class, found $scs"
53+
kubectl get sc
54+
return 1
55+
fi
56+
}
57+
58+
main() {
59+
if ! embedded-cluster install --no-prompt 2>&1 | tee /tmp/log ; then
60+
cat /etc/os-release
61+
echo "Failed to install embedded-cluster"
62+
exit 1
63+
fi
64+
if ! grep -q "Admin Console is ready!" /tmp/log; then
65+
echo "Failed to install embedded-cluster"
66+
exit 1
67+
fi
68+
if ! wait_for_healthy_node; then
69+
echo "Failed to install embedded-cluster"
70+
exit 1
71+
fi
72+
if ! wait_for_pods_running 900; then
73+
echo "Failed to install embedded-cluster"
74+
exit 1
75+
fi
76+
if ! check_openebs_storage_class; then
77+
echo "Failed to validate if only openebs storage class is present"
78+
exit 1
79+
fi
80+
if ! systemctl restart embedded-cluster; then
81+
echo "Failed to restart embedded-cluster service"
82+
exit 1
83+
fi
84+
}
85+
86+
export EMBEDDED_CLUSTER_METRICS_BASEURL="https://staging.replicated.app"
87+
export KUBECONFIG=/root/.config/embedded-cluster/etc/kubeconfig
88+
export PATH=$PATH:/root/.config/embedded-cluster/bin
89+
main

0 commit comments

Comments
 (0)