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

Enhancement: Use Sandbox for Testing #363

Merged
merged 18 commits into from
Aug 22, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
14 changes: 14 additions & 0 deletions .test-env
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Configs for testing repo download:
SDK_TESTING_URL="https://github.com/algorand/algorand-sdk-testing"
SDK_TESTING_BRANCH="trim-indexer"
tzaffi marked this conversation as resolved.
Show resolved Hide resolved
SDK_TESTING_HARNESS="test-harness"
tzaffi marked this conversation as resolved.
Show resolved Hide resolved

VERBOSE_HARNESS=1

# WARNING: If set to 1, new features will be LOST when downloading the test harness.
# REGARDLESS: modified features are ALWAYS overwritten.
REMOVE_LOCAL_FEATURES=0

# WARNING: Be careful when turning on the next variable.
# In that case you'll need to provide all variables expected by `algorand-sdk-testing`'s `.env`
OVERWRITE_TESTING_ENVIRONMENT=0
tzaffi marked this conversation as resolved.
Show resolved Hide resolved
22 changes: 16 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
UNITS = "@unit.offline or @unit.algod or @unit.indexer or @unit.rekey or @unit.indexer.rekey or @unit.transactions or @unit.transactions.keyreg or @unit.responses or @unit.applications or @unit.dryrun or @unit.tealsign or @unit.responses.messagepack or @unit.responses.231 or @unit.responses.messagepack.231 or @unit.feetest or @unit.indexer.logs or @unit.abijson or @unit.abijson.byname or @unit.atomic_transaction_composer or @unit.transactions.payment or @unit.responses.unlimited_assets or @unit.algod.ledger_refactoring or @unit.indexer.ledger_refactoring or @unit.dryrun.trace.application or @unit.sourcemap"
unit:
mvn test -Dcucumber.filter.tags="@unit.offline or @unit.algod or @unit.indexer or @unit.rekey or @unit.indexer.rekey or @unit.transactions or @unit.transactions.keyreg or @unit.responses or @unit.applications or @unit.dryrun or @unit.tealsign or @unit.responses.messagepack or @unit.responses.231 or @unit.responses.messagepack.231 or @unit.feetest or @unit.indexer.logs or @unit.abijson or @unit.abijson.byname or @unit.atomic_transaction_composer or @unit.transactions.payment or @unit.responses.unlimited_assets or @unit.algod.ledger_refactoring or @unit.indexer.ledger_refactoring or @unit.dryrun.trace.application or @unit.sourcemap"
mvn test -Dcucumber.filter.tags=$(UNITS)

INTEGRATIONS = "@algod or @assets or @auction or @kmd or @send or @send.keyregtxn or @indexer or @rekey_v1 or @applications.verified or @applications or @compile or @dryrun or @indexer.applications or @indexer.231 or @abi or @c2c or @compile.sourcemap"
tzaffi marked this conversation as resolved.
Show resolved Hide resolved
integration:
mvn test \
-Dtest=com.algorand.algosdk.integration.RunCucumberIntegrationTest \
-Dcucumber.filter.tags="@algod or @assets or @auction or @kmd or @send or @send.keyregtxn or @indexer or @rekey_v1 or @applications.verified or @applications or @compile or @dryrun or @indexer.applications or @indexer.231 or @abi or @c2c or @compile.sourcemap"
mvn test -Dtest=com.algorand.algosdk.integration.RunCucumberIntegrationTest -Dcucumber.filter.tags=$(INTEGRATIONS)

docker-test:
./run_integration_tests.sh
harness:
./test-harness.sh

docker-javasdk-build:
# Build SDK testing environment
docker build -t java-sdk-testing .

docker-javasdk-run:
# Launch SDK testing
docker run -it --network host java-sdk-testing:latest

docker-test: harness docker-javasdk-build docker-javasdk-run
82 changes: 0 additions & 82 deletions run_integration_tests.sh

This file was deleted.

73 changes: 73 additions & 0 deletions test-harness.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/usr/bin/env bash
set -euo pipefail

START=$(date "+%s")

THIS=$(basename "$0")
ENV_FILE=".test-env"
TEST_DIR="src/test/resources/com/algorand/algosdk"
TEST_RESOURCES_DIR="src/test/resources/"

set -a
source "$ENV_FILE"
set +a

rootdir=$(dirname "$0")
pushd "$rootdir"

## Reset test harness
if [ -d "$SDK_TESTING_HARNESS" ]; then
pushd "$SDK_TESTING_HARNESS"
./scripts/down.sh
popd
rm -rf "$SDK_TESTING_HARNESS"
else
echo "$THIS: directory $SDK_TESTING_HARNESS does not exist - NOOP"
fi

git clone --depth 1 --single-branch --branch "$SDK_TESTING_BRANCH" "$SDK_TESTING_URL" "$SDK_TESTING_HARNESS"


if [[ $OVERWRITE_TESTING_ENVIRONMENT == 1 ]]; then
echo "$THIS: OVERWRITE replaced $SDK_TESTING_HARNESS/.env with $ENV_FILE:"
cp "$ENV_FILE" "$SDK_TESTING_HARNESS"/.env
fi

## Copy feature files into the project resources
if [[ $REMOVE_LOCAL_FEATURES == 1 ]]; then
echo "$THIS: OVERWRITE wipes clean $TEST_DIR/features"
if [[ $VERBOSE_HARNESS == 1 ]]; then
( tree $TEST_DIR/integration && tree $TEST_DIR/unit && tree $TEST_RESOURCES_DIR && echo "$THIS: see the previous for files deleted" ) || true
fi
rm -rf $TEST_DIR/integration
rm -rf $TEST_DIR/unit
rm -rf $TEST_RESOURCES_DIR
fi
mkdir -p $TEST_DIR/integration
mkdir -p $TEST_DIR/unit
mkdir -p $TEST_RESOURCES_DIR

# The Java implementation of these is too tightly coupled with the
# integration tests, so add them to the integration tests instead.
mv "$SDK_TESTING_HARNESS"/features/unit/offline.feature test-harness/features/integration/
tzaffi marked this conversation as resolved.
Show resolved Hide resolved

cp -r "$SDK_TESTING_HARNESS"/features/integration/* $TEST_DIR/integration
cp -r "$SDK_TESTING_HARNESS"/features/unit/* $TEST_DIR/unit
cp -r "$SDK_TESTING_HARNESS"/features/resources/* $TEST_RESOURCES_DIR

if [[ $VERBOSE_HARNESS == 1 ]]; then
( tree $TEST_DIR/integration && tree $TEST_DIR/unit && tree $TEST_RESOURCES_DIR && echo "$THIS: see the previous for files copied over" ) || true
fi
echo "$THIS: seconds it took to get to end of cloning and copying: $(($(date "+%s") - START))s"

## Start test harness environment
pushd "$SDK_TESTING_HARNESS"
./scripts/up.sh
popd
echo "$THIS: seconds it took to finish testing sdk's up.sh: $(($(date "+%s") - START))s"
echo ""
echo "--------------------------------------------------------------------------------"
echo "|"
echo "| To run sandbox commands, cd into $SDK_TESTING_HARNESS/.sandbox "
echo "|"
echo "--------------------------------------------------------------------------------"