Skip to content

Commit

Permalink
Use latest release version in install script tests
Browse files Browse the repository at this point in the history
This way, we can guarantee that the release version we are installing in
tests available. Use `gh` to get the latest release number and pass the
TELEPORT_VERSION shell variable to test containers.
  • Loading branch information
ptgott committed Dec 27, 2024
1 parent 89a10ce commit 9e2a2d9
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 33 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/test-install-script.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: bash run-all-tests.sh
- env:
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
working-directory: ./assets/install-scripts/install-teleport-tests
run: |
export TELEPORT_VERSION=$(gh api /repos/gravitational/teleport/releases/latest | jq -r .tag_name | tr -d "v");
bash run-all-tests.sh
57 changes: 31 additions & 26 deletions assets/install-scripts/install-teleport-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ for the one-line Teleport installation script available at
The test suite uses `docker compose` to launch containers based on a number of
Linux distributions. Each container mounts the installation script and runs it,
then runs a command to make assertions against the results of the installation
script.
script. The test suite uses the value of the `TELEPORT_VERSION` environment
variable to determine the version of Teleport to install.

If an assertion fails, the container running the script prints a log that
includes the string `INSTALL_SCRIPT_TEST_FAILURE`. After running containers, the
Expand All @@ -19,6 +20,8 @@ with an error code.
## Run the test suite

```bash
# Assign TELEPORT_VERSION to your version number
$ export TELEPORT_VERSION=10.0.0
$ cd assets/install-scripts/install-teleport-tests
$ bash run-all-tests.sh
```
Expand All @@ -37,30 +40,32 @@ Consult `docker-compose.yml` for the available test cases.

## Add a test

1. Add a service definition to `docker-compose.yml`.
1. Add the following bind mounts to the service definition:

```yaml
volumes:
- type: bind
source: ../install.sh
target: /install.sh
- type: bind
source: ./run-test.sh
target: /run-test.sh
```
1. Edit the `command` field of the service definition to include the following:

```yaml
bash /install.sh 15.0.0;
bash /run-test.sh oss'
```
Add a test by defining a service similar to the following, adjusting the values
to fit your test case:

```yaml
test-ubuntu-jammy-cloud:
image: ubuntu:22.04
environment:
- TELEPORT_VERSION
volumes:
- type: bind
source: ../install.sh
target: /install.sh
- type: bind
source: ./run-test.sh
target: /run-test.sh
# Need to install curl on the ubuntu container
command: |
bash -c 'apt-get update;
apt-get install -y curl;
bash /install.sh ${TELEPORT_VERSION} cloud;
bash /run-test.sh cloud'
```
Edit the parameters of the `install.sh` and `run-tests.sh` scripts as
appropriate. The edition parameter of the two must match (the default edition
parameter for `install.sh` is `oss`).
Edit the parameters of the `install.sh` and `run-tests.sh` scripts as
appropriate. The edition parameter of the two must match (the default edition
parameter for `install.sh` is `oss`).

1. To add an assertion to the test suite, edit `run-test.sh`. Each assertion
must print a log that includes the string `INSTALL_SCRIPT_TEST_FAILURE` if it
fails.
To add an assertion to the test suite, edit `run-test.sh`. Each assertion must
print a log that includes the string `INSTALL_SCRIPT_TEST_FAILURE` if it fails.
24 changes: 18 additions & 6 deletions assets/install-scripts/install-teleport-tests/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
services:
test-ubuntu-jammy-cloud:
image: ubuntu:22.04
environment:
- TELEPORT_VERSION
volumes:
- type: bind
source: ../install.sh
Expand All @@ -12,11 +14,13 @@ services:
command: |
bash -c 'apt-get update;
apt-get install -y curl;
bash /install.sh 15.1.0 cloud;
bash /install.sh ${TELEPORT_VERSION} cloud;
bash /run-test.sh cloud'
test-ubuntu-jammy-no-edition:
image: ubuntu:22.04
environment:
- TELEPORT_VERSION
volumes:
- type: bind
source: ../install.sh
Expand All @@ -28,11 +32,13 @@ services:
command: |
bash -c 'apt-get update;
apt-get install -y curl;
bash /install.sh 15.0.0;
bash /install.sh ${TELEPORT_VERSION};
bash /run-test.sh oss'
test-debian-bookworm-oss:
image: debian:bookworm
environment:
- TELEPORT_VERSION
volumes:
- type: bind
source: ../install.sh
Expand All @@ -44,11 +50,13 @@ services:
command: |
bash -c 'apt-get update;
apt-get install -y curl;
bash /install.sh 15.0.0 oss;
bash /install.sh ${TELEPORT_VERSION} oss;
bash /run-test.sh oss'
test-rocky-9-enterprise:
image: rockylinux:9
environment:
- TELEPORT_VERSION
volumes:
- type: bind
source: ../install.sh
Expand All @@ -57,11 +65,13 @@ services:
source: ./run-test.sh
target: /run-test.sh
command: |
bash -c 'bash /install.sh 15.0.0 enterprise;
bash -c 'bash /install.sh ${TELEPORT_VERSION} enterprise;
bash /run-test.sh enterprise'
test-sles-cloud:
image: registry.suse.com/bci/bci-base:15.5
environment:
- TELEPORT_VERSION
volumes:
- type: bind
source: ../install.sh
Expand All @@ -75,14 +85,16 @@ services:
bash -c '
zypper update -y;
zypper install -y awk;
bash /install.sh 15.1.0 cloud;
bash /install.sh ${TELEPORT_VERSION} cloud;
bash /run-test.sh cloud'
# Ensure that the installation script completes as expected when the ID_LIKE
# value in /etc/os-release is "ubuntu debian", as it is on Linux Mint and
# Pop!_OS.
test-ubuntu-debian:
image: ubuntu:22.04
environment:
- TELEPORT_VERSION
volumes:
- type: bind
source: ../install.sh
Expand All @@ -95,7 +107,7 @@ services:
bash -c 'apt-get update;
apt-get install -y curl;
sed -E -i "s/ID_LIKE=.*$/ID_LIKE=\"ubuntu debian\"/" /etc/os-release;
bash /install.sh 15.0.0;
bash /install.sh ${TELEPORT_VERSION};
bash /run-test.sh oss'

0 comments on commit 9e2a2d9

Please sign in to comment.