Skip to content

Commit

Permalink
chore: use a license during e2e tests (#172)
Browse files Browse the repository at this point in the history
* chore: use a license during e2e tests

in order to capture problems with the embedded license we need to use a
version of the embedded cluster binary with an embedded kots license.

* chore: fix wrong e2e test name

* chore: error out if message is not found

* chore: remove surplus password confirmation

* chore: bump admin console version
  • Loading branch information
ricardomaraschini authored Nov 8, 2023
1 parent cd77654 commit 781f6b9
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 14 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ bundle
pkg/goods/bins
pkg/goods/images
*tgz
license.yaml
release.tar.gz
release.o
20 changes: 12 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ARCH := $(shell uname -m)
APP_NAME = embedded-cluster
ADMIN_CONSOLE_CHART_URL = oci://registry.replicated.com/library
ADMIN_CONSOLE_CHART_NAME = admin-console
ADMIN_CONSOLE_CHART_VERSION = 1.104.0
ADMIN_CONSOLE_CHART_VERSION = 1.104.0-build.1
EMBEDDED_OPERATOR_CHART_URL = oci://registry.replicated.com/library
EMBEDDED_OPERATOR_CHART_NAME = embedded-cluster-operator
EMBEDDED_OPERATOR_CHART_VERSION = 0.2.0
Expand Down Expand Up @@ -92,12 +92,16 @@ pkg/goods/bins/embedded-cluster/kubectl-preflight:
tar -xzf output/tmp/preflight/preflight.tar.gz -C output/tmp/preflight
mv output/tmp/preflight/preflight pkg/goods/bins/embedded-cluster/kubectl-preflight

.PHONY: embed-license
embed-license: embedded-cluster-linux-amd64 license.yaml
release.tar.gz:
mkdir -p output/tmp
tar -czvf output/tmp/license.tar.gz license.yaml
objcopy --input-target binary --output-target binary --rename-section .data=sec_bundle output/tmp/license.tar.gz output/tmp/license.tar.gz.o
objcopy --add-section sec_bundle=output/tmp/license.tar.gz.o output/bin/embedded-cluster
tar -czf release.tar.gz -C e2e/kots-release .

.PHONY: embedded-release
embedded-release: embedded-cluster-linux-amd64 release.tar.gz
objcopy --input-target binary --output-target binary --rename-section .data=sec_bundle release.tar.gz release.o
@if ! objcopy --update-section sec_bundle=release.o output/bin/embedded-cluster ; then \
objcopy --add-section sec_bundle=release.o output/bin/embedded-cluster ; \
fi

.PHONY: static
static: pkg/goods/bins/embedded-cluster/kubectl-preflight \
Expand Down Expand Up @@ -133,14 +137,14 @@ vet: static-linux-amd64 static
go vet ./...

.PHONY: e2e-tests
e2e-tests: embedded-cluster-linux-amd64
e2e-tests: embedded-release
mkdir -p output/tmp
rm -rf output/tmp/id_rsa*
ssh-keygen -t rsa -N "" -C "Integration Test Key" -f output/tmp/id_rsa
go test -timeout 45m -parallel 1 -failfast -v ./e2e

.PHONY: e2e-test
e2e-test: embedded-cluster-linux-amd64
e2e-test: embedded-release
mkdir -p output/tmp
rm -rf output/tmp/id_rsa*
ssh-keygen -t rsa -N "" -C "Integration Test Key" -f output/tmp/id_rsa
Expand Down
11 changes: 11 additions & 0 deletions e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,14 @@ TestSomething is the name of the test function you want to run.

To add more tests you just need to create one inside this directory
and then add it to the `.github/workflows/e2e.yaml` file.


### Kots test application

During end to end tests we embed a license for a smoke test kots app,
this app can be found in:

https://vendor.replicated.com/apps/embedded-cluster-smoke-test-app

Make sure to update the application yaml files under kots-release
directory if you create a new release of the remote application.
2 changes: 1 addition & 1 deletion e2e/embed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/replicatedhq/embedded-cluster/e2e/cluster"
)

