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

Fix the cloud region data source #581

Merged
merged 11 commits into from
Dec 8, 2023
110 changes: 83 additions & 27 deletions .github/workflows/integration-tests.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
# This workflow splits the tests to run across multiple nodes. This significantly reduces the testing time, as the
# tests require starting Octopus, MSSQL, and then running Terraform against the Octopus instance.
# See # Refer to https://github.com/hashicorp-forge/go-test-split-action for more information on how the tests are split.

name: Integration Tests
'on':
workflow_dispatch: {}
push: {}
jobs:
build:
tests:
name: Test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
parallel: [ 15 ]
index: [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 ]

steps:
- uses: actions/checkout@v3
- name: Install Terraform
Expand All @@ -13,8 +24,6 @@ jobs:
terraform_wrapper: false
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.20.5
- uses: actions/setup-python@v4
with:
python-version: '3.10'
Expand All @@ -41,6 +50,21 @@ jobs:
--header "X-GitHub-Api-Version: 2022-11-28" | jq -r '"GIT_CREDENTIAL=" + .token' > "$GITHUB_ENV"
env:
GH_APP_INSTALLATION_ID: ${{ secrets.GH_APP_INSTALLATION_ID }}
- name: Download JUnit Summary from Previous Workflow
id: download-artifact
uses: dawidd6/action-download-artifact@v2
mcasperson marked this conversation as resolved.
Show resolved Hide resolved
with:
workflow_conclusion: success
name: junit-test-summary
if_no_artifact_found: warn
branch: main
- name: Split integration tests
id: test_split
uses: hashicorp-forge/go-test-split-action@v1
with:
index: ${{ matrix.index }}
total: ${{ matrix.parallel }}
junit-summary: ./junit-test-summary.xml
- name: Install Dependencies
run: go get ./...
shell: bash
Expand All @@ -56,25 +80,10 @@ jobs:
direct {}
}
EOT
- name: Install gotestsum
run: go install gotest.tools/gotestsum@latest
shell: bash
# The GitHub token we generated is valid for an hour. The full test suite can run for longer than an hour.
# So we first run the git tests while the token is fresh, and the run the rest of the tests.
- name: Test Git integration
run: go test -v -timeout 0 -run "^\\QTestProjectWithGitUsernameExport\\E$" integration_test.go
shell: bash
env:
LICENSE: ${{ secrets.OCTOPUS_SERVER_BASE64_LICENSE }}
ECR_ACCESS_KEY: ${{ secrets.ECR_ACCESS_KEY }}
ECR_SECRET_KEY: ${{ secrets.ECR_SECRET_KEY }}
GIT_USERNAME: x-access-token
OCTODISABLEOCTOCONTAINERLOGGING: true
OCTOTESTSKIPINIT: true
GOMAXPROCS: 1
OCTOTESTVERSION: 2023.2
- name: Test everything else
run: gotestsum --junitfile results.xml -- -v -timeout 0 -skip "^\\QTestProjectWithGitUsernameExport\\E$" -json integration_test.go
- name: Test integration tests
run: |
GOBIN=$PWD/bin go install gotest.tools/gotestsum@latest
./bin/gotestsum --junitfile node-summary.xml --format short-verbose -- -run "${{ steps.test_split.outputs.run }}" -timeout 0 integration_test.go
shell: bash
env:
LICENSE: ${{ secrets.OCTOPUS_SERVER_BASE64_LICENSE }}
Expand All @@ -84,15 +93,62 @@ jobs:
OCTODISABLEOCTOCONTAINERLOGGING: true
OCTOTESTSKIPINIT: true
GOMAXPROCS: 1
OCTOTESTVERSION: 2023.2
- if: always()
name: Report
OCTOTESTVERSION: 2023.4
- name: Upload test artifacts
uses: actions/upload-artifact@v3
with:
name: junit-test-summary-${{ matrix.index }}
path: node-summary.xml
retention-days: 1
mcasperson marked this conversation as resolved.
Show resolved Hide resolved

tests-combine-summaries:
name: Combine Test Reports
needs: [ tests ]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- uses: actions/setup-node@v3

- name: Download artifacts
uses: actions/download-artifact@v3

- name: Install junit-report-merger
run: npm install -g junit-report-merger

- name: Merge reports
run: >
jrm ./junit-test-summary.xml
"junit-test-summary-0/*.xml"
"junit-test-summary-1/*.xml"
"junit-test-summary-2/*.xml"
"junit-test-summary-3/*.xml"
"junit-test-summary-4/*.xml"
"junit-test-summary-5/*.xml"
"junit-test-summary-6/*.xml"
"junit-test-summary-7/*.xml"
"junit-test-summary-8/*.xml"
"junit-test-summary-9/*.xml"
"junit-test-summary-10/*.xml"
"junit-test-summary-11/*.xml"
"junit-test-summary-12/*.xml"
"junit-test-summary-13/*.xml"
"junit-test-summary-14/*.xml"

- name: Upload test artifacts
uses: actions/upload-artifact@v3
with:
name: junit-test-summary
path: ./junit-test-summary.xml

- name: Report
uses: dorny/test-reporter@v1
with:
name: Go Tests
path: results.xml
path: junit-test-summary.xml
reporter: java-junit
fail-on-error: 'false'
fail-on-error: 'true'
permissions:
id-token: write
checks: write
Expand Down
2 changes: 1 addition & 1 deletion integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2311,7 +2311,7 @@ func TestCloudRegionTargetResource(t *testing.T) {
err = testFramework.TerraformInitAndApply(t, container, filepath.Join("./terraform", "33a-cloudregiontargetds"), newSpaceId, []string{})

if err != nil {
t.Log("BUG: cloud region data source does not appear to work")
t.Fatal("cloud region data source does not appear to work")
}

// Assert
Expand Down
2 changes: 0 additions & 2 deletions octopusdeploy/schema_cloud_region_deployment_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ func getCloudRegionDeploymentTargetDataSchema() map[string]*schema.Schema {
func getCloudRegionDeploymentTargetSchema() map[string]*schema.Schema {
cloudRegionDeploymentTargetSchema := getDeploymentTargetSchema()

delete(cloudRegionDeploymentTargetSchema, "endpoint")

cloudRegionDeploymentTargetSchema["default_worker_pool_id"] = &schema.Schema{
Optional: true,
Type: schema.TypeString,
Expand Down
Loading