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

Action inputs to dispatch n-runs of a single test in CI #6297

Merged
merged 81 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from 79 commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
f5301c6
create Run Test N-times gh action
carlydf Jul 10, 2024
377d713
change name of step
carlydf Jul 10, 2024
c05a1a1
make existing test workflow allow single test run
carlydf Jul 11, 2024
6fb13fd
fix false check syntax
carlydf Jul 11, 2024
82acc5c
don't run unit tests in single functional test mode
carlydf Jul 11, 2024
56b97cf
fix needs
carlydf Jul 11, 2024
320ed3d
hardcode single test mode
carlydf Jul 11, 2024
94a6f2c
run functional-test always()
carlydf Jul 11, 2024
774403d
print what the makefile runs
carlydf Jul 12, 2024
cd5160b
temporary code change to test flaky test
carlydf Jul 12, 2024
f055929
add db options
carlydf Jul 12, 2024
451f80c
hard code sqlite and postgres12
carlydf Jul 13, 2024
ceeaca4
delete comment below runs-on
carlydf Jul 13, 2024
6ddda0b
fix db issue?
carlydf Jul 13, 2024
fc7ead3
removed duplicate matrix step, updated options
carlydf Jul 15, 2024
ce29c65
define setup job outputs
carlydf Jul 15, 2024
8fbe6df
configurable timeout
carlydf Jul 15, 2024
bc76889
test string timeout
carlydf Jul 16, 2024
69a0a37
fix timeout pipe
carlydf Jul 16, 2024
ee8e476
try dynamic shard matrix
carlydf Jul 16, 2024
be78354
try other dynamic matrix format
carlydf Jul 16, 2024
0a9d473
add db matrix
carlydf Jul 16, 2024
f6b52ea
fix misuse of single quotes
carlydf Jul 16, 2024
5647d44
hard-code sqlite for single test mode
carlydf Jul 16, 2024
dd629bc
quote the db names
carlydf Jul 16, 2024
9a78b44
remove comment above runs-on and dynamically config test_db
carlydf Jul 16, 2024
a129047
Merge branch 'main' into cdf/rerun-functional-test
carlydf Jul 16, 2024
7292977
change job if condition so steps run when needed
carlydf Jul 16, 2024
4980a86
Merge branch 'cdf/rerun-functional-test' of github.com:temporalio/tem…
carlydf Jul 16, 2024
189b6a9
fix lint and clean code
carlydf Jul 16, 2024
241cf33
remove db configuration
carlydf Jul 16, 2024
9c1f858
change if condition syntax and pipe in timeout
carlydf Jul 16, 2024
f4f8752
give up on configuring test db
carlydf Jul 16, 2024
b29a900
specify # of times per db
carlydf Jul 16, 2024
2eacb72
Revert "specify # of times per db"
carlydf Jul 16, 2024
8d05095
Revert "give up on configuring test db"
carlydf Jul 16, 2024
537294b
try db config again with new json formatting
carlydf Jul 16, 2024
e9d8f11
go back tp unquoted != true
carlydf Jul 16, 2024
c33c0a4
run functional-test always
carlydf Jul 16, 2024
56e19ef
give up on one-db-at-a-time
carlydf Jul 16, 2024
8278452
uncomment real functional test work
carlydf Jul 16, 2024
1ae8df0
clean up extra files
carlydf Jul 16, 2024
2a95b20
pass timeout to makefile
carlydf Jul 16, 2024
3ef7261
pass timeouts correctly
carlydf Jul 16, 2024
945dc27
use TEST_TIMEOUT variable in makefile
carlydf Jul 16, 2024
5470ba7
remove unused make target, try == false syntax for if:
carlydf Jul 16, 2024
55962e8
go back to != true
carlydf Jul 16, 2024
f9f1533
try != 'true'
carlydf Jul 16, 2024
09d7fe6
Merge branch 'main' of github.com:temporalio/temporal into cdf/rerun-…
carlydf Jul 16, 2024
532c0a9
try != true again
carlydf Jul 16, 2024
07ce206
remove extra file
carlydf Jul 16, 2024
3d226a4
improve test flag consistency
carlydf Jul 16, 2024
7824291
change wording
carlydf Jul 16, 2024
3acb316
fix TestWorkflowTaskRedirectInRetryFirstTask flake
carlydf Jul 16, 2024
e525fd4
add buildkite message
carlydf Jul 16, 2024
c74c23d
try configurable runner size
carlydf Jul 16, 2024
fe5c796
add configurable db via if
carlydf Jul 16, 2024
b4ff739
run job set up conditionally based on db as well
carlydf Jul 16, 2024
3e826a3
only tear down docker compose if we made it
carlydf Jul 16, 2024
a082423
revert test flake fix
carlydf Jul 16, 2024
a31d78b
fix cassandra db input
carlydf Jul 17, 2024
f6f6873
multi-select test db
carlydf Jul 24, 2024
e2e0d15
remove postgres12_pgx test db
carlydf Jul 24, 2024
2540f46
fix bash syntax error
carlydf Jul 24, 2024
e9ce2a7
try a different jq syntax
carlydf Jul 24, 2024
ed9233b
merge in main
carlydf Jul 24, 2024
fdcaa7f
delete bad mktemp --tmpdir flag
carlydf Jul 24, 2024
b7d9ccc
revert --tempdir flag change
carlydf Jul 24, 2024
fc558d9
put back newlines
carlydf Jul 24, 2024
2db8d87
temporarily remove make ci-build-misc
carlydf Jul 24, 2024
5951bb3
remove cache-docker-images dependency
carlydf Jul 24, 2024
7417f3d
add prints
carlydf Jul 24, 2024
16ee81e
save changes
carlydf Jul 25, 2024
edb5343
echo vars then run functional test n times
carlydf Sep 9, 2024
90c4962
fix syntax
carlydf Sep 9, 2024
f16eb70
Merge branch 'main' of github.com:temporalio/temporal into cdf/rerun-…
carlydf Sep 9, 2024
89b47d1
offer custom test directory
carlydf Oct 4, 2024
20e1f1e
offer n-times run for unit test also
carlydf Oct 4, 2024
b70af29
print test command in run
carlydf Oct 4, 2024
cb7d6c1
take dbs as list
carlydf Oct 9, 2024
c857565
make misc-checks a no-op in single test mode
carlydf Oct 9, 2024
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
152 changes: 142 additions & 10 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,54 @@ on:
commit:
description: "Commit SHA"
required: true
run_single_functional_test:
description: "Run a single functional test"
type: boolean
default: false
run_single_unit_test:
description: "Run a single unit test (INSTEAD of functional test)"
type: boolean
default: false
unit_test_directory:
description: "[Unit Test Only] Directory to run unit tests in"
type: string
default: "./temporal"
n_runs:
description: "Number of times to repeat the single test per database type"
type: number
default: 1
test_name:
description: "Name of the test to run (i.e. 'TestAcquireShard_DeadlineExceededErrorSuite' or 'TestFunctionalSuite/TestUpdateWorkflow')"
type: string
timeout_minutes:
description: "Test timeout in minutes"
type: number
default: 120
test_runner:
description: "Which runner to use. Choose higher RAM if your n_runs is high."
type: choice
default: "16GB RAM (ubuntu-20.04)"
options:
- "16GB RAM (ubuntu-20.04)"
- "64GB RAM (ubuntu-22.04)"
cassandra:
description: "cassandra"
type: boolean
default: false
sqlite:
description: "sqlite"
type: boolean
default: false
# mysql8:
# description: "mysql8"
# type: boolean
# default: false
# postgres12:
# description: "postgres12"
# type: boolean
# default: false
# if [[ "${{ inputs.mysql8 }}" == "true" ]]; then dbs_arr+=("mysql8"); fi
# if [[ "${{ inputs.postgres12 }}" == "true" ]]; then dbs_arr+=("postgres12"); fi
carlydf marked this conversation as resolved.
Show resolved Hide resolved