func AndInstall(t *testing.T) {
func TestEmbedAndInstall(t *testing.T) {
t.Parallel()
tc := cluster.NewTestCluster(&cluster.Input{
T: t,
Expand Down
15 changes: 15 additions & 0 deletions e2e/kots-release/kots-app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
apiVersion: kots.io/v1beta1
kind: Application
metadata:
name: nginx
spec:
title: Embedded Cluster Smoke Test App
icon: https://raw.githubusercontent.com/cncf/artwork/master/projects/kubernetes/icon/color/kubernetes-icon-color.png
statusInformers:
- deployment/nginx
ports:
- serviceName: "nginx"
servicePort: 80
localPort: 8888
applicationUrl: "http://nginx"
27 changes: 27 additions & 0 deletions e2e/kots-release/license.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: kots.io/v1beta1
kind: License
metadata:
name: embeddedclusterintegrationtests
spec:
appSlug: embedded-cluster-smoke-test-app
channelID: 2Xt5IoImUY2W8eo5DWZEdtA5Yr1
channelName: Stable
customerName: Embedded Cluster Integration Tests
endpoint: https://replicated.app
entitlements:
expires_at:
description: License Expiration
signature: {}
title: Expiration
value: ""
valueType: String
isGitOpsSupported: true
isHelmVmDownloadEnabled: true
isKotsInstallEnabled: true
isNewKotsUiEnabled: true
isSemverRequired: true
isSnapshotSupported: true
licenseID: 2Xt5q15MDpLvaO15UZ5XhKxBqB1
licenseSequence: 1
licenseType: prod
signature: eyJsaWNlbnNlRGF0YSI6ImV5SmhjR2xXWlhKemFXOXVJam9pYTI5MGN5NXBieTkyTVdKbGRHRXhJaXdpYTJsdVpDSTZJa3hwWTJWdWMyVWlMQ0p0WlhSaFpHRjBZU0k2ZXlKdVlXMWxJam9pWlcxaVpXUmtaV1JqYkhWemRHVnlhVzUwWldkeVlYUnBiMjUwWlhOMGN5SjlMQ0p6Y0dWaklqcDdJbXhwWTJWdWMyVkpSQ0k2SWpKWWREVnhNVFZOUkhCTWRtRlBNVFZWV2pWWWFFdDRRbkZDTVNJc0lteHBZMlZ1YzJWVWVYQmxJam9pY0hKdlpDSXNJbU4xYzNSdmJXVnlUbUZ0WlNJNklrVnRZbVZrWkdWa0lFTnNkWE4wWlhJZ1NXNTBaV2R5WVhScGIyNGdWR1Z6ZEhNaUxDSmhjSEJUYkhWbklqb2laVzFpWldSa1pXUXRZMngxYzNSbGNpMXpiVzlyWlMxMFpYTjBMV0Z3Y0NJc0ltTm9ZVzV1Wld4SlJDSTZJakpZZERWSmI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aVlZzYTBscWIybFpiVkpzV2xSVk1rNVVXWGRaTWxwcFRrUk9hazlYU1hsUFIwcHRUMVJvYkZsWFRtaGFiVVV5VGtSWmFXWlJQVDBpZlE9PSJ9
2 changes: 1 addition & 1 deletion e2e/scripts/embedded-preflight.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ embed_preflight() {
objcopy --input-target binary --output-target binary --rename-section .data=sec_bundle /root/preflight.tar.gz /root/preflight.o
rm -rf /usr/local/bin/embedded-cluster
cp -Rfp /usr/local/bin/embedded-cluster-copy /usr/local/bin/embedded-cluster
objcopy --add-section sec_bundle=/root/preflight.o /usr/local/bin/embedded-cluster
objcopy --update-section sec_bundle=/root/preflight.o /usr/local/bin/embedded-cluster
}

has_applied_host_preflight() {
Expand Down
5 changes: 4 additions & 1 deletion e2e/scripts/interactive-multi-node-install.exp
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ expect -re "Add another node?.*:" { send "n\r" }
set timeout 600
expect "Enter a new Admin Console password:" { send "password\r" }
expect "Confirm password:" { send "password\r" }
expect "Admin Console is ready!"
expect {
"Admin Console is ready!" { exit 0 }
eof { exit 1 }
}
4 changes: 2 additions & 2 deletions pkg/kubeutils/kubeutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ func WaitForDeployment(ctx context.Context, cli client.Client, ns, name string)
if err := wait.ExponentialBackoff(backoff, func() (bool, error) {
ready, err := IsDeploymentReady(ctx, cli, ns, name)
if err != nil {
lasterr = fmt.Errorf("error checking status of kotsadm: %v", err)
lasterr = fmt.Errorf("unable to get deploy %s status: %v", name, err)
return false, nil
}
return ready, nil
}); err != nil {
return fmt.Errorf("timed out waiting for admin console: %v", lasterr)
return fmt.Errorf("timed out waiting for deploy %s: %v", name, lasterr)
}
return nil
}
Expand Down

0 comments on commit 781f6b9

Please sign in to comment.