Skip to content

Commit 733afdf

Browse files
update dev container documentation and setup as the tests are now run out of cluster
Issue: ZENKO-5201
1 parent fbeabac commit 733afdf

File tree

4 files changed

+36
-45
lines changed

4 files changed

+36
-45
lines changed

.devcontainer/README.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,23 @@ See [tests/ctst/README.md](../tests/ctst/README.md) for more details on building
1414

1515
## Running e2e tests in the codespace
1616

17-
To run the CTST tests in the codespace, head to `.github/script/end2end/` and run `run-e2e-ctst.sh`
18-
script. Some variables need to be exported before running the tests.
17+
### Node tests (mocha)
1918

2019
```bash
21-
env_variables=$(yq eval '.env | to_entries | .[] | .key + "=" + .value' .github/workflows/end2end.yaml | sed 's/\${{[^}]*}}//g') && export $env_variables
22-
export E2E_IMAGE_TAG=latest
23-
export GCP_BACKEND_DESTINATION_LOCATION=
20+
# Set up the test environment (endpoints, credentials, mongo, TLS)
21+
source .github/scripts/end2end/setup-e2e-env.sh
2422

25-
cd .github/scripts/end2end/
26-
bash run-e2e-test.sh "end2end" ${E2E_IMAGE_NAME}:${E2E_IMAGE_TAG} "backbeat" "default"
23+
# Run mocha directly (setup-e2e-env.sh already cd's to node_tests/)
24+
yarn mocha --exit -t 10000 --recursive smoke_tests
25+
yarn mocha --exit -t 10000 --recursive cloudserver/bucketGetV2
26+
yarn mocha --exit -t 10000 --grep "should list objects" --recursive cloudserver/bucketGetV2
27+
```
28+
29+
### CTST tests (cucumber)
30+
31+
```bash
32+
cd tests/ctst
33+
./run-ctst-locally.sh @yourTag
2734
```
2835

2936
## Accessing s3 service

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"features": {
1313
"ghcr.io/devcontainers/features/docker-in-docker": {},
1414
"ghcr.io/devcontainers/features/github-cli:1": {},
15-
"ghcr.io/devcontainers/features/node:1": {},
15+
"ghcr.io/devcontainers/features/node:1": { "version": "22" },
1616
"ghcr.io/devcontainers/features/python:1": {},
1717
"ghcr.io/devcontainers/features/sshd:1": {},
1818
"ghcr.io/devcontainers-extra/features/kind:1": {},

.devcontainer/setup.sh

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,19 @@
22

33
set -e
44

5-
env_variables=$(yq eval '.env | to_entries | .[] | .key + "=" + .value' .github/workflows/end2end.yaml | sed 's/\${{[^}]*}}//g') && export $env_variables
6-
export GIT_ACCESS_TOKEN=${GITHUB_TOKEN}
7-
export E2E_IMAGE_TAG=latest
8-
5+
# Persist workflow env vars so they survive across terminal sessions
6+
ZENKO_ENV_FILE="$HOME/.zenko.env"
7+
yq eval '.env | to_entries | .[] | "export " + .key + "=" + (.value | tostring | @sh)' .github/workflows/end2end.yaml \
8+
| sed 's/\${{[^}]*}}//g' > "$ZENKO_ENV_FILE"
9+
echo 'export GIT_ACCESS_TOKEN="${GITHUB_TOKEN}"' >> "$ZENKO_ENV_FILE"
910
# Disable GCP tests as we don't have credentials setup in devcontainer
10-
export GCP_BACKEND_DESTINATION_LOCATION=
11+
echo 'export GCP_BACKEND_DESTINATION_LOCATION=' >> "$ZENKO_ENV_FILE"
12+
13+
# Source now for this session
14+
source "$ZENKO_ENV_FILE"
15+
16+
# Auto-source in future Codespace terminals
17+
echo '[ -f "$HOME/.zenko.env" ] && source "$HOME/.zenko.env"' >> "$HOME/.bashrc"
1118

1219
GITHUB_ENV=$(mktemp /tmp/github_env.XXXXXX)
1320

@@ -22,10 +29,10 @@ for i in $(seq 0 $array_length); do
2229
working_dir=$(yq ".runs.steps[$i].working-directory" .github/actions/deploy/action.yaml)
2330
run_command=$(yq ".runs.steps[$i].run" .github/actions/deploy/action.yaml)
2431

25-
# We don't want to run `run-e2e-test.sh` because it is used for linting here, user will run it manually if needed after deployment
26-
# We can't run `configure-e2e.sh` here because it needs an image that is not yet built and sent to kind, will be run after
32+
# We can't run `configure-e2e.sh` here because it needs services to be ready first, will be run after
33+
# User will run tests manually after deployment
2734
(
28-
if [[ "$run_command" != "null" && "$run_command" != *"configure-e2e.sh"* && "$run_command" != *"run-e2e-test.sh"* ]]; then
35+
if [[ "$run_command" != "null" && "$run_command" != *"configure-e2e.sh"* ]]; then
2936
# Inject env 'generated' from previous steps
3037
source "$GITHUB_ENV"
3138

@@ -47,23 +54,6 @@ for i in $(seq 0 $array_length); do
4754
)
4855
done
4956

50-
(
51-
cd tests/zenko_tests
52-
53-
envsubst < 'e2e-config.yaml.template' > 'e2e-config.yaml'
54-
if [[ "${ENABLE_RING_TESTS}" == "false" ]]; then
55-
yq -i 'del(.locations[] | select(.locationType == "location-scality-ring-s3-v1"))' e2e-config.yaml
56-
fi
57-
58-
if [ -z "$GCP_BACKEND_DESTINATION_LOCATION" ]; then
59-
yq -i 'del(.locations[] | select(.locationType == "location-gcp-v1"))' e2e-config.yaml
60-
fi
61-
62-
docker build -t $E2E_IMAGE_NAME:$E2E_IMAGE_TAG .
63-
kind load docker-image ${E2E_IMAGE_NAME}:${E2E_IMAGE_TAG}
64-
docker rmi ${E2E_IMAGE_NAME}:${E2E_IMAGE_TAG}
65-
)
66-
6757
(
6858
cd .github/scripts/end2end
6959

tests/zenko_tests/README.md

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,15 @@
88
# How to run node tests locally in a Codespace
99

1010
```bash
11-
cd tests/zenko_tests/node_tests
11+
# Set up the test environment (endpoints, credentials, mongo port-forward, TLS)
12+
source .github/scripts/end2end/setup-e2e-env.sh
1213

13-
# Run a specific test with grep
14-
./run-node-tests-locally.sh "should list objects in V2 format" "cloudserver/bucketGetV2"
15-
16-
# Run all tests in a folder
17-
./run-node-tests-locally.sh "" "cloudserver"
18-
19-
# Build and use a custom image
20-
docker build -t my-e2e:local ../
21-
./run-node-tests-locally.sh "should list objects" "cloudserver" my-e2e:local
14+
# Run mocha directly (setup-e2e-env.sh already cd's to node_tests/)
15+
yarn mocha --exit -t 10000 --recursive smoke_tests
16+
yarn mocha --exit -t 10000 --grep "should list objects" --recursive cloudserver/bucketGetV2
17+
yarn mocha --exit -t 10000 --recursive cloudserver
2218
```
2319

24-
To switch images, delete the pod first: `kubectl delete pod node-tests-local`
25-
2620
# How to write iam policy e2e tests
2721

2822
All iam policy controlled tests go under `node_tests/iam_policies`,

0 commit comments

Comments
 (0)