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

Checking CircleCI tests run once and only once #2749

Merged
merged 54 commits into from
Sep 8, 2021
Merged
Show file tree
Hide file tree
Changes from 45 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
9442a8c
Adding gotestsum to integration tests
algojack Aug 16, 2021
68e791c
Removed a testing block
algojack Aug 16, 2021
f20b6d0
Adding test results dir
algojack Aug 17, 2021
ec23752
Undoing shellcheck improvements
algojack Aug 17, 2021
58a3b56
Undoing shellcheck improvements
algojack Aug 17, 2021
12bb942
Added junit file for test results
algojack Aug 17, 2021
64907c0
Merge branch 'master' into jack/1489-checking-circleci-tests-run-only…
algojack Aug 18, 2021
3e167d4
Added new check job and result_path var
algojack Aug 18, 2021
d35acb0
Fixed typo
algojack Aug 18, 2021
6c6a3b2
Fixed parameter reference
algojack Aug 18, 2021
e4aaf76
Added script to check for tests
algojack Aug 18, 2021
cff740f
Added partition id folders and recursive file list
algojack Aug 19, 2021
eb1e87e
Creating node index folders
algojack Aug 19, 2021
47eee52
Fixing workspace paths
algojack Aug 19, 2021
744eca3
Fixing workspace paths
algojack Aug 19, 2021
b73ee2b
Combining result files into one
algojack Aug 19, 2021
784072c
Making it run for all needed jobs
algojack Aug 19, 2021
25cd3dd
Fixing naming
algojack Aug 19, 2021
2dbac42
Merge remote-tracking branch 'origin/master' into jack/1489-checking-…
algojack Aug 20, 2021
69e438d
Separated skipped due to partition, and made docker small
algojack Aug 20, 2021
61986f5
Restricted to amd64_test and nightly for testing
algojack Aug 20, 2021
aed014b
Restricted to mac_amd64_test and nightly for testing
algojack Aug 20, 2021
965c61d
Added color and switched to nightly
algojack Aug 20, 2021
7884fe7
Enabled all nightly tests to check that they all work
algojack Aug 23, 2021
464a39a
Merge remote-tracking branch 'origin/master' into jack/1489-checking-…
algojack Aug 23, 2021
2855341
Switched back to normal (not nightlies)
algojack Aug 23, 2021
b6d3b4d
Added comment about gotestsum usage
algojack Aug 23, 2021
11d153a
Add double sharding to the expect tests
cce Aug 25, 2021
f4e5e60
Merge branch 'master' into jack/1489-checking-circleci-tests-run-only…
algojack Aug 30, 2021
7f93ef4
Replaced lists with one dictionary and better messages
algojack Aug 30, 2021
08fd3b5
Fixed typos and formatting
algojack Aug 31, 2021
a749734
Added verification to e2e expect jobs
algojack Aug 31, 2021
08cfb40
Fixed exit error code
algojack Aug 31, 2021
a7ef7c7
Switching to nightly tests to check them too
algojack Aug 31, 2021
fa5f92c
Revert "Switching to nightly tests to check them too"
algojack Aug 31, 2021
fff3913
increase parallelism: 2 and reduce resource_class used by expect jobs
cce Sep 1, 2021
c4b6da3
Fixing how we detect intentional vs unintentional skips
algojack Sep 1, 2021
aa5576d
Fixed message when no reason found
algojack Sep 1, 2021
30c9613
Fixed formatting of skipped reasons
algojack Sep 2, 2021
5772416
Fixing wording of some things
algojack Sep 3, 2021
bb2fa57
Revert "Add double sharding to the expect tests"
cce Sep 7, 2021
4929222
Fixing double partitioned tests
algojack Sep 7, 2021
67abb84
Add PartitionTest call to some tests that were not partitioned spotte…
cce Sep 7, 2021
04ed1bc
Switching to nightly tests for testing only
algojack Sep 7, 2021
732eb5b
Merge branch 'jack/1489-checking-circleci-tests-run-only-once' of git…
algojack Sep 7, 2021
87e0cba
Fixing expect tests to have partition
algojack Sep 7, 2021
017a5ae
Paritioning unpartitioned multiple run tests
algojack Sep 7, 2021
8c09cb5
Revert "Switching to nightly tests for testing only"
algojack Sep 7, 2021
dcbca18
Fixed automatic VSCode corrections
algojack Sep 7, 2021
7a0c2b5
Fixing vscode bug
algojack Sep 7, 2021
4ae2738
Fixing double partitioned tests
algojack Sep 8, 2021
efd73b6
Switching to nightly tests for testing only
algojack Sep 7, 2021
d083c52
Fixing double partitioning
algojack Sep 8, 2021
54a03e5
Revert "Switching to nightly tests for testing only"
algojack Sep 8, 2021
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
185 changes: 123 additions & 62 deletions .circleci/config.yml

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions agreement/agreementtest/simulate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
"github.com/algorand/go-algorand/data/committee"
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/protocol"
"github.com/algorand/go-algorand/test/partitiontest"
"github.com/algorand/go-algorand/util/db"
)

