Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added changes to make local e2e test work/ update doc #2036

Merged
merged 4 commits into from
Apr 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK you can also use an existing cluster and just run make test-e2e if you let the CLUSTER variable point to it. Maybe we should also document this, because sometimes you might want to use an existing one.

- 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