Skip to content

Commit

Permalink
added changes to make local e2e test work/ update doc (#2036)
Browse files Browse the repository at this point in the history
* added changes to make local e2e test work/ update doc
  • Loading branch information
Jeremy Facchetti authored Apr 7, 2022
1 parent 5afa1b7 commit 4dbe573
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
23 changes: 20 additions & 3 deletions docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,14 @@ For faster feedback, you may want to set up [golanglint-ci's editor integration]
E2e tests can be run in CI with the `/azp run e2e` command in your GitHub PR.

E2e tests can also be run locally as follows:
- Deploy or use an existing cosmos database
- Run the RP
- Make sure that you meet the requirements from [Prepare the database and run the rp](./deploy-development-rp.md) (do not create the database yet)
- Source the [helper script](../hack/e2e/run-rp-and-e2e.sh) to set the proper ENV variables. If you run the tests locally, run `export LOCAL_E2E=true` env before sourcing the helper file.
- Run the rp
- Validate the RP is running properly by hitting the `/healthz` route
- Register a subscription where to run the e2e
- Create an openshift cluster
- Run the `make test-e2e` target
- Delete the openshift cluster, if applicable
- Delete the cosmos database, if applicable

You can also modify the flags passed to the e2e.test run by setting the E2E_FLAGS environment variable before running `make test-e2e`.
Expand All @@ -48,15 +51,23 @@ These steps can be acheived using commands below. Look at the [e2e helper
file](../hack/e2e/run-rp-and-e2e.sh) to understand each of the bash functions
below.

### Run a specific test

End to end tests are run using ginkgo. You can run subsets of tests or ignore some tests by following the [ginkgo documentation](https://onsi.github.io/ginkgo/#filtering-specs)



```bash
# source your environment file
. ./secrets/env

# set the LOCAL_E2E env if you are testing locally
export LOCAL_E2E="true"

# source the e2e helper file
. ./hack/e2e/run-rp-and-e2e.sh

# Deploy a new DB
# Deploy a new DB if it does not exist yet
deploy_e2e_db

# build the rp binary
Expand All @@ -68,12 +79,18 @@ run_rp
# validate if the RP is ready to receive requests
validate_rp_running

# create an openshift cluster if it does not exist yet
go run ./hack/cluster create

# Register the sub you are using to run e2e
register_sub

# Run e2e
make test-e2e

# delete the openshift cluster if applicable
go run ./hack/cluster delete

# Stop the local RP
kill_rp

Expand Down
20 changes: 18 additions & 2 deletions hack/e2e/run-rp-and-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,24 @@ clean_e2e_db(){

# TODO: CLUSTER and is also recalculated in multiple places
# in the billing pipelines :-(
export CLUSTER="v4-e2e-V$BUILD_BUILDID-$LOCATION"
export DATABASE_NAME="v4-e2e-V$BUILD_BUILDID-$LOCATION"


# if LOCAL_E2E is set, set the value with the local test names
# If it it not set, it defaults to the build ID
if [ -z "${LOCAL_E2E}" ] ; then
export CLUSTER="v4-e2e-V$BUILD_BUILDID-$LOCATION"
export DATABASE_NAME="v4-e2e-V$BUILD_BUILDID-$LOCATION"
fi

if [ -z "${CLUSTER}" ] ; then
echo "CLUSTER is not set , aborting"
exit 1
fi

if [ -z "${DATABASE_NAME}" ] ; then
echo "DATABASE_NAME is not set , aborting"
exit 1
fi

echo "######################################"
echo "##### ARO V4 E2e helper sourced ######"
Expand Down

0 comments on commit 4dbe573

Please sign in to comment.