This short guide shows you how to setup the e2e tests on your local machine. We won't go into detail on how all of the e2e stuff works, as this is covered in great detail in the osde2e documentation itelf. Instead, i'll just focus on the steps I took to get them running locally, without too many tangents.
- Fork and clone the osde2e test repo: gh.com/openshift/osde2e
- Make sure you have an osd cluster ready
golang
version 1.16+
We will need to create a couple of helper files to get the tests to run.
Find the Name of the test you want to run. I did this by looking at the go
file associated with the specific e2e test. For example, looking at the osd-metrics-operator.go file, you can find the test name right at the top:
...
"github.com/openshift/osde2e/pkg/common/alert"
"github.com/openshift/osde2e/pkg/common/helper"
)
var (
osdMetricsExporterTestPrefix = "[Suite: operators] [OSD] OSD Metrics Exporter" <<<<<<
osdMetricsExporterBasicTest = osdMetricsExporterTestPrefix + " Basic Test"
)
func init() {
...
In this case, the test name is [Suite: operators] [OSD] OSD Metrics Exporter
.
We will set up a new e2e test config file to specify that only the test identified earlier should be run. The configuration file needs to be created in the config
subfolder of the osde2e test repo ( but don't commit or push the config file ). Run the following to create the file and name it localconfig.yaml
cd $OSDE2E_HOME/config
cat << EOF > ./localconfig.yaml
tests:
testsToRun:
- '\[Suite: operators\] \[OSD\] OSD Metrics Exporter'
Replace the string under testsToRun
with the Name of the test you've identified earlier.
You need to Escape any
[]
in the Test name with backslashes\
!
We will be using the following script to re-build and run the osde2e test binary:
#!/bin/bash
if [ -z "$CLUSTER_ID" ]; then
echo -e "\$CLUSTER_ID needs to be set"
echo -e "exiting..."
exit 1
fi
echo -e "Running tests against $CLUSTER_ID"
export OSD_ENV="stage"
export CLOUD_PROVIDER_ID="aws"
export CLOUD_PROVIDER_REGION="us-east-1"
export DESTROY_CLUSTER="false"
export MUST_GATHER="false"
export HIBERNATE_AFTER_USE="false"
OCM_TOKEN="YOUR_TOKEN" # insert your OCM token here
export OCM_TOKEN
export CLUSTER_ID
make build
./out/osde2e test --configs "localconfig"
Double check the variables that are defined in the script. Especially make sure that you either set the OCM_TOKEN
in the script itself, or remove it from the script and export it separately before running the script. Save the file as testLocal.sh
in the root of the git repo.
When done with the steps, you can go ahead and run the script. Make sure that you have exported the ID of the cluster you want to run the e2e tests in:
chmod +x ./testlocal.sh
export CLUSTER_ID=<internal-cluster-id>
./testlocal.sh