mirror of
https://github.com/gomods/athens
synced 2026-02-03 12:10:32 +00:00
* Added new cataloger interface * Implementing catalog protocol * Propagated to protocol and over * First round of fixes * S3 almost ready, need to be tested * Going on with testing s3 * Better testing with s3 * Simplified catalog tests * Preparing gcp tests to access a gcp instance * Fixing initialization errors * Removed some prints * Gcp ready, to be tested * Gcp working * Aligned bucket mock to catalog method * Switched res payload to json * Added catalog method to all storage instances * Added catalog method to unsupported storages * Fixed with pool test * Restored tests * Fixed gcp constructor * Implemented catalog for fs * Removed trace * E2e tests, fixed fs * Fixed module name return value * Added cataloger method to azure storage * Added docs * Changed pagesize parameter name * Fixed gofmt error * Added json tags to result. Fixed lint warning * Removed extra line * Changed not implemented error to http.KindNotImplemented * Checking for inequality on results * Lower-cased json keys * Added cleaning of path separator * Fixed review comments * Add catalog endpoint for mongo * Add omitempty to ID * Fix catalog tests * update for next token * fix e2e * Make query readable * Fix language and e2e script * remove new line
70 lines
2.0 KiB
Bash
Executable File
70 lines
2.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# test_e2e.sh
|
|
# Execute end-to-end (e2e) tests to verify that everything is working right
|
|
# from the end user perpsective
|
|
set -xeuo pipefail
|
|
|
|
REPO_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )/.."
|
|
|
|
OGOPATH=${GOPATH:-}
|
|
OGO111MODULE=${GO111MODULE:-}
|
|
OGOPROXY=${GOPROXY:-}
|
|
export GO_BINARY_PATH=${GO_BINARY_PATH:-go}
|
|
TMPDIR=$(mktemp -d)
|
|
export GOPATH=$TMPDIR
|
|
GOMOD_CACHE=$TMPDIR/pkg/mod
|
|
export PATH=${REPO_DIR}/bin:${PATH}
|
|
|
|
clearGoModCache () {
|
|
chmod -R 0770 ${GOMOD_CACHE}
|
|
rm -fr ${GOMOD_CACHE}
|
|
}
|
|
|
|
teardown () {
|
|
# Cleanup after our tests
|
|
[[ -z "${OGOPATH}" ]] && unset GOPATH || export GOPATH=$OGOPATH
|
|
[[ -z "${OGO111MODULE}" ]] && unset GO111MODULE || export GO111MODULE=$OGO111MODULE
|
|
[[ -z "${OGOPROXY}" ]] && unset GOPROXY || export GOPROXY=$OGOPROXY
|
|
|
|
clearGoModCache
|
|
pkill athens-proxy || true
|
|
rm $REPO_DIR/cmd/proxy/athens-proxy || true
|
|
rm -fr ${TMPDIR}
|
|
popd 2> /dev/null || true
|
|
}
|
|
trap teardown EXIT
|
|
|
|
export GO111MODULE=on
|
|
|
|
# Start the proxy in the background and wait for it to be ready
|
|
cd $REPO_DIR/cmd/proxy
|
|
pkill athens-proxy || true # cleanup proxy if it is running
|
|
go build -mod=vendor -o athens-proxy && ./athens-proxy &
|
|
while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:3000/readyz)" != "200" ]]; do sleep 1; done
|
|
|
|
# Clone our test repo
|
|
TEST_SOURCE=${TMPDIR}/happy-path
|
|
rm -fr ${TEST_SOURCE} 2> /dev/null || true
|
|
git clone https://github.com/athens-artifacts/happy-path.git ${TEST_SOURCE}
|
|
pushd ${TEST_SOURCE}
|
|
|
|
# Make sure that our test repo works without the GOPROXY first
|
|
unset GOPROXY
|
|
$GO_BINARY_PATH run .
|
|
|
|
# clear cache so that go uses the proxy
|
|
clearGoModCache
|
|
|
|
# Verify that the test works against the proxy
|
|
export GOPROXY=http://localhost:3000
|
|
$GO_BINARY_PATH run .
|
|
|
|
CATALOG_RES=$(curl localhost:3000/catalog)
|
|
CATALOG_EXPECTED='{"modules":[{"module":"github.com/athens-artifacts/no-tags","version":"v0.0.0-20180803171426-1a540c5d67ab"}]}'
|
|
|
|
if [[ "$CATALOG_RES" != "$CATALOG_EXPECTED" ]]; then
|
|
echo ERROR: catalog endpoint failed
|
|
exit 1 # terminate and indicate error
|
|
fi
|