Skip to content

Commit

Permalink
Fix integration tests (#454)
Browse files Browse the repository at this point in the history
Fixes #432 

This PR uses upstream's test setup to create a local testing keycloak
harness. The deleted test files were copy and pasted from upstream
originally, so nothing significant has changed in their contents,
excepting that they were updated for keycloak's modern API paths.
  • Loading branch information
iwahbe authored Apr 8, 2024
1 parent f9bf7ba commit 398cd83
Show file tree
Hide file tree
Showing 16 changed files with 216 additions and 202 deletions.
10 changes: 7 additions & 3 deletions .ci-mgmt.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
provider: keycloak
docker: true
setup-script: "testing/setup.sh"
major-version: 5
env: # these are in plaintext in the setup script
KEYCLOAK_CLIENT_ID: "terraform"
KEYCLOAK_CLIENT_SECRET: "884e0f95-0f42-4a63-9b1f-94274655669e"
KEYCLOAK_PASSWORD: "password"
KEYCLOAK_URL: "http://localhost:8080/auth"
KEYCLOAK_URL: "http://localhost:8080"
KEYCLOAK_USER: "keycloak"
makeTemplate: bridged
plugins:
- name: aws
version: "4.2.0"
actions:
preTest:
- name: Ensure upstream
run: make upstream
- name: Setup local Keycloak
run: make -C upstream local
2 changes: 1 addition & 1 deletion .github/workflows/command-dispatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ env:
KEYCLOAK_CLIENT_ID: terraform
KEYCLOAK_CLIENT_SECRET: 884e0f95-0f42-4a63-9b1f-94274655669e
KEYCLOAK_PASSWORD: password
KEYCLOAK_URL: http://localhost:8080/auth
KEYCLOAK_URL: http://localhost:8080
KEYCLOAK_USER: keycloak
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NODEVERSION: 20.x
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/license.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ env:
KEYCLOAK_CLIENT_ID: terraform
KEYCLOAK_CLIENT_SECRET: 884e0f95-0f42-4a63-9b1f-94274655669e
KEYCLOAK_PASSWORD: password
KEYCLOAK_URL: http://localhost:8080/auth
KEYCLOAK_URL: http://localhost:8080
KEYCLOAK_USER: keycloak
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NODEVERSION: 20.x
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ env:
KEYCLOAK_CLIENT_ID: terraform
KEYCLOAK_CLIENT_SECRET: 884e0f95-0f42-4a63-9b1f-94274655669e
KEYCLOAK_PASSWORD: password
KEYCLOAK_URL: http://localhost:8080/auth
KEYCLOAK_URL: http://localhost:8080
KEYCLOAK_USER: keycloak
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NODEVERSION: 20.x
Expand Down
55 changes: 46 additions & 9 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ env:
KEYCLOAK_CLIENT_ID: terraform
KEYCLOAK_CLIENT_SECRET: 884e0f95-0f42-4a63-9b1f-94274655669e
KEYCLOAK_PASSWORD: password
KEYCLOAK_URL: http://localhost:8080/auth
KEYCLOAK_URL: http://localhost:8080
KEYCLOAK_USER: keycloak
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NODEVERSION: 20.x
Expand Down Expand Up @@ -133,6 +133,7 @@ jobs:
- dotnet
- go
- java

generate_coverage_data:
continue-on-error: true
env:
Expand Down Expand Up @@ -217,12 +218,15 @@ jobs:
ref: deca2c5c6015ad7aaea6f572a1c2b198ca323592
- name: Unshallow clone for tags
run: git fetch --prune --unshallow --tags
- name: Prepare upstream code
run: make upstream
- name: Install Go
uses: actions/setup-go@v5
with:
cache-dependency-path: |
sdk/go.sum
go-version: 1.21.x
cache-dependency-path: |
provider/*.sum
upstream/*.sum
- name: Install pulumictl
uses: jaxxstorm/[email protected]
with:
Expand All @@ -237,8 +241,14 @@ jobs:
uses: jaxxstorm/[email protected]
with:
repo: pulumi/schema-tools
- name: Build tfgen & provider binaries
run: make provider
- name: Build schema generator binary
run: make tfgen_build_only
- name: Install plugins
run: make install_plugins
- name: Generate schema
run: make tfgen_no_deps
- name: Build provider binary
run: make provider_no_deps
- name: Unit-test provider code
run: make test_provider
- if: github.event_name == 'pull_request'
Expand All @@ -265,6 +275,33 @@ jobs:
Maintainer note: consult the [runbook](https://github.com/pulumi/platform-providers-team/blob/main/playbooks/tf-provider-updating.md) for dealing with any breaking changes.
- if: github.event_name == 'pull_request'
name: Check Configuration section
run: |
sed -n '/## Configuration/,$p' README.md | sed -n '/## Reference/q;p' >> config_section.txt
jq -r '.config | select(.variables) | .variables | keys[]' < provider/cmd/pulumi-resource-${{ env.PROVIDER }}/schema.json >> keys.txt
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
{
echo "MISSING_CONFIG<<$EOF";
xargs -I {} sh -c "grep -q {} config_section.txt || echo \\\`{}\\\` not found in Configuration section" < keys.txt
echo "$EOF";
} >> "$GITHUB_ENV"
- if: github.event_name == 'pull_request' && github.actor != 'dependabot[bot]'
name: Comment on PR with Details of Configuration check
uses: thollander/actions-comment-pull-request@v2
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
comment_tag: configurationCheck
message: >+
### Is README.md missing any configuration options?
${{ env.MISSING_CONFIG || 'No missing config!' }}
${{ env.MISSING_CONFIG && 'Please add a description for each of these options to `README.md`.' }}
${{ env.MISSING_CONFIG && 'Details about them can be found in either the upstream docs or `schema.json`.' }}
- name: Tar provider binaries
run: tar -zcf ${{ github.workspace }}/bin/provider.tar.gz -C ${{
github.workspace }}/bin/ pulumi-resource-${{ env.PROVIDER }}
Expand Down Expand Up @@ -462,17 +499,17 @@ jobs:
run: |-
pip3 install virtualenv==20.0.23
pip3 install pipenv
- name: Run docker-compose
run: docker-compose -f testing/docker-compose.yml up --build -d
- name: Run setup script
run: testing/setup.sh
- name: Install dependencies
run: make install_${{ matrix.language}}_sdk
- name: Install gotestfmt
uses: GoTestTools/gotestfmt-action@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: v2.5.0
- name: Ensure upstream
run: make upstream
- name: Setup local Keycloak
run: make -C upstream local
- name: Run tests
run: cd examples && go test -v -json -count=1 -cover -timeout 2h -tags=${{
matrix.language }} -parallel 4 . 2>&1 | tee /tmp/gotest.log | gotestfmt
Expand Down
56 changes: 47 additions & 9 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ env:
KEYCLOAK_CLIENT_ID: terraform
KEYCLOAK_CLIENT_SECRET: 884e0f95-0f42-4a63-9b1f-94274655669e
KEYCLOAK_PASSWORD: password
KEYCLOAK_URL: http://localhost:8080/auth
KEYCLOAK_URL: http://localhost:8080
KEYCLOAK_USER: keycloak
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NODEVERSION: 20.x
Expand Down Expand Up @@ -117,6 +117,7 @@ jobs:
with:
name: ${{ matrix.language }}-sdk.tar.gz
path: ${{ github.workspace}}/sdk/${{ matrix.language }}.tar.gz
retention-days: 30
- if: failure() && github.event_name == 'push'
name: Notify Slack
uses: 8398a7/action-slack@v3
Expand All @@ -133,6 +134,7 @@ jobs:
- dotnet
- go
- java

lint:
name: lint
uses: ./.github/workflows/lint.yml
Expand All @@ -155,12 +157,15 @@ jobs:
ref: deca2c5c6015ad7aaea6f572a1c2b198ca323592
- name: Unshallow clone for tags
run: git fetch --prune --unshallow --tags
- name: Prepare upstream code
run: make upstream
- name: Install Go
uses: actions/setup-go@v5
with:
cache-dependency-path: |
sdk/go.sum
go-version: 1.21.x
cache-dependency-path: |
provider/*.sum
upstream/*.sum
- name: Install pulumictl
uses: jaxxstorm/[email protected]
with:
Expand All @@ -175,8 +180,14 @@ jobs:
uses: jaxxstorm/[email protected]
with:
repo: pulumi/schema-tools
- name: Build tfgen & provider binaries
run: make provider
- name: Build schema generator binary
run: make tfgen_build_only
- name: Install plugins
run: make install_plugins
- name: Generate schema
run: make tfgen_no_deps
- name: Build provider binary
run: make provider_no_deps
- name: Unit-test provider code
run: make test_provider
- if: github.event_name == 'pull_request'
Expand All @@ -203,6 +214,33 @@ jobs:
Maintainer note: consult the [runbook](https://github.com/pulumi/platform-providers-team/blob/main/playbooks/tf-provider-updating.md) for dealing with any breaking changes.
- if: github.event_name == 'pull_request'
name: Check Configuration section
run: |
sed -n '/## Configuration/,$p' README.md | sed -n '/## Reference/q;p' >> config_section.txt
jq -r '.config | select(.variables) | .variables | keys[]' < provider/cmd/pulumi-resource-${{ env.PROVIDER }}/schema.json >> keys.txt
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
{
echo "MISSING_CONFIG<<$EOF";
xargs -I {} sh -c "grep -q {} config_section.txt || echo \\\`{}\\\` not found in Configuration section" < keys.txt
echo "$EOF";
} >> "$GITHUB_ENV"
- if: github.event_name == 'pull_request' && github.actor != 'dependabot[bot]'
name: Comment on PR with Details of Configuration check
uses: thollander/actions-comment-pull-request@v2
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
comment_tag: configurationCheck
message: >+
### Is README.md missing any configuration options?
${{ env.MISSING_CONFIG || 'No missing config!' }}
${{ env.MISSING_CONFIG && 'Please add a description for each of these options to `README.md`.' }}
${{ env.MISSING_CONFIG && 'Details about them can be found in either the upstream docs or `schema.json`.' }}
- name: Tar provider binaries
run: tar -zcf ${{ github.workspace }}/bin/provider.tar.gz -C ${{
github.workspace }}/bin/ pulumi-resource-${{ env.PROVIDER }}
Expand Down Expand Up @@ -382,17 +420,17 @@ jobs:
run: |-
pip3 install virtualenv==20.0.23
pip3 install pipenv
- name: Run docker-compose
run: docker-compose -f testing/docker-compose.yml up --build -d
- name: Run setup script
run: testing/setup.sh
- name: Install dependencies
run: make install_${{ matrix.language}}_sdk
- name: Install gotestfmt
uses: GoTestTools/gotestfmt-action@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: v2.5.0
- name: Ensure upstream
run: make upstream
- name: Setup local Keycloak
run: make -C upstream local
- name: Run tests
run: cd examples && go test -v -json -count=1 -cover -timeout 2h -tags=${{
matrix.language }} -parallel 4 . 2>&1 | tee /tmp/gotest.log | gotestfmt
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ env:
KEYCLOAK_CLIENT_ID: terraform
KEYCLOAK_CLIENT_SECRET: 884e0f95-0f42-4a63-9b1f-94274655669e
KEYCLOAK_PASSWORD: password
KEYCLOAK_URL: http://localhost:8080/auth
KEYCLOAK_URL: http://localhost:8080
KEYCLOAK_USER: keycloak
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NODEVERSION: 20.x
Expand Down
56 changes: 47 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ env:
KEYCLOAK_CLIENT_ID: terraform
KEYCLOAK_CLIENT_SECRET: 884e0f95-0f42-4a63-9b1f-94274655669e
KEYCLOAK_PASSWORD: password
KEYCLOAK_URL: http://localhost:8080/auth
KEYCLOAK_URL: http://localhost:8080
KEYCLOAK_USER: keycloak
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NODEVERSION: 20.x
Expand Down Expand Up @@ -116,6 +116,7 @@ jobs:
with:
name: ${{ matrix.language }}-sdk.tar.gz
path: ${{ github.workspace}}/sdk/${{ matrix.language }}.tar.gz
retention-days: 30
- if: failure() && github.event_name == 'push'
name: Notify Slack
uses: 8398a7/action-slack@v3
Expand All @@ -132,6 +133,7 @@ jobs:
- dotnet
- go
- java

create_docs_build:
name: create_docs_build
needs: tag_sdk
Expand Down Expand Up @@ -169,12 +171,15 @@ jobs:
ref: deca2c5c6015ad7aaea6f572a1c2b198ca323592
- name: Unshallow clone for tags
run: git fetch --prune --unshallow --tags
- name: Prepare upstream code
run: make upstream
- name: Install Go
uses: actions/setup-go@v5
with:
cache-dependency-path: |
sdk/go.sum
go-version: 1.21.x
cache-dependency-path: |
provider/*.sum
upstream/*.sum
- name: Install pulumictl
uses: jaxxstorm/[email protected]
with:
Expand All @@ -189,8 +194,14 @@ jobs:
uses: jaxxstorm/[email protected]
with:
repo: pulumi/schema-tools
- name: Build tfgen & provider binaries
run: make provider
- name: Build schema generator binary
run: make tfgen_build_only
- name: Install plugins
run: make install_plugins
- name: Generate schema
run: make tfgen_no_deps
- name: Build provider binary
run: make provider_no_deps
- name: Unit-test provider code
run: make test_provider
- if: github.event_name == 'pull_request'
Expand All @@ -217,6 +228,33 @@ jobs:
Maintainer note: consult the [runbook](https://github.com/pulumi/platform-providers-team/blob/main/playbooks/tf-provider-updating.md) for dealing with any breaking changes.
- if: github.event_name == 'pull_request'
name: Check Configuration section
run: |
sed -n '/## Configuration/,$p' README.md | sed -n '/## Reference/q;p' >> config_section.txt
jq -r '.config | select(.variables) | .variables | keys[]' < provider/cmd/pulumi-resource-${{ env.PROVIDER }}/schema.json >> keys.txt
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
{
echo "MISSING_CONFIG<<$EOF";
xargs -I {} sh -c "grep -q {} config_section.txt || echo \\\`{}\\\` not found in Configuration section" < keys.txt
echo "$EOF";
} >> "$GITHUB_ENV"
- if: github.event_name == 'pull_request' && github.actor != 'dependabot[bot]'
name: Comment on PR with Details of Configuration check
uses: thollander/actions-comment-pull-request@v2
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
comment_tag: configurationCheck
message: >+
### Is README.md missing any configuration options?
${{ env.MISSING_CONFIG || 'No missing config!' }}
${{ env.MISSING_CONFIG && 'Please add a description for each of these options to `README.md`.' }}
${{ env.MISSING_CONFIG && 'Details about them can be found in either the upstream docs or `schema.json`.' }}
- name: Tar provider binaries
run: tar -zcf ${{ github.workspace }}/bin/provider.tar.gz -C ${{
github.workspace }}/bin/ pulumi-resource-${{ env.PROVIDER }}
Expand Down Expand Up @@ -430,17 +468,17 @@ jobs:
run: |-
pip3 install virtualenv==20.0.23
pip3 install pipenv
- name: Run docker-compose
run: docker-compose -f testing/docker-compose.yml up --build -d
- name: Run setup script
run: testing/setup.sh
- name: Install dependencies
run: make install_${{ matrix.language}}_sdk
- name: Install gotestfmt
uses: GoTestTools/gotestfmt-action@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: v2.5.0
- name: Ensure upstream
run: make upstream
- name: Setup local Keycloak
run: make -C upstream local
- name: Run tests
run: cd examples && go test -v -json -count=1 -cover -timeout 2h -tags=${{
matrix.language }} -parallel 4 . 2>&1 | tee /tmp/gotest.log | gotestfmt
Expand Down
Loading

0 comments on commit 398cd83

Please sign in to comment.