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 all 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
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="master"
SDK_TESTING_HARNESS="test-harness"

VERBOSE_HARNESS=0

# 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
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ RUN pip install . -q \
&& pip install -r requirements.txt -q

# Run integration tests
CMD ["/bin/bash", "-c", "make unit && make integration"]

CMD ["/bin/bash", "-c", "python --version && make unit && make integration"]
25 changes: 19 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
UNITS = "@unit.abijson or @unit.abijson.byname or @unit.algod or @unit.algod.ledger_refactoring or @unit.applications or @unit.atc_method_args or @unit.atomic_transaction_composer or @unit.dryrun or @unit.dryrun.trace.application or @unit.feetest or @unit.indexer or @unit.indexer.ledger_refactoring or @unit.indexer.logs or @unit.offline or @unit.rekey or @unit.transactions.keyreg or @unit.responses or @unit.responses.231 or @unit.tealsign or @unit.transactions or @unit.transactions.payment or @unit.responses.unlimited_assets or @unit.sourcemap"
UNIT_TAGS := "$(subst :, or ,$(shell awk '{print $2}' tests/unit.tags | paste -s -d: -))"
INTEGRATION_TAGS := "$(subst :, or ,$(shell awk '{print $2}' tests/integration.tags | paste -s -d: -))"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

cucumber tags now reside in:

  • tests/unit.tags
  • tests/integration.tags


unit:
behave --tags=$(UNITS) tests -f progress2
behave --tags=$(UNIT_TAGS) tests -f progress2

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=$(INTEGRATION_TAGS) tests -f progress2 --no-capture

display-all-python-steps:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

generates text used by the Unused Steps Analysis script

find tests/steps -name "*.py" | xargs grep "behave" 2>/dev/null | cut -d: -f1 | sort | uniq | xargs awk "/@(given|step|then|when)/,/[)]/" | grep -E "(\".+\"|\'.+\')"

harness:
./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
30 changes: 0 additions & 30 deletions run_integration.sh

This file was deleted.

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

set -euo pipefail

START=$(date "+%s")

THIS=$(basename "$0")
ENV_FILE=".test-env"
TEST_DIR="tests"

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/features && echo "$THIS: see the previous for files deleted" ) || true
fi
rm -rf $TEST_DIR/features
fi
mkdir -p $TEST_DIR/features
cp -r "$SDK_TESTING_HARNESS"/features/* $TEST_DIR/features
if [[ $VERBOSE_HARNESS == 1 ]]; then
( tree $TEST_DIR/features && 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 "--------------------------------------------------------------------------------"
15 changes: 15 additions & 0 deletions tests/integration.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@abi
@algod
@applications
@applications.verified
@assets
@auction
@c2c
@compile
@compile.sourcemap
@dryrun
@dryrun.testing
@kmd
@rekey_v1
@send
@send.keyregtxn
200 changes: 2 additions & 198 deletions tests/steps/account_v2_steps.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Union

from algosdk import account, constants, encoding, logic
from algosdk import account, encoding, logic
from algosdk.future import transaction
from behave import given, then, when
import tests.steps.other_v2_steps # Imports MaybeString
Expand Down Expand Up @@ -33,57 +33,6 @@ def acc_info2(context, account):
context.response = context.acl.account_info(account)


@then(
'The account has {num} assets, the first is asset {index} has a frozen status of "{frozen}" and amount {units}.'
)
def lookup_account_check(context, num, index, frozen, units):
assert len(context.response["account"]["assets"]) == int(num)
assert context.response["account"]["assets"][0]["asset-id"] == int(index)
assert context.response["account"]["assets"][0]["is-frozen"] == (
frozen == "true"
)
assert context.response["account"]["assets"][0]["amount"] == int(units)


@then(
'The account created {num} assets, the first is asset {index} is named "{name}" with a total amount of {total} "{unit}"'
)
def lookup_account_check_created(context, num, index, name, total, unit):
assert len(context.response["account"]["created-assets"]) == int(num)
assert context.response["account"]["created-assets"][0]["index"] == int(
index
)
assert (
context.response["account"]["created-assets"][0]["params"]["name"]
== name
)
assert (
context.response["account"]["created-assets"][0]["params"]["unit-name"]
== unit
)
assert context.response["account"]["created-assets"][0]["params"][
"total"
] == int(total)


@then(
"The account has {μalgos} μalgos and {num} assets, {assetid} has {assetamount}"
)
def lookup_account_check_holdings(context, μalgos, num, assetid, assetamount):
assert context.response["account"]["amount"] == int(μalgos)
assert len(context.response["account"].get("assets", [])) == int(num)
if int(num) > 0:
assets = context.response["account"]["assets"]
for a in assets:
if a["asset-id"] == int(assetid):
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 All @@ -94,7 +43,7 @@ def lookup_account(context, account, block):
@when(
'we make a Lookup Account by ID call against account "{account}" with exclude "{exclude:MaybeString}"'
)
def lookup_account(context, account, exclude):
def lookup_account2(context, account, exclude):
context.response = context.icl.account_info(account, exclude=exclude)


Expand Down Expand Up @@ -262,151 +211,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}"'
)
def check_search_accounts(
context,
num,
pendingrewards,
rewardsbase,
rewards,
withoutrewards,
address,
amount,
status,
sigtype,
):
assert len(context.response["accounts"]) == int(num)
assert context.response["accounts"][0]["pending-rewards"] == int(
pendingrewards
)
assert context.response["accounts"][0].get("rewards-base", 0) == int(
rewardsbase
)
assert context.response["accounts"][0]["rewards"] == int(rewards)
assert context.response["accounts"][0][
"amount-without-pending-rewards"
] == int(withoutrewards)
assert context.response["accounts"][0]["address"] == address
assert context.response["accounts"][0]["amount"] == int(amount)
assert context.response["accounts"][0]["status"] == status
assert context.response["accounts"][0].get("sig-type", "") == sigtype


@then(
'The first account is online and has "{address}", {keydilution}, {firstvalid}, {lastvalid}, "{votekey}", "{selectionkey}"'
)
def check_search_accounts_online(
context, address, keydilution, firstvalid, lastvalid, votekey, selectionkey
):
assert context.response["accounts"][0]["status"] == "Online"
assert context.response["accounts"][0]["address"] == address
assert context.response["accounts"][0]["participation"][
"vote-key-dilution"
] == int(keydilution)
assert context.response["accounts"][0]["participation"][
"vote-first-valid"
] == int(firstvalid)
assert context.response["accounts"][0]["participation"][
"vote-last-valid"
] == int(lastvalid)
assert (
context.response["accounts"][0]["participation"][
"vote-participation-key"
]
== votekey
)
assert (
context.response["accounts"][0]["participation"][
"selection-participation-key"
]
== selectionkey
)


@when("we make any SearchAccounts call")
def search_accounts_any(context):
context.response = context.icl.accounts(asset_id=2)
Expand Down
Loading