Test
Hangar project source code includes Unit tests & Validation tests.
Validation test
- Test the output of version, help message, etc.
- Run mirror & mirror-validate test first, mirror container images from public registry server to the Harbor private regitry server.
- Then run tests for save, load, load-validate, sync, compress, decompress etc commands.
Prepare
- Clone the source code and build the executable binary:
$ git clone https://github.com/cnrancher/hangar && cd hangar
$ make build - Prepare a Harbor V2 Registry server.
- Setup environment variables.
export SOURCE_REGISTRY="" # set to empty string
export SOURCE_USERNAME="" # docker hub username (optional)
export SOURCE_PASSWORD="" # docker hub password (optional)
export DEST_REGISTRY="" # harbor registry url
export DEST_USERNAME="" # harbor username
export DEST_PASSWORD="" # harbor passwordIf the Harbor v2 uses HTTP or insecure TLS certificate, set
export TEST_SKIP_TLS="true"
to skip tls verify.
Run tests in container
Run tests of all commands in container:
$ make test_all
Besides, you can run make test_[COMMAND_NAME]
to test the command.
Need to run
make test_mirror
before running tests of other commands.
# mirror | mirror-validate command
make test_mirror
# save command
make test_save
# load | load-validate command
make test_load
# sync | compress | decompress command
make test_sync
# Test other commands...
make test_[COMMAND_NAME]
Unit test
Run unit tests in container:
$ make test