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: Trim the indexer images and use the sandbox instead of custom dockers #367

Merged
merged 65 commits into from
Aug 22, 2022
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
2af8a71
time printout
Aug 3, 2022
e47317e
remove the integration indexers
Aug 4, 2022
acf8746
"no colors anymore I want them to turn..."
Aug 4, 2022
4fc4137
bootstrap till the point of running tests
Aug 5, 2022
96e121d
seems to mostly pass now that got the indexer v1 buck in the build
Aug 6, 2022
0a4ca51
shell scripts are so fragile
Aug 6, 2022
9e09c62
simplify and refactor into Makefile
Aug 6, 2022
800e191
bug in Makefile
Aug 6, 2022
cd52aba
bug in Makefile
Aug 6, 2022
558a042
docker ps in makefile
Aug 6, 2022
d04e34e
try docker ps gin
Aug 6, 2022
3679626
expose indxer v1 and sandbox configuration
Aug 7, 2022
32e7317
Update test-harness.sh
tzaffi Aug 7, 2022
1f06edd
Update Makefile
tzaffi Aug 7, 2022
d35731f
no cat or any other animals required
Aug 7, 2022
195b28f
Merge branch 'trim-indexer' of github.com:algorand/py-algorand-sdk in…
Aug 7, 2022
a6e3cbc
merged
Aug 7, 2022
06119ef
revert
tzaffi Aug 7, 2022
40c3352
revert
Aug 7, 2022
b3cfc66
python --version sanity check
Aug 7, 2022
85afa1e
bring down dockers BEFORE destroying their docker-compose + misc
Aug 8, 2022
149646f
Update .test-env
tzaffi Aug 8, 2022
b898570
Update .test-env
tzaffi Aug 8, 2022
1341f90
stale log
Aug 8, 2022
1cfb783
Update .test-env
tzaffi Aug 9, 2022
c1d56e4
Update .test-env
tzaffi Aug 9, 2022
34b3dc0
better end of script verbiage
Aug 9, 2022
23c723e
per CR suggestion: `rm -rf` the features
Aug 9, 2022
dda5012
trigger build with verbose
Aug 9, 2022
707b439
comment in .env
Aug 10, 2022
5dab777
try 30,000 rounds
Aug 10, 2022
9ca1ad3
don't allow configuring TYPE in the Makefile
Aug 11, 2022
6e9c7c3
don't allow configuring TYPE in the Makefile
Aug 11, 2022
f8b8092
non-archival node
Aug 12, 2022
a7465e5
remove and modify v1 steps
Aug 12, 2022
9a5c87f
remove "I get transactions by address and date" for @asset feature
Aug 12, 2022
ba76644
commentary
Aug 12, 2022
bfe0133
cleanup the cucumber tags
Aug 12, 2022
c9a1f44
sandbox branch configurable-ports ---> master
Aug 12, 2022
0878b23
vet against the bugfix-sourcing-env-can-break-aliases branch in CI
Aug 12, 2022
b0abecf
revert sandbox branch to master after the bugfix was merged
Aug 12, 2022
a38d750
revert
Aug 15, 2022
0548843
better TODO per CR comments
Aug 15, 2022
f66569d
Update test-harness.sh
tzaffi Aug 16, 2022
86bffc5
Update Makefile
tzaffi Aug 16, 2022
c646ea0
tempoary: VERBOSE_HARNESS=0 in response to upstream change. TODO: rem…
Aug 16, 2022
0ab667d
Merge branch 'trim-indexer' of github.com:algorand/py-algorand-sdk in…
Aug 16, 2022
3e3145a
don't overwrite incoming test-harness/.env
Aug 16, 2022
c702868
per CR suggestion - no py version in .test-env
Aug 16, 2022
0214958
make test-harness.sh more compliant
Aug 16, 2022
97ffb86
Update .test-env
tzaffi Aug 16, 2022
748817e
remove more indexer.features steps
Aug 17, 2022
a6a2590
Update test-harness.sh
tzaffi Aug 17, 2022
aeea8e8
Merge branch 'trim-indexer' of github.com:algorand/py-algorand-sdk in…
Aug 17, 2022
e26460f
don't default to deleting local features, and introduce verbose mode
Aug 17, 2022
70dada9
variable for destination tests directory
Aug 17, 2022
46387c1
separate cucumber tags into their own files
Aug 18, 2022
b9593bf
quotes
Aug 18, 2022
ea50a0a
Apply suggestions from code review
tzaffi Aug 19, 2022
121927e
Merge remote-tracking branch 'origin' into trim-indexer
Aug 19, 2022
309a803
display command for fuzzy matching
Aug 19, 2022
9b8a769
lintings
Aug 21, 2022
0ca7e91
Unused Steps Analysis cleanup
Aug 21, 2022
39d107a
unused import
Aug 21, 2022
11dbdc8
Update .test-env
tzaffi Aug 22, 2022
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
42 changes: 42 additions & 0 deletions .test-env
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Configs for local python sdk dockerizing:
tzaffi marked this conversation as resolved.
Show resolved Hide resolved
SKIP_PYTHON_SDK_DOCKER=0
tzaffi marked this conversation as resolved.
Show resolved Hide resolved
PYTHON_VERSION=${PYTHON_VERSION:-3.10}
tzaffi marked this conversation as resolved.
Show resolved Hide resolved

