-
Notifications
You must be signed in to change notification settings - Fork 106
Testing
First, you need a running instance of the JFrog Artifactory.
You can ask for an instance to test against it as part of your PR. Alternatively, you can run the file scripts/run-artifactory.sh.
The script requires a valid license of a supported type, license should be saved in the file called artifactory.lic
in the same directory as a script.
With the script you can start one or two Artifactory instances using docker compose.
The license is not supplied, but a 30 day trial license can be freely obtained and will allow local development. Make sure the license saved as a multi line text file.
Currently, acceptance tests require an access key and don't support basic authentication or an API key. To generate an access key, please refer to the official documentation
Then, you have to set some environment variables as this is how the acceptance tests pick up their config.
ARTIFACTORY_URL=http://localhost:8082
ARTIFACTORY_USERNAME=admin
ARTIFACTORY_ACCESS_TOKEN=<your_access_token>
TF_ACC=true
ARTIFACTORY_USERNAME
is not used in authentication, but used in several tests, related to replication functionality.
It should be hardcoded to admin
, because it's a default user created in the Artifactory instance from the start.
A crucial env var to set is TF_ACC=true
- you can literally set TF_ACC
to anything you want, so long as it's set. The acceptance tests use terraform testing libraries that, if this flag isn't set, will skip all tests.
You can then run the tests as
$ go test -v ./pkg/...
Or
$ make acceptance
DO NOT remove the -v
- terraform testing needs this. This will recursively run all tests, including acceptance tests.
To execute acceptance tests for federated repo resource, we need:
- 2 Artifactory instances, configured with Circle-of-Trust
- Set environment variables
ARTIFACTORY_URL_2
to enable the acceptance tests that utilize both Artifactory instances
The scripts/run-artifactory.sh starts two Artifactory instances for testing using the file scripts/docker-compose.yml.
artifactory-1
is on the usual 8080/8081/8082 ports while artifactory-2
is on 9080/9081/9082
Set the env var to the second Artifactory instance URL. This is the URL that will be accessible from artifactory-1
container (not the URL from the Docker host):
$ export ARTIFACTORY_URL_2=http://artifactory-2:8081
Run all the acceptance tests as usual
$ make acceptance
Or run only the acceptance tests for Federated repos:
$ make acceptance_federated