concurrency: # Auto-cancel existing runs in the PR when a new commit is pushed
group: run-tests-${{ github.head_ref || github.run_id }}
Expand All @@ -29,6 +77,52 @@ env:
BUILDKITE_ANALYTICS_TOKEN: ${{ secrets.BUILDKITE_ANALYTICS_TOKEN }}

jobs:
set-up-single-test:
name: Set up single test
runs-on: ubuntu-20.04
outputs:
shard_indices: ${{ steps.generate_output.outputs.shard_indices }}
total_shards: ${{ steps.generate_output.outputs.shards }}
github_timeout: ${{ steps.generate_output.outputs.github_timeout }}
test_timeout: ${{ steps.generate_output.outputs.test_timeout }}
single_test_args: ${{ steps.generate_output.outputs.single_test_args }}
runs_on: ${{ steps.generate_output.outputs.runs_on }}
dbs: ${{ steps.generate_output.outputs.dbs }}
steps:
- id: generate_output
run: |
shards=3
timeout=30
runs_on='["ubuntu-20.04"]'
if [[ "${{ inputs.run_single_functional_test }}" == "true" || "${{ inputs.run_single_unit_test }}" == "true" ]]; then
shards=1
timeout=${{ inputs.timeout_minutes }}
single_test_args="-run ${{ inputs.test_name }} -count ${{ inputs.n_runs }}"
if [[ "${{ inputs.test_runner }}" == "64GB RAM (ubuntu-22.04)" ]]; then
runs_on='[ "ubuntu-latest-16-cores" ]'
fi
dbs_arr=()
if [[ "${{ inputs.cassandra }}" == "true" ]]; then dbs_arr+=("cassandra"); fi
if [[ "${{ inputs.sqlite }}" == "true" ]]; then dbs_arr+=("sqlite"); fi
if [[ ${#dbs_arr[@]} == 0 ]]; then
dbs='["sqlite"]'
else
dbs=$(jq -c -n '$ARGS.positional' --args "${dbs_arr[@]}")
fi
fi
{
echo "shard_indices=[ $(seq -s, 0 $((shards-1))) ]"
echo "shards=$shards"
echo "github_timeout=$((timeout+5))"
echo "test_timeout=${timeout}m"
echo "single_test_args=$single_test_args"
echo "runs_on=$runs_on"
echo "dbs=$dbs"
} >> "$GITHUB_OUTPUT"
- id: cat_output
run: |
cat "$GITHUB_OUTPUT"

misc-checks:
name: Misc checks
strategy:
Expand Down Expand Up @@ -60,13 +154,20 @@ jobs:
- run: make build-tests

unit-test:
if: ${{ inputs.run_single_functional_test != true }}
carlydf marked this conversation as resolved.
Show resolved Hide resolved
name: Unit test
needs: misc-checks
needs: [misc-checks, set-up-single-test]
strategy:
fail-fast: false
matrix:
runs-on: [ubuntu-20.04]
runs-on: ${{ matrix.runs-on }}
env:
BUILDKITE_MESSAGE: "{\"job\": \"unit-test\"}"
SINGLE_TEST_ARGS: ${{ needs.set-up-single-test.outputs.single_test_args }}
UNIT_TEST_DIR: ${{ inputs.unit_test_directory }}
TEST_TIMEOUT: ${{ needs.set-up-single-test.outputs.test_timeout }}
RUN_SINGLE_UNIT_TEST: ${{ inputs.run_single_unit_test }}
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -78,22 +179,31 @@ jobs:
go-version-file: 'go.mod'
check-latest: true

- name: Run unit test
- name: Run unit tests
if: ${{ !cancelled() && !inputs.run_single_unit_test }}
timeout-minutes: 15
run: make unit-test-coverage

- name: Run single unit test
if: ${{ !cancelled() && inputs.run_single_unit_test }}
timeout-minutes: 15
run: UNIT_TEST_DIRS=$UNIT_TEST_DIR make unit-test-coverage

- name: Upload test results
if: ${{ !cancelled() }}
run: make upload-test-results

integration-test:
if: ${{ inputs.run_single_functional_test != true && inputs.run_single_unit_test != true }}
name: Integration test
needs: misc-checks
strategy:
fail-fast: false
matrix:
runs-on: [ubuntu-20.04]
runs-on: ${{ matrix.runs-on }}
env:
BUILDKITE_MESSAGE: "{\"job\": \"integration-test\"}"
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -123,21 +233,27 @@ jobs:
if: ${{ !cancelled() }}
run: make upload-test-results

- name: Tear down docker compose
if: ${{ always() }}
run: |
docker compose -f ${{ env.DOCKER_COMPOSE_FILE }} down -v

functional-test:
if: ${{ inputs.run_single_unit_test != true }}
name: Functional test
needs: misc-checks
needs: [misc-checks, set-up-single-test]
strategy:
fail-fast: false
matrix:
runs-on: [ubuntu-20.04]
runs-on: ${{ fromJson(needs.set-up-single-test.outputs.runs_on) }}
shard_index: ${{ fromJson(needs.set-up-single-test.outputs.shard_indices) }}
name:
- cass_es
- cass_es8
- sqlite
- mysql8
- postgres12
- postgres12_pgx
shard_index: [0, 1, 2]
include:
- name: cass_es
persistence_type: nosql
Expand Down Expand Up @@ -167,38 +283,52 @@ jobs:
containers: [postgresql]
runs-on: ${{ matrix.runs-on }}
env:
TEST_TOTAL_SHARDS: 3
TEST_TOTAL_SHARDS: ${{ needs.set-up-single-test.outputs.total_shards }}
TEST_SHARD_INDEX: ${{ matrix.shard_index }}
PERSISTENCE_TYPE: ${{ matrix.persistence_type }}
PERSISTENCE_DRIVER: ${{ matrix.persistence_driver }}
SINGLE_TEST_ARGS: ${{ needs.set-up-single-test.outputs.single_test_args }}
TEST_TIMEOUT: ${{ needs.set-up-single-test.outputs.test_timeout }}
BUILDKITE_MESSAGE: "{\"job\": \"functional-test\", \"db\": \"${{ matrix.persistence_driver }}\"}"
steps:
- name: Print functional test
run: echo "${{ needs.set-up-single-test.outputs.dbs }}" && echo "$SINGLE_TEST_ARGS"
- uses: ScribeMD/[email protected]
if: ${{ inputs.run_single_functional_test != true || (inputs.run_single_functional_test == true && contains(fromJSON(needs.set-up-single-test.outputs.dbs), env.PERSISTENCE_DRIVER)) }}
with:
key: docker-${{ runner.os }}-${{ hashFiles(env.DOCKER_COMPOSE_FILE) }}

- uses: actions/checkout@v4
if: ${{ inputs.run_single_functional_test != true || (inputs.run_single_functional_test == true && contains(fromJSON(needs.set-up-single-test.outputs.dbs), env.PERSISTENCE_DRIVER)) }}
with:
token: ${{ secrets.GITHUB_TOKEN }}
ref: ${{ env.COMMIT }}

- uses: actions/setup-go@v5
if: ${{ inputs.run_single_functional_test != true || (inputs.run_single_functional_test == true && contains(fromJSON(needs.set-up-single-test.outputs.dbs), env.PERSISTENCE_DRIVER)) }}
with:
go-version-file: 'go.mod'
check-latest: true

- name: Start containerized dependencies
if: ${{ toJson(matrix.containers) != '[]' }}
if: ${{ toJson(matrix.containers) != '[]' && (inputs.run_single_functional_test != true || (inputs.run_single_functional_test == true && contains(fromJSON(needs.set-up-single-test.outputs.dbs), env.PERSISTENCE_DRIVER))) }}
uses: hoverkraft-tech/[email protected]
with:
compose-file: ${{ env.DOCKER_COMPOSE_FILE }}
services: "${{ join(matrix.containers, '\n') }}"
down-flags: -v

- name: Run functional test
timeout-minutes: 30 # make sure this is larger than the test timeout in the Makefile
if: ${{ inputs.run_single_functional_test != true || (inputs.run_single_functional_test == true && contains(fromJSON(needs.set-up-single-test.outputs.dbs), env.PERSISTENCE_DRIVER)) }}
timeout-minutes: ${{ fromJSON(needs.set-up-single-test.outputs.github_timeout) }} # make sure this is larger than the test timeout in the Makefile
run: make functional-test-coverage

- name: Upload test results
if: ${{ !cancelled() }}
if: ${{ !cancelled() && (inputs.run_single_functional_test != true || (inputs.run_single_functional_test == true && contains(fromJSON(needs.set-up-single-test.outputs.dbs), env.PERSISTENCE_DRIVER))) }}
run: make upload-test-results

functional-test-xdc:
if: ${{ inputs.run_single_functional_test != true && inputs.run_single_unit_test != true }}
name: Functional test xdc
needs: misc-checks
strategy:
Expand Down Expand Up @@ -232,6 +362,7 @@ jobs:
env:
PERSISTENCE_TYPE: ${{ matrix.persistence_type }}
PERSISTENCE_DRIVER: ${{ matrix.persistence_driver }}
BUILDKITE_MESSAGE: "{\"job\": \"functional-test-xdc\", \"db\": \"${{ matrix.persistence_driver }}\"}"
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -260,6 +391,7 @@ jobs:
run: make upload-test-results

functional-test-ndc:
if: ${{ inputs.run_single_functional_test != true && inputs.run_single_unit_test != true }}
name: Functional test ndc
needs: misc-checks
strategy:
Expand Down Expand Up @@ -324,6 +456,7 @@ jobs:
run: make functional-test-ndc-coverage

test-status:
if: ${{ inputs.run_single_functional_test != true && inputs.run_single_unit_test != true }}
name: Test Status
needs:
- unit-test
Expand All @@ -332,7 +465,6 @@ jobs:
- functional-test-xdc
- functional-test-ndc
runs-on: ubuntu-20.04
if: always()
env:
RESULTS: ${{ toJSON(needs.*.result) }}
steps:
Expand Down
14 changes: 8 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ define NEWLINE

endef

TEST_TIMEOUT := 25m
TEST_TIMEOUT ?= 25m

PROTO_ROOT := proto
PROTO_FILES = $(shell find ./$(PROTO_ROOT)/internal -name "*.proto")
Expand All @@ -88,7 +88,7 @@ FUNCTIONAL_TEST_NDC_ROOT := ./tests/ndc
DB_INTEGRATION_TEST_ROOT := ./common/persistence/tests
DB_TOOL_INTEGRATION_TEST_ROOT := ./tools/tests
INTEGRATION_TEST_DIRS := $(DB_INTEGRATION_TEST_ROOT) $(DB_TOOL_INTEGRATION_TEST_ROOT) ./temporaltest ./internal/temporalite
UNIT_TEST_DIRS := $(filter-out $(FUNCTIONAL_TEST_ROOT)% $(FUNCTIONAL_TEST_XDC_ROOT)% $(FUNCTIONAL_TEST_NDC_ROOT)% $(DB_INTEGRATION_TEST_ROOT)% $(DB_TOOL_INTEGRATION_TEST_ROOT)% ./temporaltest% ./internal/temporalite%,$(TEST_DIRS))
UNIT_TEST_DIRS ?= $(filter-out $(FUNCTIONAL_TEST_ROOT)% $(FUNCTIONAL_TEST_XDC_ROOT)% $(FUNCTIONAL_TEST_NDC_ROOT)% $(DB_INTEGRATION_TEST_ROOT)% $(DB_TOOL_INTEGRATION_TEST_ROOT)% ./temporaltest% ./internal/temporalite%,$(TEST_DIRS))

# github.com/urfave/cli/[email protected] - needs to accept comma in values before unlocking https://github.com/urfave/cli/pull/1241.
PINNED_DEPENDENCIES := \
Expand Down Expand Up @@ -377,8 +377,8 @@ prepare-coverage-test: $(GOTESTSUM) $(TEST_OUTPUT_ROOT)

unit-test-coverage: prepare-coverage-test
@printf $(COLOR) "Run unit tests with coverage..."
@$(GOTESTSUM) --junitfile $(NEW_REPORT) -- \
$(UNIT_TEST_DIRS) -shuffle on -timeout=$(TEST_TIMEOUT) -race $(TEST_TAG_FLAG) -coverprofile=$(NEW_COVER_PROFILE)
$(GOTESTSUM) --junitfile $(NEW_REPORT) -- \
$(UNIT_TEST_DIRS) -shuffle on -timeout=$(TEST_TIMEOUT) -race $(TEST_TAG_FLAG) $(SINGLE_TEST_ARGS) -coverprofile=$(NEW_COVER_PROFILE)

integration-test-coverage: prepare-coverage-test
@printf $(COLOR) "Run integration tests with coverage..."
Expand All @@ -391,8 +391,10 @@ pre-build-functional-test-coverage: prepare-coverage-test

functional-test-coverage: prepare-coverage-test
@printf $(COLOR) "Run functional tests with coverage with $(PERSISTENCE_DRIVER) driver..."
@$(GOTESTSUM) --junitfile $(NEW_REPORT) -- \
$(FUNCTIONAL_TEST_ROOT) -shuffle on -timeout=$(TEST_TIMEOUT) $(TEST_ARGS) $(TEST_TAG_FLAG) -persistenceType=$(PERSISTENCE_TYPE) -persistenceDriver=$(PERSISTENCE_DRIVER) $(FUNCTIONAL_TEST_COVERPKG) -coverprofile=$(NEW_COVER_PROFILE)
$(GOTESTSUM) --junitfile $(NEW_REPORT) -- \
$(FUNCTIONAL_TEST_ROOT) -shuffle on -timeout=$(TEST_TIMEOUT) $(TEST_ARGS) $(SINGLE_TEST_ARGS) $(TEST_TAG_FLAG) \
-persistenceType=$(PERSISTENCE_TYPE) -persistenceDriver=$(PERSISTENCE_DRIVER) \
$(FUNCTIONAL_TEST_COVERPKG) -coverprofile=$(NEW_COVER_PROFILE)

functional-test-xdc-coverage: prepare-coverage-test
@printf $(COLOR) "Run functional test for cross DC with coverage with $(PERSISTENCE_DRIVER) driver..."
Expand Down
3 changes: 2 additions & 1 deletion develop/upload-test-results.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ for file in *.junit.xml; do
-F "run_env[branch]=${GITHUB_REF}" \
-F "run_env[commit_sha]=${GITHUB_SHA}" \
-F "run_env[url]=https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" \
-F "run_env[message]=${BUILDKITE_MESSAGE}" \
https://analytics-api.buildkite.com/v1/uploads
done
done
Loading