# Configs for testing repo download:
SDK_TESTING_URL="https://github.com/algorand/algorand-sdk-testing"
SDK_TESTING_BRANCH="trim-indexer"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: revert back to master?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^^^ TODO: REVERT TO master BEFORE MERGING

tzaffi marked this conversation as resolved.
Show resolved Hide resolved
SDK_TESTING_HARNESS="test-harness"

# Used to determine sandbox build type:
TYPE=${TYPE:-source} # OR "channel"
tzaffi marked this conversation as resolved.
Show resolved Hide resolved

# Used when TYPE==channel
ALGOD_CHANNEL="nightly"

# Used when TYPE==source
ALGOD_URL="https://github.com/algorand/go-algorand"
ALGOD_BRANCH="feature/avm-box"
tzaffi marked this conversation as resolved.
Show resolved Hide resolved
ALGOD_SHA=""

# Used regardless of TYPE
NETWORK_TEMPLATE="images/algod/DevModeNetwork.json"
NETWORK_NUM_ROUNDS=3000
tzaffi marked this conversation as resolved.
Show resolved Hide resolved
INDEXER_URL="https://github.com/algorand/indexer"
NODE_ARCHIVAL="True"
NODE_V1_INDEXER="True"
tzaffi marked this conversation as resolved.
Show resolved Hide resolved
INDEXER_BRANCH="tzaffi/box-search"
tzaffi marked this conversation as resolved.
Show resolved Hide resolved
INDEXER_SHA=""

# Sandbox configuration:
SANDBOX_BRANCH="configurable-ports"
tzaffi marked this conversation as resolved.
Show resolved Hide resolved
SANDBOX_URL="https://github.com/algorand/sandbox"
SANDBOX_DIR=".sdk-harness-sandbox"

# replacement values for Sandbox's docker-compose:
ALGOD_CONTAINER=sdk-harness-algod
KMD_PORT=60001
ALGOD_PORT=60000
INDEXER_CONTAINER=sdk-harness-indexer
INDEXER_PORT=59999
POSTGRES_CONTAINER=sdk-harness-postgres
POSTGRES_PORT=65432
126 changes: 123 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,128 @@ unit:

INTEGRATIONS = "@abi or @algod or @applications or @applications.verified or @assets or @auction or @c2c or @compile or @dryrun or @dryrun.testing or @indexer or @indexer.231 or @indexer.applications or @kmd or @rekey_v1 or @send.keyregtxn or @send or @compile.sourcemap"
integration:
behave --tags=$(INTEGRATIONS) tests -f progress2
behave --tags=$(INTEGRATIONS) tests -f progress2 --no-capture
tzaffi marked this conversation as resolved.
Show resolved Hide resolved

# channel or source
TYPE ?= channel
tzaffi marked this conversation as resolved.
Show resolved Hide resolved
harness:
TYPE='$(TYPE)' ./test-harness.sh

PYTHON_VERSION ?= 3.8
docker-test:
PYTHON_VERSION='$(PYTHON_VERSION)' ./run_integration.sh
docker-pysdk-build:
docker build -t py-sdk-testing --build-arg PYTHON_VERSION="${PYTHON_VERSION}" .

docker-pysdk-run:
docker ps -a
docker run -it --network host py-sdk-testing:latest

docker-test: harness docker-pysdk-build docker-pysdk-run

