Skip to content

Commit

Permalink
gh: Adjusted github actions for zs2
Browse files Browse the repository at this point in the history
  • Loading branch information
willguibr committed Feb 14, 2024
1 parent 1c7d3ce commit 561e447
Show file tree
Hide file tree
Showing 6 changed files with 154 additions and 9 deletions.
70 changes: 69 additions & 1 deletion .github/workflows/zia-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ jobs:
environment:
- ZIA_ZSCLOUD
- ZIA_ZS0
- ZIA_ZS2
- ZIA_ZS3
environment: ${{ matrix.environment }}
steps:
Expand Down Expand Up @@ -224,3 +223,72 @@ jobs:
ZIA_ACC_TEST_FORCE_SWEEPERS: ${{ secrets.ZIA_ACC_TEST_FORCE_SWEEPERS }}
needs:
- zia-zsbeta-tests

zia-zscalertwo-test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
goVersion: ["1.20"]
environment:
- ZIA_ZS2
environment: ${{ matrix.environment }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.goVersion }}

- name: Set Go env
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Setup Go Tools
run: make tools

- name: Download Go Dependencies
run: |
go mod tidy && go mod vendor
- name: Setup Go Tools
run: make tools

- name: Check Formatting
run: make fmtcheck

- name: Vet Code
run: make vet

- name: Lint Code
run: make lint

- name: Check Build
run: make build

- name: Run tests with retry on Ubuntu
uses: nick-fields/retry@v3
with:
max_attempts: 3
timeout_minutes: 60 # Adjust as needed
command: |
make sweep
make test:integration:zscalertwo
make sweep
env:
ZIA_USERNAME: ${{ secrets.ZIA_USERNAME }}
ZIA_PASSWORD: ${{ secrets.ZIA_PASSWORD }}
ZIA_API_KEY: ${{ secrets.ZIA_API_KEY }}
ZIA_CLOUD: ${{ secrets.ZIA_CLOUD }}
ZIA_SANDBOX_TOKEN: ${{ secrets.ZIA_SANDBOX_TOKEN }}
ZPA_CLIENT_ID: ${{ secrets.ZPA_CLIENT_ID }}
ZPA_CLIENT_SECRET: ${{ secrets.ZPA_CLIENT_SECRET }}
ZPA_CUSTOMER_ID: ${{ secrets.ZPA_CUSTOMER_ID }}
ZPA_CLOUD: ${{ secrets.ZPA_CLOUD }}
TF_ACC: ${{ secrets.TF_ACC }}
ZIA_ACC_TEST_FORCE_SWEEPERS: ${{ secrets.ZIA_ACC_TEST_FORCE_SWEEPERS }}
needs:
- zia-zsbeta-tests
71 changes: 71 additions & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,77 @@ test\:integration\:zscalerone:
@echo "Running integration tests for ZscalerOne..."
@TF_ACC=1 go test -v -cover ./zia -timeout 120m -run ^$(integration_tests)$$

