Skip to content

Commit

Permalink
feat: Adding GHA workflow for UAT Test Suite
Browse files Browse the repository at this point in the history
  • Loading branch information
srushti-patl committed Mar 4, 2024
1 parent 287758f commit 12683ca
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 0 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/test-uat-suite.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: terratests-uat-suite

on:
pull_request:
workflow_dispatch:

jobs:
setup-tests:
name: Setup UAT Tests
runs-on: ubuntu-latest
env:
EQUINIX_API_ENDPOINT: "https://uatapi.equinix.com"
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
id: actions-checkout
with:
ref: main

- name: Check out code into the Go module directory
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: './go.mod'
id: go

- name: Get dependencies
run: |
go mod download
- uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ matrix.terraform }}
terraform_wrapper: false

- name: Setup Variables Files
run:
# Parse secret content
secret_content=${{ steps.read_secret.outputs.secret_content }}

# Use conditional logic to map secret content to test directories
if [[ "$secret_content" == *"port-connection-port-zside"* ]]; then
echo "$secret_content" > examples/port-2-port-connection/terraform.tfvars.json
fi

- name: Run Go Tests
run:
go test ./tests/uat -v -coverprofile coverage_uat_modules.txt -covermode=atomic -count 1 -parallel 8 -timeout 180m

- name: Upload test coverage to Codecov
if: ${{ always() }}
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage_uat_modules.txt
2 changes: 2 additions & 0 deletions examples/port-2-port-connection/variables.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
variable "equinix_client_id" {
description = "Equinix client ID (consumer key), obtained after registering app in the developer platform"
type = string
sensitive = true
}
variable "equinix_client_secret" {
description = "Equinix client secret ID (consumer secret), obtained after registering app in the developer platform"
type = string
sensitive = true
}

variable "connection_name" {
Expand Down
8 changes: 8 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module github.com/equinix/terraform-equinix-fabric

go 1.16

require (
github.com/gruntwork-io/terratest v0.43.0
github.com/stretchr/testify v1.8.4
)
26 changes: 26 additions & 0 deletions tests/uat/port-connection-port-zside_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package uat

import (
"fmt"
"github.com/gruntwork-io/terratest/modules/terraform"
"github.com/stretchr/testify/assert"
"os"
"testing"
)

func TestPort2PortCreateConnection(t *testing.T) {
// retryable errors in terraform testing.

cwd, _ := os.Getwd()
fmt.Println("Current working directory:", cwd)

terraformOptions := terraform.WithDefaultRetryableErrors(t, &terraform.Options{
TerraformDir: "../../examples/port-2-port-connection",
})

defer terraform.Destroy(t, terraformOptions)

terraform.InitAndApply(t, terraformOptions)
output := terraform.Output(t, terraformOptions, "connection_result")
assert.NotNil(t, output)
}

0 comments on commit 12683ca

Please sign in to comment.