Skip to content

Commit

Permalink
update TestHostPreflightCustomSpec to use real releases
Browse files Browse the repository at this point in the history
  • Loading branch information
laverya committed Feb 1, 2025
1 parent db24f90 commit 89c256f
Show file tree
Hide file tree
Showing 28 changed files with 881 additions and 128 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,18 @@ jobs:
export APP_VERSION="appver-${SHORT_SHA}-unsupported-overrides"
export RELEASE_YAML_DIR=e2e/kots-release-unsupported-overrides
./scripts/ci-release-app.sh
# then install a version with additional failing host preflights
export EC_VERSION="$(git describe --tags --abbrev=4 --match='[0-9]*.[0-9]*.[0-9]*')"
export APP_VERSION="appver-${SHORT_SHA}-failing-preflights"
export RELEASE_YAML_DIR=e2e/kots-release-install-failing-preflights
./scripts/ci-release-app.sh
# then install a version with additional warning host preflights
export EC_VERSION="$(git describe --tags --abbrev=4 --match='[0-9]*.[0-9]*.[0-9]*')"
export APP_VERSION="appver-${SHORT_SHA}-warning-preflights"
export RELEASE_YAML_DIR=e2e/kots-release-install-warning-preflights
./scripts/ci-release-app.sh
# promote a release with improved dr support
export EC_VERSION="$(git describe --tags --abbrev=4 --match='[0-9]*.[0-9]*.[0-9]*')-legacydr"
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/release-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,18 @@ jobs:
export APP_VERSION="appver-${SHORT_SHA}-unsupported-overrides"
export RELEASE_YAML_DIR=e2e/kots-release-unsupported-overrides
./scripts/ci-release-app.sh
# then install a version with additional failing host preflights
export EC_VERSION="$(git describe --tags --abbrev=4 --match='[0-9]*.[0-9]*.[0-9]*')"
export APP_VERSION="appver-${SHORT_SHA}-failing-preflights"
export RELEASE_YAML_DIR=e2e/kots-release-install-failing-preflights
./scripts/ci-release-app.sh
# then install a version with additional warning host preflights
export EC_VERSION="$(git describe --tags --abbrev=4 --match='[0-9]*.[0-9]*.[0-9]*')"
export APP_VERSION="appver-${SHORT_SHA}-warning-preflights"
export RELEASE_YAML_DIR=e2e/kots-release-install-warning-preflights
./scripts/ci-release-app.sh
# then a noop upgrade
export EC_VERSION="${{ github.ref_name }}"
Expand Down
33 changes: 27 additions & 6 deletions e2e/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,9 @@ func TestHostPreflightCustomSpec(t *testing.T) {
RequireEnvVars(t, []string{"SHORT_SHA"})

tc := docker.NewCluster(&docker.ClusterInput{
T: t,
Nodes: 1,
Distro: "centos-9",
LicensePath: "license.yaml",
ECBinaryPath: "../output/bin/embedded-cluster",
ECReleaseBuilderPath: "../output/bin/embedded-cluster-release-builder",
T: t,
Nodes: 1,
Distro: "centos-9",
})
defer tc.Cleanup()

Expand All @@ -296,6 +293,30 @@ func TestHostPreflightCustomSpec(t *testing.T) {
t.Fatalf("fail to install dependencies on node 0: %v: %s: %s", err, stdout, stderr)
}

t.Logf("%s: downloading failing-preflights embedded-cluster on node 0", time.Now().Format(time.RFC3339))
line = []string{"vandoor-prepare.sh", fmt.Sprintf("appver-%s-failing-preflights", os.Getenv("SHORT_SHA")), os.Getenv("LICENSE_ID"), "false"}
if stdout, stderr, err := tc.RunCommandOnNode(0, line); err != nil {
t.Fatalf("fail to download embedded-cluster on node 0: %v: %s: %s", err, stdout, stderr)
}

t.Logf("%s: moving embedded-cluster to /usr/local/bin/embedded-cluster-failing-preflights", time.Now().Format(time.RFC3339))
line = []string{"mv", "/usr/local/bin/embedded-cluster", "/usr/local/bin/embedded-cluster-failing-preflights"}
if stdout, stderr, err := tc.RunCommandOnNode(0, line); err != nil {
t.Fatalf("fail to move embedded-cluster on node 0: %v: %s: %s", err, stdout, stderr)
}

t.Logf("%s: removing the original license file", time.Now().Format(time.RFC3339))
line = []string{"rm", "/assets/license.yaml"}
if stdout, stderr, err := tc.RunCommandOnNode(0, line); err != nil {
t.Fatalf("fail to remove /assets/license.yaml on node 0: %v: %s: %s", err, stdout, stderr)
}

t.Logf("%s: downloading warning-preflights embedded-cluster on node 0", time.Now().Format(time.RFC3339))
line = []string{"vandoor-prepare.sh", fmt.Sprintf("appver-%s-warning-preflights", os.Getenv("SHORT_SHA")), os.Getenv("LICENSE_ID"), "false"}
if stdout, stderr, err := tc.RunCommandOnNode(0, line); err != nil {
t.Fatalf("fail to download embedded-cluster on node 0: %v: %s: %s", err, stdout, stderr)
}

t.Logf("%s: running embedded-cluster preflights on node 0", time.Now().Format(time.RFC3339))
line = []string{"embedded-preflight.sh"}
if stdout, stderr, err := tc.RunCommandOnNode(0, line); err != nil {
Expand Down
33 changes: 33 additions & 0 deletions e2e/kots-release-install-failing-preflights/backup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: velero.io/v1
kind: Backup
metadata:
name: backup
annotations:
preserve: me
spec:
ttl: 36h0m0s
includedNamespaces:
- kotsadm
orLabelSelectors:
- matchExpressions:
- { key: kots.io/kotsadm, operator: NotIn, values: ["true"] }
hooks:
resources:
- name: test-hook
includedResources:
- 'pods'
labelSelector:
matchLabels:
app: example
component: nginx
pre:
- exec:
container: nginx
command:
- /bin/uname
- -a
post:
- exec:
command:
- /bin/uname
- -a
73 changes: 73 additions & 0 deletions e2e/kots-release-install-failing-preflights/cluster-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
apiVersion: embeddedcluster.replicated.com/v1beta1
kind: Config
metadata:
name: "testconfig"
spec:
version: "__version_string__"
binaryOverrideUrl: "__release_url__"
metadataOverrideUrl: "__metadata_url__"
roles:
controller:
labels:
controller-label: controller-label-value
name: controller-test
custom:
- labels:
abc-test-label: abc-test-label-value
abc-test-label-two: abc-test-label-value-2
name: abc
- labels:
xyz-test-label: xyz-value
name: xyz
unsupportedOverrides:
builtInExtensions:
- name: admin-console
values: |
labels:
release-custom-label: release-clustom-value
- name: embedded-cluster-operator
values: |
global:
labels:
release-custom-label: release-clustom-value
k0s: |
config:
metadata:
name: foo
spec:
telemetry:
enabled: false
extensions:
helm:
repositories:
- name: ingress-nginx
url: https://kubernetes.github.io/ingress-nginx
- name: okgolove
url: https://okgolove.github.io/helm-charts/
charts:
- name: ingress-nginx
chartname: ingress-nginx/ingress-nginx
namespace: ingress-nginx
version: "4.11.3"
values: |
controller:
service:
type: NodePort
nodePorts:
http: "80"
https: "443"
image:
digest: ""
digestChroot: ""
admissionWebhooks:
patch:
image:
digest: ""
- chartname: okgolove/goldpinger
name: goldpinger
namespace: goldpinger
version: 6.1.2
order: 11
values: |
image:
repository: proxy.replicated.com/anonymous/bloomberg/goldpinger
13 changes: 13 additions & 0 deletions e2e/kots-release-install-failing-preflights/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: kots.io/v1beta1
kind: Config
spec:
groups:
- name: config_group
title: The First Config Group
items:
- name: hostname
title: Hostname
type: text
- name: pw
title: Password
type: password
36 changes: 36 additions & 0 deletions e2e/kots-release-install-failing-preflights/deployment-2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: second
labels:
app: second
replicated.com/disaster-recovery: app
spec:
replicas: 0
selector:
matchLabels:
app: second
template:
metadata:
labels:
app: second
spec:
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app
operator: In
values:
- second
topologyKey: "kubernetes.io/hostname"
containers:
- name: nginx
image: proxy.replicated.com/anonymous/nginx:1.24-alpine
resources:
limits:
memory: '32Mi'
cpu: '50m'
38 changes: 38 additions & 0 deletions e2e/kots-release-install-failing-preflights/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
labels:
app: example
component: nginx
replicated.com/disaster-recovery: app
spec:
replicas: 1
selector:
matchLabels:
app: example
component: nginx
template:
metadata:
labels:
app: example
component: nginx
spec:
containers:
- name: nginx
image: proxy.replicated.com/anonymous/nginx:1.24-alpine
resources:
limits:
memory: '64Mi'
cpu: '50m'
env:
- name: APP_SEQUENCE
value: "{{repl Cursor }}"
- name: APP_VERSION
value: "{{repl VersionLabel }}"
- name: APP_CHANNEL
value: "{{repl ChannelName }}"
- name: CONFIG_HOSTNAME
value: '{{repl ConfigOption "hostname" }}'
- name: CONFIG_PASSWORD
value: '{{repl ConfigOption "pw" }}'
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
apiVersion: troubleshoot.sh/v1beta2
kind: HostPreflight
spec:
collectors:
- tcpPortStatus:
collectorName: Port 24
port: 24
- tcpPortStatus:
collectorName: Port 22
port: 22
analyzers:
- tcpPortStatus:
checkName: Port 24
collectorName: Port 24
outcomes:
- fail:
when: connection-refused
message: Connection to port 24 was refused.
- warn:
when: address-in-use
message: Another process was already listening on port 24.
- fail:
when: connection-timeout
message: Timed out connecting to port 24.
- fail:
when: error
message: Unexpected port status
- pass:
when: connected
message: Port 24 is available
- warn:
message: Unexpected port status
- tcpPortStatus:
checkName: Port 22
collectorName: Port 22
outcomes:
- fail:
when: connection-refused
message: Connection to port 22 was refused.
- fail:
when: address-in-use
message: Another process was already listening on port 22.
- fail:
when: connection-timeout
message: Timed out connecting to port 22.
- fail:
when: error
message: Unexpected port status
- pass:
when: connected
message: Port 22 is available
- warn:
message: Unexpected port status
10 changes: 10 additions & 0 deletions e2e/kots-release-install-failing-preflights/k8s-app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: app.k8s.io/v1beta1
kind: Application
metadata:
name: "nginx"
spec:
descriptor:
links:
- description: Open App
# needs to match applicationUrl in kots-app.yaml
url: "http://nginx"
16 changes: 16 additions & 0 deletions e2e/kots-release-install-failing-preflights/kots-app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
apiVersion: kots.io/v1beta1
kind: Application
metadata:
name: nginx
spec:
title: Embedded Cluster Smoke Test Staging App
icon: https://raw.githubusercontent.com/cncf/artwork/master/projects/kubernetes/icon/color/kubernetes-icon-color.png
allowRollback: true
statusInformers:
- deployment/nginx
ports:
- serviceName: "nginx"
servicePort: 80
localPort: 8888
applicationUrl: "http://nginx"
Loading

0 comments on commit 89c256f

Please sign in to comment.