Skip to content

Commit

Permalink
chore: parameterize integration tests
Browse files Browse the repository at this point in the history
refactors integration tests to execute identically across runtimes

with this change, we can also specify tests to run with the integration-test script (e.g. `integration-tests TestLifecycle` — all tests are fully encapsulated and can execute alone). providing no option will run all tests.

tests have been split into the following:

- TestLifecycle (init, deploy, call)
- TestHttpIngress (tests all http methods and tests aliased fields)
- TestDatabase
- TestExternalCalls (kotlin -> go call, kotlin -> kotlin call, etc. for all runtime permutations)

a couple small changes captured by the integration tests are also included in this PR:
- Database.kt converts module name and DB name to uppercase to align with the Go DB SDK
- Kotlin schema extractor includes module names for all DataRef schema objects, even those declared in the referencing module (this fixes builtin.HttpRequest/Response types for HTTP ingress in Kotlin)
  • Loading branch information
worstell committed Jan 31, 2024
1 parent bab131b commit 7e7a12e
Show file tree
Hide file tree
Showing 13 changed files with 582 additions and 115 deletions.
50 changes: 47 additions & 3 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,63 @@ concurrency:
cancel-in-progress: true
name: Integration
jobs:
build:
name: Build JARs
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Init Hermit
uses: cashapp/activate-hermit@v1
- name: Build JAR
run: just install-jars
- name: Archive JARs
uses: actions/upload-artifact@v2
with:
name: jars
path: |
kotlin-runtime/ftl-generator/target/ftl-generator-1.0-SNAPSHOT.jar
kotlin-runtime/ftl-runtime/target/ftl-runtime-1.0-SNAPSHOT.jar
prepare:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-tests.outputs.matrix }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Init Hermit
uses: cashapp/activate-hermit@v1
- name: Extract test cases
id: extract-tests
run: |
echo "::set-output name=cases::$(go test -v -list . ./integration | grep '^Test' | awk '{print $1}' | cut -d '(' -f1 | tr '\n' ',' | sed 's/,$//')"
- name: Format test matrix
id: set-tests
run: |
IFS=',' read -ra TESTS <<< "${{ steps.extract-tests.outputs.cases }}"
TEST_JSON=$(printf ',"%s"' "${TESTS[@]}")
TEST_JSON="[${TEST_JSON:1}]"
echo "::set-output name=matrix::{\"test\": $TEST_JSON}"
integration:
name: Integration tests
needs: prepare
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{fromJson(needs.prepare.outputs.matrix)}}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Init Hermit
uses: cashapp/activate-hermit@v1
- name: Build Cache
uses: ./.github/actions/build-cache
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: jars
- name: Docker Compose
run: docker compose up -d --wait
- name: Download Go Modules
run: go mod download
- name: Integration tests
run: go test -v -tags integration ./integration
- name: Run ${{ matrix.test }}
run: go test -v -tags integration -run ${{ matrix.test }} ./integration
Loading

0 comments on commit 7e7a12e

Please sign in to comment.