# algorand-sdk-testing's git branch:
TBRANCH = master
# go-algorand's git branch:
ABRANCH = master
get-trepo:
rm -rf test-harness && rm -rf tests/features \
&& git clone --single-branch --branch $(TBRANCH) https://github.com/algorand/algorand-sdk-testing.git test-harness \
&& sed -i "" -e "s#ALGOD_BRANCH=\".*\"#ALGOD_BRANCH=\"$(ABRANCH)\"#g" test-harness/.up-env \
&& mkdir -p test/features \
&& cp -r test-harness/features/* test/features

up:
./test-harness/scripts/up.sh

down:
./test-harness/scripts/down.sh

restart-test-harness: get-trepo up

ps:
cd test-harness \
&& docker-compose ps

pause:
cd test-harness \
&& docker-compose pause

unpause:
cd test-harness \
&& docker-compose unpause


# sdk-harness-algod \
tzaffi marked this conversation as resolved.
Show resolved Hide resolved
# && docker-compose pause sdk-harness-indexer-23x-1 \
# && docker-compose pause sdk-harness-indexer-23x-2 \
# && docker-compose pause sdk-harness-indexer-applications \
# && docker-compose pause sdk-harness-indexer-live \
# && docker-compose pause sdk-harness-indexer-release \
# && docker-compose pause sdk-harness-algod \


docker-cleanup:
docker container prune \
&& docker rmi $$(docker images -q) \
&& docker rm -v $$(docker ps -qa)

docker-nuke:
docker system prune

TBRANCH = zc2c
ABRANCH = features/contract-to-contract
z: restart-test-harness


c2c-integration:
behave -D BEHAVE_ON_ERROR --tags=c2c test/features/integration/c2c.feature -f pretty

BINARY_FILE = ""
show-binary:
xxd -p $(BINARY_FILE) | tr -d '\n'

# c2c-integration:
# behave --tags=c2c test/features/integration/c2c.feature -f plain

# Available formatters:
# json JSON dump of test run
# json.pretty JSON dump of test run (human readable)
# null Provides formatter that does not output anything.
# plain Very basic formatter with maximum compatibility
# pretty Standard colourised pretty formatter
# progress Shows dotted progress for each executed scenario.
# progress2 Shows dotted progress for each executed step.
# progress3 Shows detailed progress for each step of a scenario.
# rerun Emits scenario file locations of failing scenarios
# sphinx.steps Generate sphinx-based documentation for step definitions.
# steps Shows step definitions (step implementations).
# steps.catalog Shows non-technical documentation for step definitions.
# steps.doc Shows documentation for step definitions.
# steps.usage Shows how step definitions are used by steps.
# tags Shows tags (and how often they are used).
# tags.location Shows tags and the location where they are used.

zymlinkize:
mv test/cucumber/features test_cucumber_features \
&& ln -s ~/github/algorand/algorand-sdk-testing/features test/cucumber/features

de-zymlinkize:
rm -f test/cucumber/features \
&& mv test_cucumber_features test/cucumber/features

local-docker-testing:
PYTHON_VERSION='3.8' ./run_integration_after_git_and_docker.sh

compliant-behave:
ln -s ~/github/algorand/algorand-sdk-testing/features test/features
ln -s test/


docker-restart:
./test-harness/scripts/restart.sh

abi-args-integration:
behave -D BEHAVE_ON_ERROR --tags="@z" -k -f plain test/features/integration/abi.feature

abi-args-unit:
behave -D BEHAVE_ON_ERROR --tags="@unit.atc_method_args" -k -f plain test/features/unit/atomic_transaction_composer.feature
# behave -D BEHAVE_ON_ERROR --tags="@z" -k -f plain test/features/unit/atomic_transaction_composer.feature

tzaffi marked this conversation as resolved.
Show resolved Hide resolved
10 changes: 5 additions & 5 deletions examples/tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
# algod info is in the algod.net and algod.token files in the data directory
# kmd info is in the kmd.net and kmd.token files in the kmd directory in data

kmd_token = ""
kmd_address = ""
kmd_token = "a" * 64
kmd_address = "http://localhost:4002"

algod_token = ""
algod_address = ""
algod_token = "a" * 64
algod_address = "http://localhost:4001"

# you can also get tokens and addresses automatically
get_automatically = True
get_automatically = False

# path to the data directory
data_dir_path = home + "/node/network/Node"
Expand Down
30 changes: 0 additions & 30 deletions run_integration.sh

This file was deleted.

32 changes: 32 additions & 0 deletions test-harness.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash
algochoi marked this conversation as resolved.
Show resolved Hide resolved

START=$(date "+%s")

set -e

ENV_FILE=".test-env"
source $ENV_FILE

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

## Reset test harness
rm -rf "$SDK_TESTING_HARNESS"
git clone --single-branch --branch "$SDK_TESTING_BRANCH" "$SDK_TESTING_URL" "$SDK_TESTING_HARNESS"
tzaffi marked this conversation as resolved.
Show resolved Hide resolved

## OVERWRITE incoming .env with .test-env
cp "$ENV_FILE" "$SDK_TESTING_HARNESS"/.env
tzaffi marked this conversation as resolved.
Show resolved Hide resolved
michaeldiamant marked this conversation as resolved.
Show resolved Hide resolved

## Copy feature files into the project resources
mkdir -p tests/features
tzaffi marked this conversation as resolved.
Show resolved Hide resolved
cp -r "$SDK_TESTING_HARNESS"/features/* tests/features
echo "run_integration.sh: seconds it took to get to end of cloning + copying: " + $(($(date "+%s") - $START))


## Start test harness environment
pushd "$SDK_TESTING_HARNESS"
./scripts/up.sh
popd
echo "run_integration.sh: seconds it took to finish testing sdk's up.sh: " + $(($(date "+%s") - $START))
echo "To run sandbox commands, cd into $SDK_TESTING_HARNESS/$SANDBOX"
tzaffi marked this conversation as resolved.
Show resolved Hide resolved
echo "time till end of test-harness bootstrapping: " + $(($(date "+%s") - $START))
tzaffi marked this conversation as resolved.
Show resolved Hide resolved
19 changes: 19 additions & 0 deletions tests/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ def before_all(context):
)
context.response_thread.start()

setup_debug_on_error(context.config.userdata)


def after_all(context):
# Shutdown path server
Expand All @@ -135,3 +137,20 @@ def after_all(context):
# Shutdown route server
context.response_server.shutdown()
context.response_thread.join()


BEHAVE_DEBUG_ON_ERROR = True


def setup_debug_on_error(userdata):
global BEHAVE_DEBUG_ON_ERROR
BEHAVE_DEBUG_ON_ERROR = userdata.getbool("BEHAVE_DEBUG_ON_ERROR")


def after_step(context, step):
if BEHAVE_DEBUG_ON_ERROR and step.status == "failed":
# -- ENTER DEBUGGER: Zoom in on failure location.
# NOTE: Use IPython debugger, same for pdb (basic python debugger).
import ipdb

ipdb.post_mortem(step.exc_traceback)
87 changes: 0 additions & 87 deletions tests/steps/account_v2_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,6 @@ def lookup_account_check_holdings(context, μalgos, num, assetid, assetamount):
assert a["amount"] == int(assetamount)


@when('I use {indexer} to lookup account "{account}" at round {round}')
def icl_lookup_account_at_round(context, indexer, account, round):
context.response = context.icls[indexer].account_info(account, int(round))


@when(
'we make a Lookup Account by ID call against account "{account}" with round {block}'
)
Expand Down Expand Up @@ -262,88 +257,6 @@ def search_accounts3(
context.response = context.icl.accounts(exclude=exclude)


@when(
'I use {indexer} to search for an account with {assetid}, {limit}, {currencygt}, {currencylt}, "{auth_addr:MaybeString}", {application_id}, "{include_all:MaybeBool}" and token "{token:MaybeString}"'
)
def icl_search_accounts_with_auth_addr_and_app_id_and_include_all(
context,
indexer,
assetid,
limit,
currencygt,
currencylt,
auth_addr,
application_id,
include_all,
token,
):
context.response = context.icls[indexer].accounts(
asset_id=int(assetid),
limit=int(limit),
next_page=token,
min_balance=int(currencygt),
max_balance=int(currencylt),
auth_addr=auth_addr,
application_id=int(application_id),
include_all=include_all,
)


@when(
'I use {indexer} to search for an account with {assetid}, {limit}, {currencygt}, {currencylt}, "{auth_addr:MaybeString}", {application_id} and token "{token:MaybeString}"'
)
def icl_search_accounts_with_auth_addr_and_app_id(
context,
indexer,
assetid,
limit,
currencygt,
currencylt,
auth_addr,
application_id,
token,
):
context.response = context.icls[indexer].accounts(
asset_id=int(assetid),
limit=int(limit),
next_page=token,
min_balance=int(currencygt),
max_balance=int(currencylt),
auth_addr=auth_addr,
application_id=int(application_id),
)


@when(
'I use {indexer} to search for an account with {assetid}, {limit}, {currencygt}, {currencylt} and token "{token:MaybeString}"'
)
def icl_search_accounts_legacy(
context, indexer, assetid, limit, currencygt, currencylt, token
):
context.response = context.icls[indexer].accounts(
asset_id=int(assetid),
limit=int(limit),
next_page=token,
min_balance=int(currencygt),
max_balance=int(currencylt),
)


@then(
"I get the next page using {indexer} to search for an account with {assetid}, {limit}, {currencygt} and {currencylt}"
)
def search_accounts_nex(
context, indexer, assetid, limit, currencygt, currencylt
):
context.response = context.icls[indexer].accounts(
asset_id=int(assetid),
limit=int(limit),
min_balance=int(currencygt),
max_balance=int(currencylt),
next_page=context.response["next-token"],
)


@then(
'There are {num}, the first has {pendingrewards}, {rewardsbase}, {rewards}, {withoutrewards}, "{address}", {amount}, "{status}", "{sigtype:MaybeString}"'
)
Expand Down
Loading