Expand Down Expand Up @@ -294,6 +295,8 @@ func (l *testLedger) EnsureDigest(c agreement.Certificate, verifier *agreement.A
}

func TestSimulate(t *testing.T) {
partitiontest.PartitionTest(t)

f, _ := os.Create(t.Name() + ".log")
logging.Base().SetJSONFormatter()
logging.Base().SetOutput(f)
Expand Down
3 changes: 3 additions & 0 deletions daemon/algod/api/server/lib/middlewares/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"net/http"
"testing"

"github.com/algorand/go-algorand/test/partitiontest"
"github.com/labstack/echo/v4"
"github.com/stretchr/testify/require"
)
Expand All @@ -36,6 +37,8 @@ func success(ctx echo.Context) error {
}

func TestAuth(t *testing.T) {
partitiontest.PartitionTest(t)

tokens := []string{"token1", "token2"}

tests := []struct {
Expand Down
2 changes: 2 additions & 0 deletions data/transactions/logic/doc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ func TestOpImmediateNote(t *testing.T) {
}

func TestAllImmediatesDocumented(t *testing.T) {
partitiontest.PartitionTest(t)

for _, op := range OpSpecs {
count := len(op.Details.Immediates)
note := OpImmediateNote(op.Name)
Expand Down
5 changes: 5 additions & 0 deletions data/transactions/logic/eval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2140,6 +2140,7 @@ len`, 2)
}

func TestExtractOp(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()
testAccepts(t, "byte 0x123456789abc; extract 1 2; byte 0x3456; ==", 5)
testAccepts(t, "byte 0x123456789abc; extract 0 6; byte 0x123456789abc; ==", 5)
Expand All @@ -2156,6 +2157,7 @@ func TestExtractOp(t *testing.T) {
}

func TestExtractFlop(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()
// fails in compiler
testProg(t, `byte 0xf000000000000000
Expand Down Expand Up @@ -4355,6 +4357,7 @@ func TestBytes(t *testing.T) {
}

func TestMethod(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()
// Although 'method' is new around the time of v5, it is a
// pseudo-op, so it's ok to use it earlier, as it compiles to
Expand Down Expand Up @@ -4391,6 +4394,7 @@ func TestDig(t *testing.T) {
}

func TestCover(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()
testAccepts(t, "int 4; int 3; int 2; int 1; cover 0; int 1; ==; return", 5)
testAccepts(t, "int 4; int 3; int 2; int 1; cover 1; int 2; ==; return", 5)
Expand All @@ -4401,6 +4405,7 @@ func TestCover(t *testing.T) {
}

func TestUncover(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()
testAccepts(t, "int 4; int 3; int 2; int 1; uncover 0; int 1; ==; return", 5)
testAccepts(t, "int 4; int 3; int 2; int 1; uncover 2; int 3; ==; return", 5)
Expand Down
3 changes: 2 additions & 1 deletion data/transactions/logic/opcodes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ func TestOpcodesByVersionReordered(t *testing.T) {
}

func TestOpcodesByVersion(t *testing.T) {
partitiontest.PartitionTest(t)
// partitiontest.PartitionTest(t)
// has partitioning in the TestOpcodesByVersionReordered()

// Make a copy of the OpSpecs to check if OpcodesByVersion will change it
OpSpecs2 := make([]OpSpec, len(OpSpecs))
Expand Down
1 change: 1 addition & 0 deletions network/wsNetwork_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2053,6 +2053,7 @@ type urlCase struct {
}

func TestParseHostOrURL(t *testing.T) {
partitiontest.PartitionTest(t)
urlTestCases := []urlCase{
{"localhost:123", url.URL{Scheme: "http", Host: "localhost:123"}},
{"http://localhost:123", url.URL{Scheme: "http", Host: "localhost:123"}},
Expand Down
116 changes: 116 additions & 0 deletions scripts/buildtools/check_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
print("===== STARTED RUNNING check_tests.py =====\n")

import json
import sys
import argparse

# Arguments parsing / help menu
parser = argparse.ArgumentParser(description='Check test results for intentionally and unintentionally skipped tests, as well as tests that ran multiple times.')
parser.add_argument('tests_results_filepath', metavar='RESULTS_FILE',
help='json format test results file path (e.g. /tmp/results/testresults.json)')
args = parser.parse_args()

# Go through the given file one json object at a time, and record into a dict
AllTestResults = {}
with open(args.tests_results_filepath) as f:
for jsonObj in f:
testDict = json.loads(jsonObj)
if 'Test' not in testDict:
continue

fullTestName = testDict['Package'] + ' ' + testDict['Test']
if fullTestName not in AllTestResults:
AllTestResults[fullTestName] = {}
AllTestResults[fullTestName]['ran'] = 0
AllTestResults[fullTestName]['last_output'] = ''
AllTestResults[fullTestName]['skipped_intentionally'] = False
AllTestResults[fullTestName]['skipped_reason'] = ''

# actions can be: output, run, skip, pass
if 'pass' in testDict["Action"]:
AllTestResults[fullTestName]['ran'] += 1
elif 'output' in testDict["Action"]:
if '--- SKIP' in testDict['Output'] and 'due to partitioning' not in AllTestResults[fullTestName]['last_output']:
AllTestResults[fullTestName]['skipped_intentionally'] = True
if '=== RUN' in AllTestResults[fullTestName]['last_output']:
AllTestResults[fullTestName]['skipped_reason'] = 'No reason given. PLEASE CHECK!!!'
else:
AllTestResults[fullTestName]['skipped_reason'] = AllTestResults[fullTestName]['last_output'].strip()

AllTestResults[fullTestName]['last_output'] = testDict['Output']



f.close()

# === Calculate results ===

# Sort and print messages with colored prefix
RED_TEXT_COLOR = "\033[0;31m"
GREEN_TEXT_COLOR = "\033[0;32m"
YELLOW_TEXT_COLOR = "\033[0;33m"
NORMAL_TEXT_COLOR = "\033[0;0m"
def printColor(message, color=NORMAL_TEXT_COLOR):
print(f"{color}{message}{NORMAL_TEXT_COLOR}")

# Record error message for sys.exit(errorMessage)
errorMessage = ''

# Check for tests that ran multiple times
printColor("=========== RAN MULTIPLE TIMES ===================", YELLOW_TEXT_COLOR)
listOfMultipleRuns = []
for x in AllTestResults:
if AllTestResults[x]['ran'] > 1:
listOfMultipleRuns.append(x + " -- ran " + str(AllTestResults[x]['ran']) + " times. (Can probably be fixed by adding \"partitiontest.PartitionTest()\")")
countMultipleRuns = len(listOfMultipleRuns)
if countMultipleRuns:
printColor(f"The above {countMultipleRuns} tests ran multiple times:", RED_TEXT_COLOR)
[printColor(f"{x}", RED_TEXT_COLOR) for x in sorted(listOfMultipleRuns)]
printColor(f"The above {countMultipleRuns} tests ran multiple times:", RED_TEXT_COLOR)
else:
printColor("All tests that ran, ran only once ... OK", GREEN_TEXT_COLOR)
printColor("==================================================\n", YELLOW_TEXT_COLOR)

# Check intentionally skipped tests
printColor("============= INTENTIONALLY SKIPPED ==============", YELLOW_TEXT_COLOR)
listOfSkippedIntentionally = []
[listOfSkippedIntentionally.append(x) for x in AllTestResults if (AllTestResults[x]['ran'] == 0 and AllTestResults[x]['skipped_intentionally'] == True )]
countSkippedIntentionally = len(listOfSkippedIntentionally)
if countSkippedIntentionally:
printColor(f"The following {countSkippedIntentionally} tests were skipped intentionally:", YELLOW_TEXT_COLOR)
[printColor(f"{x} -- skipped intentionally (please double check) Reason: {AllTestResults[x]['skipped_reason']}", YELLOW_TEXT_COLOR) for x in sorted(listOfSkippedIntentionally)]
printColor(f"The above {countSkippedIntentionally} tests were skipped intentionally:", YELLOW_TEXT_COLOR)
else:
printColor("No tests skipped intentionally.", GREEN_TEXT_COLOR)
printColor("==================================================\n", YELLOW_TEXT_COLOR)

# Check unintentionally skipped tests (due to partition)
printColor("============= UNINTENTIONALLY SKIPPED ============", YELLOW_TEXT_COLOR)
listOfSkippedUnintentionally = []
[listOfSkippedUnintentionally.append(x) for x in AllTestResults if (AllTestResults[x]['ran'] == 0 and AllTestResults[x]['skipped_intentionally'] == False)]
countSkippedUnintentionally = len(listOfSkippedUnintentionally)
if countSkippedUnintentionally:
printColor(f"{countSkippedUnintentionally} tests were skipped unintentionally", RED_TEXT_COLOR)
[printColor(f"{x} -- skipped unintentionally. (due to partitiontest.PartitionTest() being called twice?)", RED_TEXT_COLOR) for x in sorted(listOfSkippedUnintentionally)]
printColor(f"{countSkippedUnintentionally} tests were skipped unintentionally.", RED_TEXT_COLOR)
errorMessage += f"{countSkippedUnintentionally} tests were skipped unintentionally";
else:
printColor("No tests skipped unintentionally (due to partitioning).", GREEN_TEXT_COLOR)
printColor("==================================================\n", YELLOW_TEXT_COLOR)

# === Summary ===
printColor("==================== SUMMARY =====================", YELLOW_TEXT_COLOR)
countUniqueTests = len(AllTestResults)
countTotalSkipped = countSkippedIntentionally + countSkippedUnintentionally
countRanTests = sum(1 for x in AllTestResults if AllTestResults[x]['ran'] > 0)

printColor(f"Saw {countUniqueTests} unique tests", GREEN_TEXT_COLOR if countUniqueTests != 0 else RED_TEXT_COLOR)
printColor(f"{countTotalSkipped} total skipped tests", GREEN_TEXT_COLOR if countTotalSkipped == 0 else YELLOW_TEXT_COLOR)
printColor(f"{countRanTests} tests ran", GREEN_TEXT_COLOR if countRanTests != 0 else RED_TEXT_COLOR)
printColor(f"{countSkippedIntentionally} tests were skipped intentionally. (They were probably disabled, please double check)", GREEN_TEXT_COLOR if countSkippedIntentionally == 0 else YELLOW_TEXT_COLOR)
printColor(f"{countSkippedUnintentionally} tests were skipped unintentionally. (Due to partitioning multiple times? maybe due to partitiontest.PartitionTest() being called twice?)", GREEN_TEXT_COLOR if countSkippedUnintentionally == 0 else RED_TEXT_COLOR)
printColor(f"{countMultipleRuns} tests ran multiple times. (Can probably be fixed by adding \"partitiontest.PartitionTest()\")", GREEN_TEXT_COLOR if countMultipleRuns == 0 else RED_TEXT_COLOR)
printColor("==================================================\n", YELLOW_TEXT_COLOR)

print("===== FINISHED RUNNING check_tests.py =====")
sys.exit(0 if not errorMessage else errorMessage)
11 changes: 10 additions & 1 deletion test/scripts/e2e_go_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,16 @@ set -o pipefail

export GOPATH=$(go env GOPATH)
export GO111MODULE=on
GOTESTCOMMAND=${GOTESTCOMMAND:="go test"}

# Needed for now because circleci doesn't use makefile yet
if [ -z "$(which gotestsum)" ]; then
GOTESTCOMMAND=${GOTESTCOMMAND:="go test"}
else
TEST_RESULTS=${TEST_RESULTS:="$(pwd)"}
GOTESTCOMMAND=${GOTESTCOMMAND:="gotestsum --format testname --junitfile ${TEST_RESULTS}/results.xml --jsonfile ${TEST_RESULTS}/testresults.json --"}
fi

echo "GOTESTCOMMAND will be: ${GOTESTCOMMAND}"

# If one or more -t <pattern> are specified, use GOTESTCOMMAND -run <pattern> for each

Expand Down