# Default set of integration tests to run for ZscalerOne
ZS2_INTEGRATION_TESTS?=\
TestAccDataSourceActivationStatus_Basic \
TestAccDataSourceAdminRoles_Basic \
TestAccDataSourceAdminUsers_Basic \
TestAccDataSourceFWApplicationServicesGroupLite_Basic \
TestAccDataSourceFWApplicationServicesLite_Basic \
TestAccDataSourceAuthSettingsUrls_Basic \
TestAccDataSourceCBIProfile_Basic \
TestAccDataSourceDeviceGroups_Basic \
TestAccDataSourceDLPDictionaries_Basic \
TestAccDataSourceDLPEngines_Basic \
TestAccDataSourceDLPICAPServers_Basic \
TestAccDataSourceDLPIncidentReceiverServers_Basic \
TestAccDataSourceDLPNotificationTemplates_Basic \
TestAccDataSourceDlpWebRules_Basic \
TestAccDataSourceFWIPDestinationGroups_Basic \
TestAccDataSourceFWIPSourceGroups_Basic \
TestAccDataSourceFWNetworkApplicationGroups_Basic \
TestAccDataSourceFWNetworkServiceGroups_Basic \
TestAccResourceFWNetworkServicesBasic \
TestAccDataSourceFWTimeWindow_Basic \
TestAccDataSourceLocationGroup_Basic \
TestAccDataSourceLocationLite_Basic \
TestAccDataSourceLocationManagement_Basic \
TestAccDataSourceRuleLabels_Basic \
TestResourceSandboxSettings_basic \
TestAccDataSourceTrafficGreInternalIPRangeList_Basic \
TestAccDataSourceTrafficForwardingStaticIP_Basic \
TestAccDataSourceTrafficForwardingVPNCredentials_Basic \
TestAccDataSourceTrafficForwardingGreTunnels_Basic \
TestAccDataSourceURLCategories_Basic \
TestAccDataSourceURLFilteringRules_Basic \
TestAccDataSourceDepartmentManagement_Basic \
TestAccDataSourceGroupManagement_Basic \
TestAccDataSourceUserManagement_Basic \
TestAccResourceAdminUsersBasic \
TestAccResourceAuthSettingsUrls_basic \
TestAccResourceDLPDictionariesBasic \
TestAccResourceDLPEnginesBasic \
TestAccResourceDLPNotificationTemplatesBasic \
TestAccResourceDlpWebRules_Basic \
TestAccResourceFWIPDestinationGroupsBasic \
TestAccResourceFWIPSourceGroupsBasic \
TestAccResourceFWNetworkApplicationGroupsBasic \
TestAccResourceFWNetworkServiceGroupsBasic \
TestAccResourceFWNetworkServicesBasic \
TestAccResourceLocationManagementBasic \
TestAccResourceRuleLabelsBasic \
TestAccZiaSandboxFileSubmission_basic \
TestResourceSandboxSettings_basic \
TestAccResourceSecurityPolicySettings_basic \
TestAccResourceTrafficForwardingStaticIPBasic \
TestAccResourceTrafficForwardingVPNCredentialsBasic \
TestAccResourceTrafficForwardingGRETunnelBasic \
TestAccResourceURLCategoriesBasic \
TestAccResourceURLFilteringRulesBasic \
TestAccResourceUserManagementBasic

ifeq ($(strip $(ZS_INTEGRATION_TESTS)),)
ZS_INTEGRATION_TESTS = $(ZS2_INTEGRATION_TESTS)
endif

space := $(subst ,, )
integration_zs2_tests := $(subst $(space),\|,$(ZS_INTEGRATION_TESTS))

# Target to run integration tests for ZscalerTwo
test\:integration\:zscalertwo:
@echo "Running integration tests for ZscalerTwo..."
@TF_ACC=1 go test -v -cover ./zia -timeout 120m -run ^$(integration_zs2_tests)$$

