Group kind tests by owning component
This commit is contained in:
parent
fa7220ee33
commit
ffa65018ed
2 changed files with 115 additions and 115 deletions
117
tests/kind/sample/job.yaml.in
Normal file
117
tests/kind/sample/job.yaml.in
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
apiVersion: batch/v1
|
||||
kind: Job
|
||||
metadata:
|
||||
name: @@JOB_NAME@@
|
||||
namespace: remora-testbed
|
||||
spec:
|
||||
activeDeadlineSeconds: 300
|
||||
backoffLimit: 0
|
||||
ttlSecondsAfterFinished: 300
|
||||
template:
|
||||
spec:
|
||||
automountServiceAccountToken: false
|
||||
enableServiceLinks: false
|
||||
restartPolicy: Never
|
||||
dnsPolicy: None
|
||||
dnsConfig:
|
||||
nameservers: [10.96.0.53]
|
||||
searches: [remora-testbed.svc.cluster.local, svc.cluster.local, cluster.local]
|
||||
options:
|
||||
- {name: ndots, value: "5"}
|
||||
initContainers:
|
||||
- name: durable-canary
|
||||
image: @@POSTGRES_IMAGE@@
|
||||
imagePullPolicy: Never
|
||||
command: [/bin/sh, -ec]
|
||||
args: [psql "$DATABASE_URL" --set ON_ERROR_STOP=1 --command "SELECT 1"]
|
||||
envFrom:
|
||||
- configMapRef: {name: @@PROFILE_NAME@@}
|
||||
resources:
|
||||
requests: {cpu: 25m, memory: 32Mi}
|
||||
limits: {cpu: "1", memory: 128Mi}
|
||||
- name: coordination-canary
|
||||
image: @@REDIS_IMAGE@@
|
||||
imagePullPolicy: Never
|
||||
command: [/bin/sh, -ec]
|
||||
args:
|
||||
- |
|
||||
key="${REMORA_COORDINATION_NAMESPACE}sample-canary"
|
||||
redis-cli -u "$REMORA_COORDINATION_URL" SET "$key" passed >/dev/null
|
||||
test "$(redis-cli -u "$REMORA_COORDINATION_URL" GET "$key")" = passed
|
||||
envFrom:
|
||||
- configMapRef: {name: @@PROFILE_NAME@@}
|
||||
resources:
|
||||
requests: {cpu: 25m, memory: 32Mi}
|
||||
limits: {cpu: "1", memory: 128Mi}
|
||||
- name: oidc-canary
|
||||
image: @@CURL_IMAGE@@
|
||||
imagePullPolicy: Never
|
||||
command: [/bin/sh, -ec]
|
||||
args:
|
||||
- |
|
||||
discovery="$(curl --fail --silent --show-error "$REMORA_OIDC_ISSUER/.well-known/openid-configuration")"
|
||||
printf '%s' "$discovery" | grep -F '"issuer"' >/dev/null
|
||||
printf '%s' "$discovery" | grep -F "$REMORA_OIDC_ISSUER" >/dev/null
|
||||
case "$REMORA_OIDC_PROVIDER" in
|
||||
keycloak) keys="$REMORA_OIDC_ISSUER/protocol/openid-connect/certs" ;;
|
||||
zitadel) keys="$REMORA_OIDC_ISSUER/oauth/v2/keys" ;;
|
||||
*) exit 1 ;;
|
||||
esac
|
||||
curl --fail --silent --show-error "$keys" | grep -F '"keys"' >/dev/null
|
||||
envFrom:
|
||||
- configMapRef: {name: @@PROFILE_NAME@@}
|
||||
resources:
|
||||
requests: {cpu: 25m, memory: 32Mi}
|
||||
limits: {cpu: "1", memory: 128Mi}
|
||||
- name: target-canary
|
||||
image: @@AWS_CLI_IMAGE@@
|
||||
imagePullPolicy: Never
|
||||
command: [/bin/sh, -ec]
|
||||
args:
|
||||
- |
|
||||
export AWS_ACCESS_KEY_ID="$REMORA_TARGET_ACCESS_KEY"
|
||||
export AWS_SECRET_ACCESS_KEY="$REMORA_TARGET_SECRET_KEY"
|
||||
export AWS_DEFAULT_REGION="$REMORA_TARGET_REGION"
|
||||
key="${REMORA_TARGET_PREFIX}sample-canary"
|
||||
printf 'passed\n' >/tmp/input
|
||||
aws --endpoint-url "$REMORA_TARGET_ENDPOINT" s3api put-object --bucket "$REMORA_TARGET_BUCKET" --key "$key" --body /tmp/input >/dev/null
|
||||
aws --endpoint-url "$REMORA_TARGET_ENDPOINT" s3api get-object --bucket "$REMORA_TARGET_BUCKET" --key "$key" /tmp/output >/dev/null
|
||||
IFS= read -r output </tmp/output
|
||||
test "$output" = passed
|
||||
envFrom:
|
||||
- configMapRef: {name: @@PROFILE_NAME@@}
|
||||
resources:
|
||||
requests: {cpu: 25m, memory: 64Mi}
|
||||
limits: {cpu: "1", memory: 256Mi}
|
||||
- name: secret-canary
|
||||
image: @@VAULT_IMAGE@@
|
||||
imagePullPolicy: Never
|
||||
command: [/bin/sh, -ec]
|
||||
args:
|
||||
- |
|
||||
export VAULT_ADDR="$REMORA_VAULT_ADDR"
|
||||
export VAULT_TOKEN="$REMORA_VAULT_TOKEN"
|
||||
vault kv put "$REMORA_VAULT_PATH" value=passed >/dev/null
|
||||
test "$(vault kv get -field=value "$REMORA_VAULT_PATH")" = passed
|
||||
envFrom:
|
||||
- configMapRef: {name: @@PROFILE_NAME@@}
|
||||
resources:
|
||||
requests: {cpu: 25m, memory: 64Mi}
|
||||
limits: {cpu: "1", memory: 256Mi}
|
||||
containers:
|
||||
- name: tests
|
||||
image: @@TEST_IMAGE@@
|
||||
imagePullPolicy: Never
|
||||
envFrom:
|
||||
- configMapRef: {name: @@PROFILE_NAME@@}
|
||||
volumeMounts:
|
||||
- {name: fixture-profile, mountPath: /run/remora-fixture, readOnly: true}
|
||||
resources:
|
||||
requests: {cpu: 100m, memory: 64Mi}
|
||||
limits: {cpu: "2", memory: 512Mi}
|
||||
volumes:
|
||||
- name: fixture-profile
|
||||
configMap:
|
||||
name: @@PROFILE_NAME@@-file
|
||||
items:
|
||||
- {key: profile.env, path: profile.env}
|
||||
50
tests/kind/sample/run.sh
Executable file
50
tests/kind/sample/run.sh
Executable file
|
|
@ -0,0 +1,50 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "$0")/../../.." && pwd)"
|
||||
source "$ROOT/tests/kind/fixture/lib.sh"
|
||||
|
||||
USER_KUBECONFIG_BEFORE="$(user_kubeconfig_digest)"
|
||||
SUCCEEDED=false
|
||||
OWNS_FIXTURE=false
|
||||
|
||||
cleanup() {
|
||||
local status=$?
|
||||
trap - EXIT INT TERM
|
||||
if [[ "${REMORA_TESTBED_RETAIN:-0}" = 1 ]] && [[ "$SUCCEEDED" != true ]]; then
|
||||
printf 'retained kubeconfig: %s\n' "$KUBECONFIG_PATH"
|
||||
printf 'retained context: %s\n' "$CONTEXT"
|
||||
exit "$status"
|
||||
fi
|
||||
if [[ "$OWNS_FIXTURE" = true ]]; then
|
||||
destroy_fixture || status=1
|
||||
fi
|
||||
if [[ "$(user_kubeconfig_digest)" != "$USER_KUBECONFIG_BEFORE" ]]; then
|
||||
printf 'user kubeconfig changed unexpectedly\n' >&2
|
||||
status=1
|
||||
fi
|
||||
exit "$status"
|
||||
}
|
||||
|
||||
trap cleanup EXIT
|
||||
trap 'exit 130' INT
|
||||
trap 'exit 143' TERM
|
||||
|
||||
acquire_fixture_lock
|
||||
REMORA_REAL_NERDCTL="$(command -v nerdctl)"
|
||||
export REMORA_REAL_NERDCTL
|
||||
"$REMORA_REAL_NERDCTL" --namespace default build \
|
||||
--file "$ROOT/Dockerfile.test" \
|
||||
--target kind-sample-runner \
|
||||
--tag remora-kind-sample:local \
|
||||
"$ROOT"
|
||||
OWNS_FIXTURE=true
|
||||
setup_fixture all
|
||||
load_local_image remora-kind-sample:local
|
||||
run_job_matrix \
|
||||
fixture-consumer-sample \
|
||||
"$TESTBED/sample/job.yaml.in" \
|
||||
remora-kind-sample:local \
|
||||
all
|
||||
SUCCEEDED=true
|
||||
printf 'sample package test Job passed\n'
|
||||
Loading…
Reference in a new issue