-
Notifications
You must be signed in to change notification settings - Fork 13
160 lines (158 loc) · 6.13 KB
/
Copy pathacceptance-sim.yml
File metadata and controls
160 lines (158 loc) · 6.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
name: "simulator acceptance tests"
on:
workflow_call:
inputs:
omicron-sha:
type: "string"
required: true
testrail-upload:
type: "boolean"
required: false
default: false
secrets:
testrail-host:
required: false
testrail-project:
required: false
testrail-username:
required: false
testrail-api-key:
required: false
jobs:
acceptance:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
tf-binary:
- terraform
- tofu
steps:
- uses: actions/checkout@v7
- uses: hashicorp/setup-terraform@v4
if: matrix.tf-binary == 'terraform'
with:
terraform_wrapper: false
- uses: opentofu/setup-opentofu@v2
if: matrix.tf-binary == 'tofu'
with:
tofu_wrapper: false
- uses: actions/setup-go@v7
with:
go-version-file: 'go.mod'
- uses: docker/setup-compose-action@v2
- uses: astral-sh/setup-uv@v7
with:
# We don't have any Python dependencies to cache.
enable-cache: false
# Look up the version of oxide.rs corresponding to the requested omicron version. We'll cache
# the resulting binary, so that we only build the CLI for a given oxide.rs commit once, and
# always use the latest oxide.rs version corresponding to the relevant omicron version.
- name: resolve oxide cli version
id: oxide-cli
env:
GH_TOKEN: ${{ github.token }}
run: |
commit=$(./acctest/oxide-cli-version.sh '${{ inputs.omicron-sha }}')
echo "commit=${commit}" >> $GITHUB_OUTPUT
- name: cache oxide cli
uses: actions/cache@v6
with:
path: ~/.cargo/bin/oxide
key: oxide-cli-${{ steps.oxide-cli.outputs.commit }}
- name: install oxide cli
run: |
if [[ -x ~/.cargo/bin/oxide ]]; then
echo "using cached oxide cli"
else
cargo install \
--git https://github.com/oxidecomputer/oxide.rs \
--rev '${{ steps.oxide-cli.outputs.commit }}' \
oxide-cli
fi
~/.cargo/bin/oxide version
echo ~/.cargo/bin >> $GITHUB_PATH
# Run simulated omicron in the background with docker compose.
# The image is pre-built and pushed by the publish-image job in build-test.yml.
- name: ensure omicron-dev image
run: ./acctest/ensure-image.sh '${{ inputs.omicron-sha }}'
- name: start omicron-dev
working-directory: acctest
env:
TEST_ACC_DOCKER_TAG: ${{ inputs.omicron-sha }}
run: docker compose up --wait --wait-timeout 1500
# We can't use `oxide auth login` here, since it requires a browser to
# complete the oauth device flow. Instead, fetch an auth token using a
# script that simulates the browser flow.
- id: auth-token
working-directory: acctest
run: |
echo "OXIDE_TOKEN=$(uv run auth.py)" >> $GITHUB_OUTPUT
# Create oxide resources necessary for acceptance tests, including an
# arbitrary small image. Skip proxy to avoid recording the fairly large
# image upload requests.
- name: oxide-dependencies
run: |
# Install qemu, which we'll use to build a sample image.
sudo apt-get update && sudo apt-get install -y qemu-utils
./scripts/acc-test-setup.sh
env:
OXIDE_HOST: http://localhost:12220
OXIDE_TOKEN: ${{ steps.auth-token.outputs.OXIDE_TOKEN }}
- name: run acceptance test
run: |
export TF_ACC_TERRAFORM_PATH=$(which ${{ matrix.tf-binary }})
make testacc
env:
CHECKPOINT_DISABLE: "1"
OXIDE_HOST: http://localhost:8080
OXIDE_TOKEN: ${{ steps.auth-token.outputs.OXIDE_TOKEN }}
TEST_ACC_GOTESTSUM_ARGS: "--rerun-fails-report=./acctest/acc-test-rerun.txt --junitfile=./acctest/acc-tests.xml"
TF_ACC_PROVIDER_NAMESPACE: oxidecomputer
TF_ACC_SIM: "1"
TF_LOG: "TRACE"
TF_LOG_PATH: "terraform.log"
- name: extract log files
if: always()
continue-on-error: true
working-directory: acctest
# Ignore command errors to collect as many logs as possible.
run: |
docker compose exec -T omicron-dev sh -c 'tar -cf - /tmp/omicron-dev*.log' | tar -xf - || true
docker compose exec -T mitmproxy sh -c 'tar -cf - /tmp/mitmproxy.log' | tar -xf - || true
docker compose logs omicron-dev > ./tmp/omicron-dev.log || true
find .. -name terraform.log -exec cat {} \; > ./tmp/terraform.log || true
cp ./acc-tests.xml ./tmp || true
- name: rerun warn
if: always()
continue-on-error: true
working-directory: acctest
run: |
if [ -f ./acc-test-rerun.txt ]; then
echo "::warning title=${{ github.job }} (${{ matrix.tf-binary }}) - test rerun::$(cat ./acc-test-rerun.txt)"
fi
- name: upload test results to TestRail
if: ${{ always() && inputs.testrail-upload }}
continue-on-error: true
env:
TR_CLI_HOST: ${{ secrets.testrail-host }}
TR_CLI_USERNAME: ${{ secrets.testrail-username }}
TR_CLI_KEY: ${{ secrets.testrail-api-key }}
TR_CLI_PROJECT: ${{ secrets.testrail-project }}
run: |
uvx trcli \
--yes `# Auto-create new test cases.` \
parse_junit \
--file './acctest/acc-tests.xml' \
--title 'Acceptance Tests (${{ matrix.tf-binary }}) - ${{ github.run_id }} - ${{ job.check_run_id }}' \
--run-description 'GitHub workflow: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/job/${{ job.check_run_id }}' \
--update-existing-cases 'yes' \
--case-matcher 'auto' \
--close-run
- name: upload logs
if: always()
continue-on-error: true
uses: actions/upload-artifact@v7
with:
name: logs-${{ matrix.tf-binary }}-${{ job.check_run_id }}
path: acctest/tmp/