build13: GOOS=$(shell go env GOOS)
build13: GOARCH=$(shell go env GOARCH)
ifeq ($(OS),Windows_NT) # is Windows_NT on XP, 2000, 7, Vista, 10...
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/hashicorp/go-hclog v1.6.2
github.com/hashicorp/terraform-plugin-sdk v1.17.2
github.com/hashicorp/terraform-plugin-sdk/v2 v2.32.0
github.com/zscaler/zscaler-sdk-go/v2 v2.3.8
github.com/zscaler/zscaler-sdk-go/v2 v2.3.9
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,8 @@ github.com/zclconf/go-cty v1.14.2 h1:kTG7lqmBou0Zkx35r6HJHUQTvaRPr5bIAf3AoHS0izI
github.com/zclconf/go-cty v1.14.2/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE=
github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8=
github.com/zclconf/go-cty-yaml v1.0.2/go.mod h1:IP3Ylp0wQpYm50IHK8OZWKMu6sPJIUgKa8XhiVHura0=
github.com/zscaler/zscaler-sdk-go/v2 v2.3.8 h1:ajdAHp0SSbY5BahC2EfQo/812v2QwpKaDjsnwtYSbAM=
github.com/zscaler/zscaler-sdk-go/v2 v2.3.8/go.mod h1:v8TLsPbVlQ3kAvGs8sIWsuhSAVggLbowiyDzaGYPWKg=
github.com/zscaler/zscaler-sdk-go/v2 v2.3.9 h1:7EcMIOKJqHABJonOdQEE/i4zjmGnZtxvr4O5woPJy9w=
github.com/zscaler/zscaler-sdk-go/v2 v2.3.9/go.mod h1:v8TLsPbVlQ3kAvGs8sIWsuhSAVggLbowiyDzaGYPWKg=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
Expand Down
2 changes: 2 additions & 0 deletions zia/data_source_zia_traffic_forwarding_gre_tunnels_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ func TestAccDataSourceTrafficForwardingGreTunnels_Basic(t *testing.T) {
Config: testAccCheckTrafficForwardingGRETunnelConfigure(resourceTypeAndName, generatedName, staticIPResourceHCL, staticIPTypeAndName, variable.GRETunnelWithinCountry, variable.GRETunnelIPUnnumbered),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrPair(dataSourceTypeAndName, "id", resourceTypeAndName, "id"),
resource.TestCheckResourceAttrPair(dataSourceTypeAndName, "source_ip", resourceTypeAndName, "source_ip"),
resource.TestCheckResourceAttrPair(dataSourceTypeAndName, "comment", resourceTypeAndName, "comment"),
resource.TestCheckResourceAttr(resourceTypeAndName, "within_country", strconv.FormatBool(variable.GRETunnelWithinCountry)),
resource.TestCheckResourceAttr(resourceTypeAndName, "ip_unnumbered", strconv.FormatBool(variable.GRETunnelIPUnnumbered)),
),
ExpectNonEmptyPlan: true,
},
},
})
Expand Down
14 changes: 9 additions & 5 deletions zia/resource_zia_traffic_forwarding_gre_tunnels_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,23 @@ func TestAccResourceTrafficForwardingGRETunnelBasic(t *testing.T) {
Config: testAccCheckTrafficForwardingGRETunnelConfigure(resourceTypeAndName, generatedName, staticIPResourceHCL, staticIPTypeAndName, variable.GRETunnelWithinCountry, variable.GRETunnelIPUnnumbered),
Check: resource.ComposeTestCheckFunc(
testAccCheckTrafficForwardingGRETunnelExists(resourceTypeAndName, &gretunnel),
resource.TestCheckResourceAttr(resourceTypeAndName, "comment", "TestAcc Created with Terraform"),
resource.TestCheckResourceAttr(resourceTypeAndName, "comment", generatedName),
resource.TestCheckResourceAttr(resourceTypeAndName, "within_country", strconv.FormatBool(variable.GRETunnelWithinCountry)),
resource.TestCheckResourceAttr(resourceTypeAndName, "ip_unnumbered", strconv.FormatBool(variable.GRETunnelIPUnnumbered)),
),
ExpectNonEmptyPlan: true,
},
// update
{
Config: testAccCheckTrafficForwardingGRETunnelConfigure(resourceTypeAndName, generatedName, staticIPResourceHCL, staticIPTypeAndName, variable.GRETunnelWithinCountry, variable.GRETunnelIPUnnumbered),
Check: resource.ComposeTestCheckFunc(
testAccCheckTrafficForwardingGRETunnelExists(resourceTypeAndName, &gretunnel),
resource.TestCheckResourceAttr(resourceTypeAndName, "comment", "TestAcc Created with Terraform"),
resource.TestCheckResourceAttr(resourceTypeAndName, "comment", generatedName),
resource.TestCheckResourceAttr(resourceTypeAndName, "within_country", strconv.FormatBool(variable.GRETunnelWithinCountry)),
resource.TestCheckResourceAttr(resourceTypeAndName, "ip_unnumbered", strconv.FormatBool(variable.GRETunnelIPUnnumbered)),
),
ExpectNonEmptyPlan: true,
},
},
})
Expand Down Expand Up @@ -112,10 +114,10 @@ func testAccCheckTrafficForwardingGRETunnelExists(resource string, rule *gretunn
func testAccCheckTrafficForwardingGRETunnelConfigure(resourceTypeAndName, generatedName, staticIPResourceHCL, staticIPTypeAndName string, withinCountry, ipUnnumbered bool) string {
return fmt.Sprintf(`
// gre tunnel resource
// static ip resource
%s
// static ip resource
// gre tunnel resource
%s
data "%s" "%s" {
Expand All @@ -134,11 +136,12 @@ func testAccCheckTrafficForwardingGRETunnelConfigure(resourceTypeAndName, genera
}
func getTrafficForwardingGRETunnel_HCL(generatedName, staticIPTypeAndName string, withinCountry, ipUnnumbered bool) string {
return fmt.Sprintf(`
resource "%s" "%s" {
source_ip = "${%s.ip_address}"
comment = "TestAcc Created with Terraform"
comment = "%s"
country_code = "CA"
within_country = "%s"
ip_unnumbered = "%s"
Expand All @@ -148,6 +151,7 @@ resource "%s" "%s" {
resourcetype.TrafficForwardingGRETunnel,
generatedName,
staticIPTypeAndName,
generatedName,
strconv.FormatBool(withinCountry),
strconv.FormatBool(ipUnnumbered),
)
Expand Down

0 comments on commit 561e447

Please sign in to comment.