Skip to content

Commit

Permalink
publish end to end test summary reports for arm, bicep and terraform (#…
Browse files Browse the repository at this point in the history
…37)

publish end to end test summary reports for arm, bicep and terraform
  • Loading branch information
maniSbindra authored Mar 21, 2024
1 parent 2e5d8dd commit b1b4fe1
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 23 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/az-mpf-e2e-arm-bicep.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@ jobs:
export MPF_BICEPEXECPATH=/usr/local/bin/bicep
go install github.com/jstemmer/go-junit-report@latest
go test ./e2eTests -v -run TestARM TestBicep | tee TestResults-${{ matrix.go-version }}.txt
# | go-junit-report -set-exit-code > TestResults-${{ matrix.go-version }}.xml
cat TestResults-${{ matrix.go-version }}.txt | go-junit-report -set-exit-code > TestResults-${{ matrix.go-version }}.xml
- name: Upload Go test results
uses: actions/upload-artifact@v4
with:
name: Go-results-${{ matrix.go-version }}
path: TestResults-${{ matrix.go-version }}.txt
path: TestResults-${{ matrix.go-version }}.xml

# - name: Test Summary
# uses: test-summary/action@v1
# with:
# paths: |
# TestResults-${{ matrix.go-version }}.xml
# if: always()
- name: Test Summary
uses: test-summary/action@v1
with:
paths: |
TestResults-${{ matrix.go-version }}.xml
if: always()
36 changes: 22 additions & 14 deletions .github/workflows/az-mpf-e2e-terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,18 @@ jobs:
with:
go-version: ${{ matrix.go-version }}

- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.5.7
# - name: Setup Terraform
# uses: hashicorp/setup-terraform@v3
# with:
# terraform_version: 1.5.7
- name: Install Terraform
run: |
curl -Lo terraform.zip https://releases.hashicorp.com/terraform/1.5.7/terraform_1.5.7_linux_amd64.zip
unzip terraform.zip
# move to working directory
sudo mv terraform /usr/local/bin/terraform
terraform --version
- name: Install dependencies
run: go get ./...
Expand All @@ -47,22 +55,22 @@ jobs:

- name: Test with Go
run: |
# cd e2eTests
which terraform
export MPF_TFPATH=$(which terraform)
export MPF_TFPATH="/usr/local/bin/terraform"
$MPF_TFPATH --version
go install github.com/jstemmer/go-junit-report@latest
go test ./e2eTests -v -timeout 20m -run TestTerraform | tee TestResults-${{ matrix.go-version }}.txt
# | go-junit-report -set-exit-code > TestResults-${{ matrix.go-version }}.xml
cat TestResults-${{ matrix.go-version }}.txt | go-junit-report -set-exit-code > TestResults-${{ matrix.go-version }}.xml
- name: Upload Go test results
uses: actions/upload-artifact@v4
with:
name: Go-results-${{ matrix.go-version }}
path: TestResults-${{ matrix.go-version }}.txt
path: TestResults-${{ matrix.go-version }}.xml

# - name: Test Summary
# uses: test-summary/action@v1
# with:
# paths: |
# TestResults-${{ matrix.go-version }}.xml
# if: always()
- name: Test Summary
uses: test-summary/action@v1
with:
paths: |
TestResults-${{ matrix.go-version }}.xml
if: always()
4 changes: 4 additions & 0 deletions e2eTests/e2eTerraform_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
resourceGroupManager "github.com/manisbindra/az-mpf/pkg/infrastructure/resourceGroupManager"
sproleassignmentmanager "github.com/manisbindra/az-mpf/pkg/infrastructure/spRoleAssignmentManager"
"github.com/manisbindra/az-mpf/pkg/usecase"
log "github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
)

Expand All @@ -30,8 +31,11 @@ func TestTerraformACI(t *testing.T) {

_, filename, _, _ := runtime.Caller(0)
curDir := path.Dir(filename)
log.Infof("curDir: %s", curDir)
wrkDir := path.Join(curDir, "../samples/terraform/aci")
log.Infof("wrkDir: %s", wrkDir)
varsFile := path.Join(curDir, "../samples/terraform/aci/dev.vars.tfvars")
log.Infof("varsFile: %s", varsFile)

ctx := context.Background()

Expand Down
2 changes: 1 addition & 1 deletion pkg/domain/authorizationErrorParser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestSingleAuthorizationSpaceFailedError(t *testing.T) {
}

func TestSingleLinkedAuthorizationFailedError(t *testing.T) {
singleLinkedAuthorizationFailedError := "error: LinkedAuthorizationFailed: The client '***REMOVED***' with object id '***REMOVED***' has permission to perform action 'Microsoft.ContainerService/managedClusters/write' on scope '/subscriptions/SSSSSSSS-SSSS-SSSS-SSSS-SSSSSSSSSSSS/resourceGroups/az-mpf-tf-test-rg/providers/Microsoft.ContainerService/managedClusters/aks-32a70ccbb3247e2b'; however, it does not have permission to perform action(s) 'Microsoft.Network/virtualNetworks/subnets/join/action' on the linked scope(s) '/subscriptions/SSSSSSSS-SSSS-SSSS-SSSS-SSSSSSSSSSSS/resourceGroups/az-mpf-tf-test-rg/providers/Microsoft.Network/virtualNetworks/vnet-32a70ccbb3247e2b/subnets/subnet-32a70ccbb3247e2b' (respectively) or the linked scope(s) are invalid."
singleLinkedAuthorizationFailedError := "error: LinkedAuthorizationFailed: The client 'a31fc7f1-1349-4b3c-af16-60422be430cc' with object id 'a31fc7f1-1349-4b3c-af16-60422be430cc' has permission to perform action 'Microsoft.ContainerService/managedClusters/write' on scope '/subscriptions/SSSSSSSS-SSSS-SSSS-SSSS-SSSSSSSSSSSS/resourceGroups/az-mpf-tf-test-rg/providers/Microsoft.ContainerService/managedClusters/aks-32a70ccbb3247e2b'; however, it does not have permission to perform action(s) 'Microsoft.Network/virtualNetworks/subnets/join/action' on the linked scope(s) '/subscriptions/SSSSSSSS-SSSS-SSSS-SSSS-SSSSSSSSSSSS/resourceGroups/az-mpf-tf-test-rg/providers/Microsoft.Network/virtualNetworks/vnet-32a70ccbb3247e2b/subnets/subnet-32a70ccbb3247e2b' (respectively) or the linked scope(s) are invalid."
spm, err := GetScopePermissionsFromAuthError(singleLinkedAuthorizationFailedError)
l := len(spm)
assert.Nil(t, err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ func (a *terraformDeploymentConfig) CleanDeployment(mpfConfig domain.MPFConfig)

func (a *terraformDeploymentConfig) deployTerraform(mpfConfig domain.MPFConfig) (string, error) {

log.Infof("workingDir: %s", a.workingDir)
log.Infof("varfilePath: %s", a.varFilePath)
log.Infof("execPath: %s", a.execPath)

tf, err := tfexec.NewTerraform(a.workingDir, a.execPath)
if err != nil {
log.Fatalf("error running NewTerraform: %s", err)
Expand Down

0 comments on commit b1b4fe1

Please sign in to comment.