*: rename test scripts and update test pod readme (#1754)

This commit is contained in:
Haseeb Tariq 2017-12-11 15:49:41 -08:00 коммит произвёл Hongchao Deng
Родитель 8ae62a60a9
Коммит 44e9df7807
5 изменённых файлов: 38 добавлений и 28 удалений

Просмотреть файл

@ -5,7 +5,6 @@ set -o nounset
set -o pipefail
: ${TEST_IMAGE:?"Need to set TEST_IMAGE"}
: ${OPERATOR_IMAGE:?"Need to set OPERATOR_IMAGE"}
if ! which docker > /dev/null; then
echo "docker needs to be installed"

Просмотреть файл

@ -15,19 +15,13 @@ kubectl version
: ${TEST_S3_BUCKET:?"Need to set TEST_S3_BUCKET"}
: ${TEST_AWS_SECRET:?"Need to set TEST_AWS_SECRET"}
# Set envs for build
GIT_VERSION=$(git rev-parse HEAD)
export OPERATOR_IMAGE=${OPERATOR_IMAGE:-"gcr.io/coreos-k8s-scale-testing/etcd-operator:${GIT_VERSION}"}
export TEST_IMAGE=${TEST_IMAGE:-"gcr.io/coreos-k8s-scale-testing/etcd-operator-e2e:${GIT_VERSION}"}
echo "TEST_NAMESPACE: ${TEST_NAMESPACE}"
echo "OPERATOR_IMAGE: ${OPERATOR_IMAGE}"
echo "TEST_IMAGE: ${TEST_IMAGE}"
hack/ci/get_dep
BUILD_IMAGE=${BUILD_IMAGE:-true}
if [[ ${BUILD_IMAGE} == "true" ]]; then
OPERATOR_IMAGE=${OPERATOR_IMAGE:-"gcr.io/coreos-k8s-scale-testing/etcd-operator:${GIT_VERSION}"}
gcloud docker -a
hack/build/build
IMAGE=${OPERATOR_IMAGE} hack/build/docker_push
@ -35,10 +29,14 @@ fi
BUILD_E2E=${BUILD_E2E:-true}
if [[ ${BUILD_E2E} == "true" ]]; then
TEST_IMAGE=${TEST_IMAGE:-"gcr.io/coreos-k8s-scale-testing/etcd-operator-e2e:${GIT_VERSION}"}
gcloud docker -a
hack/build/e2e/docker_push
TEST_IMAGE=${TEST_IMAGE} hack/build/e2e/docker_push
fi
echo "TEST_NAMESPACE: ${TEST_NAMESPACE}"
echo "OPERATOR_IMAGE: ${OPERATOR_IMAGE}"
echo "TEST_IMAGE: ${TEST_IMAGE}"
# Generate test-pod spec
export TEST_POD_SPEC=${PWD}/test/pod/test-pod-spec.yaml
@ -46,16 +44,13 @@ export POD_NAME=${POD_NAME:-"e2e-testing"}
export E2E_TEST_SELECTOR=${E2E_TEST_SELECTOR:-""}
sed -e "s|<POD_NAME>|${POD_NAME}|g" \
-e "s|<TEST_IMAGE>|${TEST_IMAGE}|g" \
-e "s|<TEST_IMAGE>|${TEST_IMAGE}|g" \
-e "s|<PASSES>|${PASSES}|g" \
-e "s|<OPERATOR_IMAGE>|${OPERATOR_IMAGE}|g" \
-e "s|<E2E_TEST_SELECTOR>|${E2E_TEST_SELECTOR}|g" \
-e "s|<TEST_S3_BUCKET>|${TEST_S3_BUCKET}|g" \
-e "s|<TEST_AWS_SECRET>|${TEST_AWS_SECRET}|g" \
test/pod/test-pod.yaml > ${TEST_POD_SPEC}
test/pod/test-pod-templ.yaml > ${TEST_POD_SPEC}
# Run test-pod
PASSES=${PASSES} \
TEST_S3_BUCKET=${TEST_S3_BUCKET} \
TEST_AWS_SECRET=${TEST_AWS_SECRET} \
test/pod/run-test-pod
test/pod/run-test-pod

Просмотреть файл

@ -1,6 +1,6 @@
# Running Containarized Tests
The scripts at `test/pod` can be used to package and run the e2e tests inside a [test-pod](./test-pod.yaml) on a k8s cluster.
The scripts at `test/pod` can be used to package and run the e2e tests inside a test-pod on a k8s cluster.
## Create the AWS secret
@ -11,24 +11,42 @@ The e2e tests need access to an S3 bucket for testing. Create a secret containin
The following should build and push the test-pod image to some specified repository:
```sh
TEST_IMAGE=gcr.io/coreos-k8s-scale-testing/etcd-operator-e2e test/pod/build
TEST_IMAGE=gcr.io/coreos-k8s-scale-testing/etcd-operator-e2e test/pod/docker_push
```
## Run the test-pod
The `run-test-pod` script sets up RBAC for the namespace, and necessary environment variables for the test-pod before running it:
## Generate the test-pod spec file
The [test-pod-tmpl.yaml](./test-pod-tmpl.yaml) can be used to define the test-pod spec with the necessary values for the following environment variables:
- `TEST_NAMESPACE` is the namespace where the test-pod and e2e tests will run.
- `OPERATOR_IMAGE` is the etcd-operator image used for testing
- `TEST_S3_BUCKET` is the S3 bucket name used for testing
- `TEST_AWS_SECRET` is the secret name containing the aws credentials/config files.
- `E2E_TEST_SELECTOR` is used to select which tests to run. Leave empty to run all tests.
- `PASSES` are the test passes to run (e2e, e2eslow, e2esh). See [hack/test](../../hack/test)
```sh
TEST_IMAGE=gcr.io/coreos-k8s-scale-testing/etcd-operator-e2e \
TEST_NAMESPACE=e2e \
OPERATOR_IMAGE=quay.io/coreos/etcd-operator:dev \
TEST_S3_BUCKET=my-bucket \
TEST_AWS_SECRET=aws-secret \
test/pod/run-test-pod
sed -e "s|<POD_NAME>|e2e-testing|g" \
-e "s|<TEST_IMAGE>|gcr.io/coreos-k8s-scale-testing/etcd-operator-e2e|g" \
-e "s|<PASSES>|e2eslow|g" \
-e "s|<OPERATOR_IMAGE>|quay.io/coreos/etcd-operator:dev|g" \
-e "s|<E2E_TEST_SELECTOR>|CreateCluster|g" \
-e "s|<TEST_S3_BUCKET>|my-bucket|g" \
-e "s|<TEST_AWS_SECRET>|aws-secret|g" \
test/pod/test-pod-templ.yaml > test-pod-spec.yaml
```
## Run the test-pod
The `run-test-pod` script sets up RBAC for the namespace, runs the logcollector and then the test-pod. The script waits until the test-pod has run to completion.
```sh
TEST_NAMESPACE=e2e \
POD_NAME=testing-e2e \
TEST_POD_SPEC=${PWD}/test-pod-spec.yaml \
KUBECONFIG=/path/to/kubeconfig \
test/pod/run-test-pod
```
The logfiles for all the pods in the test namespace will be saved at `${CWD}/_output/logs`.
[setup-aws-secret]:../../doc/user/walkthrough/backup-operator.md#setup-aws-secret

Просмотреть файл

@ -1,7 +1,5 @@
#!/usr/bin/env bash
# This script runs the test-pod with the specified TEST_IMAGE and necessary envs for e2e tests
set -o errexit
set -o nounset
set -o pipefail

Просмотреть файл