Skip to content

Commit d53367a

Browse files
tutkatCopilot
andauthored
test: Add tests for ept (#193)
* added * added npt test * added ptp test and github flow to run tests * added ptp test and github flow to run tests * modified * up * updated tests * added empty line * updated path to test * Update .github/workflows/terratests-ept-prod-suite.yaml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 46042f1 commit d53367a

13 files changed

Lines changed: 448 additions & 11 deletions

File tree

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: terratests-ept-prod-suite
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
setup-tests:
8+
name: Setup PROD DIGP Tests
9+
runs-on: ubuntu-latest
10+
env:
11+
TF_VAR_equinix_client_id: ${{ secrets.EQUINIX_CLIENT_ID }}
12+
TF_VAR_equinix_client_secret: ${{ secrets.EQUINIX_CLIENT_SECRET }}
13+
TEST_DATA_PROD_PORT_2_PRECISION_TIME_PTP: ${{ secrets.TEST_DATA_PROD_PORT_2_PRECISION_TIME_PTP }}
14+
TEST_DATA_PROD_FCR_2_PRECISION_TIME_NPT: ${{ secrets.TEST_DATA_PROD_FCR_2_PRECISION_TIME_NPT }}
15+
TEST_DATA_PROD_VD_2_PRECISION_TIME_NPT: ${{ secrets.TEST_DATA_PROD_VD_2_PRECISION_TIME_NPT }}
16+
17+
steps:
18+
- name: Check out code into the Go module directory
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Go
22+
uses: actions/setup-go@v5
23+
with:
24+
go-version-file: './go.mod'
25+
id: go
26+
27+
- name: Set up Python3
28+
uses: actions/setup-python@v5
29+
with:
30+
python-version: '3.13'
31+
32+
- name: Get dependencies
33+
run: |
34+
go mod download
35+
go install github.com/thogarty/go-junit-report/v2@latest
36+
pip3 install junit2html
37+
38+
- uses: hashicorp/setup-terraform@v3
39+
with:
40+
terraform_version: ${{ matrix.terraform }}
41+
terraform_wrapper: false
42+
43+
- name: Install jq
44+
run: |
45+
sudo apt-get install jq
46+
47+
- name: Setup Variables Files
48+
run: |
49+
TIMESTAMP=$(date +"%m%d%M%S")
50+
SUFFIX="_DIGP"
51+
echo $TEST_DATA_PROD_FCR_2_PRECISION_TIME_NPT >> "./tests/examples-without-external-providers/cloud-router-2-precision-time-npt/terraform.tfvars.json"
52+
jq --arg timestamp "$TIMESTAMP" '.connection_name = ($timestamp + "_" + .connection_name)' ./tests/examples-without-external-providers/cloud-router-2-precision-time-npt/terraform.tfvars.json > ./tests/examples-without-external-providers/cloud-router-2-precision-time-npt/tmp.test.json && mv ./tests/examples-without-external-providers/cloud-router-2-precision-time-npt/tmp.test.json ./tests/examples-without-external-providers/cloud-router-2-precision-time-npt/terraform.tfvars.json
53+
echo $TEST_DATA_PROD_PORT_2_PRECISION_TIME_PTP >> "./examples/port-2-precision-time-ptp/terraform.tfvars.json"
54+
jq --arg timestamp "$TIMESTAMP" '.connection_name = ($timestamp + "_" + .connection_name)' ./examples/port-2-precision-time-ptp/terraform.tfvars.json > ./examples/port-2-precision-time-ptp/tmp.test.json && mv ./examples/port-2-precision-time-ptp/tmp.test.json ./examples/port-2-precision-time-ptp/terraform.tfvars.json
55+
echo $TEST_DATA_PROD_VD_2_PRECISION_TIME_NPT >> "./tests/examples-without-external-providers/virtual_device-2-precision-time-npt/terraform.tfvars.json"
56+
jq --arg timestamp "$TIMESTAMP" '.connection_name = ($timestamp + "_" + .connection_name)' ./tests/examples-without-external-providers/virtual_device-2-precision-time-npt/terraform.tfvars.json > ./tests/examples-without-external-providers/virtual_device-2-precision-time-npt/tmp.test.json && mv ./tests/examples-without-external-providers/virtual_device-2-precision-time-npt/tmp.test.json ./tests/examples-without-external-providers/virtual_device-2-precision-time-npt/terraform.tfvars.json
57+
58+
- name: Run Go Tests
59+
run:
60+
go test ./tests/prod/precision_time -v -json -count 1 -parallel 8 -run "(DIGP)" -timeout 180m | tee precision_time_prod_suite.log
61+
62+
- name: Create HTML Testing Report
63+
run: |
64+
go-junit-report -parser gojson -in precision_time_prod_suite.log > precision_time_prod_suite.xml && python3 -m junit2htmlreport precision_time_prod_suite.xml precision_time_prod_suite.html
65+
66+
- name: Upload HTML Testing Report
67+
uses: actions/upload-artifact@v4
68+
with:
69+
name: Port Prod Suite Terraform Modules Testing Report
70+
path: precision_time_prod_suite.html
71+
compression-level: 0
72+
73+
- name: Check if Tests are passed
74+
run: sh scripts/check_tests.sh *suite.log

examples/port-2-precision-time-ptp/main.tf

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ provider "equinix" {
33
client_secret = var.equinix_client_secret
44
}
55

6+
resource "random_integer" "random_vlan_tag" {
7+
min = 50
8+
max = 2549
9+
}
10+
11+
output "random_vlan_tag" {
12+
value = random_integer.random_vlan_tag.result
13+
}
14+
615
module "create_port_2_precision_time_ptp_service_profile" {
716
source = "../../modules/port-connection"
817

@@ -15,7 +24,7 @@ module "create_port_2_precision_time_ptp_service_profile" {
1524

1625
# A-side
1726
aside_port_name = var.aside_port_name
18-
aside_vlan_tag = var.aside_vlan_tag
27+
aside_vlan_tag = tostring(random_integer.random_vlan_tag.result)
1928

2029
# Z-side
2130
zside_ap_type = var.zside_ap_type

examples/port-2-precision-time-ptp/outputs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ output "port_2_ptp_connection_id" {
22
value = module.create_port_2_precision_time_ptp_service_profile.primary_connection_id
33
}
44

5-
output "ntp_ept_resource_id" {
5+
output "ptp_ept_resource_id" {
66
value = equinix_fabric_precision_time_service.ptp.id
77
}

examples/port-2-precision-time-ptp/variables.tf

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,6 @@ variable "aside_port_name" {
3838
description = "Equinix A-Side Port Name"
3939
type = string
4040
}
41-
variable "aside_vlan_tag" {
42-
description = "Vlan Tag information, outer vlanSTag for QINQ connections"
43-
type = string
44-
}
45-
variable "aside_vlan_inner_tag" {
46-
description = "Vlan Inner Tag information, inner vlanCTag for QINQ connections"
47-
type = string
48-
default = ""
49-
}
5041
variable "zside_ap_type" {
5142
description = "Access point type - COLO, VD, VG, SP, IGW, SUBNET, GW"
5243
type = string
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
provider "equinix" {
2+
client_id = var.equinix_client_id
3+
client_secret = var.equinix_client_secret
4+
}
5+
6+
module "create_cloud_router_2_precision_time_ntp" {
7+
source = "../../../modules/cloud-router-connection"
8+
connection_name = var.connection_name
9+
connection_type = var.connection_type
10+
notifications_type = var.notifications_type
11+
notifications_emails = var.notifications_emails
12+
bandwidth = var.bandwidth
13+
purchase_order_number = var.purchase_order_number
14+
15+
# A-side
16+
aside_fcr_uuid = var.aside_fcr_uuid
17+
18+
# Z-side
19+
zside_ap_type = var.zside_ap_type
20+
zside_ap_profile_type = var.zside_ap_profile_type
21+
zside_location = var.zside_location
22+
zside_fabric_sp_name = var.zside_fabric_sp_name
23+
}
24+
25+
resource "equinix_fabric_precision_time_service" "ntp" {
26+
type = "NTP"
27+
name = var.precision_time_ntp_name
28+
package = {
29+
code = var.precision_time_ntp_package_code
30+
}
31+
connections = [
32+
{
33+
uuid = module.create_cloud_router_2_precision_time_ntp.primary_connection_id
34+
}
35+
]
36+
ipv4 = {
37+
primary = var.precision_time_ntp_ipv4_primary
38+
secondary = var.precision_time_ntp_ipv4_secondary
39+
network_mask = var.precision_time_ntp_ipv4_network_mask
40+
default_gateway = var.precision_time_ntp_ipv4_default_gateway
41+
}
42+
ntp_advanced_configuration = var.precision_time_ntp_advance_configuration != null ? var.precision_time_ntp_advance_configuration : null
43+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
output "port_2_npt_connection_id" {
2+
value = module.create_cloud_router_2_precision_time_ntp.primary_connection_id
3+
}
4+
5+
output "npt_ept_resource_id" {
6+
value = equinix_fabric_precision_time_service.ntp.id
7+
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
variable "equinix_client_id" {
2+
description = "Equinix client ID (consumer key), obtained after registering app in the developer platform"
3+
type = string
4+
sensitive = true
5+
}
6+
variable "equinix_client_secret" {
7+
description = "Equinix client secret ID (consumer secret), obtained after registering app in the developer platform"
8+
type = string
9+
sensitive = true
10+
}
11+
variable "connection_name" {
12+
description = "Connection name. An alpha-numeric 24 characters string which can include only hyphens and underscores"
13+
type = string
14+
}
15+
variable "connection_type" {
16+
description = "Defines the connection type like VG_VC, EVPL_VC, EPL_VC, EC_VC, IP_VC, ACCESS_EPL_VC"
17+
type = string
18+
}
19+
variable "notifications_type" {
20+
description = "Notification Type - ALL is the only type currently supported"
21+
type = string
22+
default = "ALL"
23+
}
24+
variable "notifications_emails" {
25+
description = "Array of contact emails"
26+
type = list(string)
27+
}
28+
variable "bandwidth" {
29+
description = "Connection bandwidth in Mbps"
30+
type = number
31+
}
32+
variable "purchase_order_number" {
33+
description = "Purchase order number"
34+
type = string
35+
default = ""
36+
}
37+
variable "aside_fcr_uuid" {
38+
description = "Equinix Cloud Router UUID"
39+
type = string
40+
}
41+
variable "zside_fabric_sp_name" {
42+
description = "Service Profile name"
43+
type = string
44+
}
45+
variable "zside_ap_type" {
46+
description = "Access point type - COLO, VD, VG, SP, IGW, SUBNET, GW"
47+
type = string
48+
}
49+
variable "zside_ap_profile_type" {
50+
description = "Service profile type - L2_PROFILE, L3_PROFILE, ECIA_PROFILE, ECMC_PROFILE"
51+
type = string
52+
}
53+
variable "zside_location" {
54+
description = "Access point metro code"
55+
type = string
56+
}
57+
variable "precision_time_ntp_name" {
58+
description = "Precision Time Service Name"
59+
type = string
60+
}
61+
variable "precision_time_ntp_package_code" {
62+
description = "Precision Time Service Package Code"
63+
type = string
64+
}
65+
variable "precision_time_ntp_ipv4_primary" {
66+
description = "Precision Time Service Primary Ipv4 value"
67+
type = string
68+
}
69+
variable "precision_time_ntp_ipv4_secondary" {
70+
description = "Precision Time Service Secondary Ipv4 value"
71+
type = string
72+
}
73+
variable "precision_time_ntp_ipv4_network_mask" {
74+
description = "Precision Time Service Ipv4 Network Mask value"
75+
type = string
76+
}
77+
variable "precision_time_ntp_ipv4_default_gateway" {
78+
description = "Precision Time Service Ipv4 Default Gateway value"
79+
type = string
80+
}
81+
variable "precision_time_ntp_advance_configuration" {
82+
description = "Precision Time Service NTP Advance Configuration MD5 Details"
83+
type = list(object({
84+
type = string
85+
key_number = number
86+
key = string
87+
}))
88+
default = null
89+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
terraform {
2+
required_version = ">= 1.5.2"
3+
required_providers {
4+
equinix = {
5+
source = "equinix/equinix"
6+
version = ">= 3.8.0"
7+
}
8+
}
9+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
provider "equinix" {
2+
client_id = var.equinix_client_id
3+
client_secret = var.equinix_client_secret
4+
}
5+
6+
module "virtual_device_2_precision_time_ntp" {
7+
source = "../../../modules/virtual-device-connection"
8+
9+
connection_name = var.connection_name
10+
connection_type = var.connection_type
11+
notifications_type = var.notifications_type
12+
notifications_emails = var.notifications_emails
13+
bandwidth = var.bandwidth
14+
purchase_order_number = var.purchase_order_number
15+
# A-side
16+
aside_vd_type = var.aside_vd_type
17+
aside_vd_uuid = var.aside_vd_uuid
18+
# Z-side
19+
zside_ap_type = var.zside_ap_type
20+
zside_ap_profile_type = var.zside_ap_profile_type
21+
zside_location = var.zside_location
22+
zside_sp_name = var.zside_sp_name
23+
}
24+
25+
resource "equinix_fabric_precision_time_service" "ntp" {
26+
type = "NTP"
27+
name = var.precision_time_ntp_name
28+
package = {
29+
code = var.precision_time_ntp_package_code
30+
}
31+
connections = [
32+
{
33+
uuid = module.virtual_device_2_precision_time_ntp.primary_connection_id
34+
}
35+
]
36+
ipv4 = {
37+
primary = var.precision_time_ntp_ipv4_primary
38+
secondary = var.precision_time_ntp_ipv4_secondary
39+
network_mask = var.precision_time_ntp_ipv4_network_mask
40+
default_gateway = var.precision_time_ntp_ipv4_default_gateway
41+
}
42+
ntp_advanced_configuration = var.precision_time_ntp_advance_configuration != null ? var.precision_time_ntp_advance_configuration : null
43+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
output "virtual_device_2_ntp_connection_id" {
2+
value = module.virtual_device_2_precision_time_ntp.primary_connection_id
3+
}
4+
5+
output "npt_ept_resource_id" {
6+
value = equinix_fabric_precision_time_service.ntp.id
7+
}

0 commit comments

Comments
 (0)