Skip to content

Commit

Permalink
Add second testing values
Browse files Browse the repository at this point in the history
  • Loading branch information
seconroy committed Aug 12, 2024
1 parent 4b34228 commit b8fe4fd
Show file tree
Hide file tree
Showing 56 changed files with 2,710 additions and 86 deletions.
26 changes: 23 additions & 3 deletions gen/definitions/profile_parcels/service_tracker_group.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ attributes:
- model_name: refId
tf_name: tracker_id
data_path: [trackerRef]
id: true
mandatory: true
example: 615d948f-34ee-4a2e-810e-a9bd8d3d48ec
test_value: sdwan_service_tracker_profile_parcel.test.id
test_value: sdwan_service_tracker_profile_parcel.test-1.id
secondary_test_value: sdwan_service_tracker_profile_parcel.test-2.id
- model_name: combineBoolean
tf_name: tracker_boolean
example: or
Expand All @@ -30,8 +33,25 @@ test_prerequisites: |
description = "Terraform test"
}
resource "sdwan_service_tracker_profile_parcel" "test" {
name = "TF_TEST"
resource "sdwan_service_tracker_profile_parcel" "test-1" {
name = "TF_TEST_1"
description = "Terraform test"
feature_profile_id = sdwan_service_feature_profile.test.id
tracker_name = "TRACKER_2"
endpoint_api_url = "google.com"
endpoint_dns_name = "google.com"
endpoint_ip = "1.2.3.4"
protocol = "tcp"
port = 123
interval = 30
multiplier = 3
threshold = 300
endpoint_tracker_type = "static-route"
tracker_type = "endpoint"
}
resource "sdwan_service_tracker_profile_parcel" "test-2" {
name = "TF_TEST_2"
description = "Terraform test"
feature_profile_id = sdwan_service_feature_profile.test.id
tracker_name = "TRACKER_2"
Expand Down
23 changes: 20 additions & 3 deletions gen/definitions/profile_parcels/transport_ipv6_tracker_group.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ attributes:
tf_name: tracker_id
data_path: [trackerRef]
id: true
mandatory: true
example: 615d948f-34ee-4a2e-810e-a9bd8d3d48ec
test_value: sdwan_transport_ipv6_tracker_profile_parcel.test.id
test_value: sdwan_transport_ipv6_tracker_profile_parcel.test-1.id
secondary_test_value: sdwan_transport_ipv6_tracker_profile_parcel.test-2.id
- model_name: combineBoolean
tf_name: tracker_boolean
example: or
Expand All @@ -35,8 +37,23 @@ test_prerequisites: |
description = "Terraform test"
}
resource "sdwan_transport_ipv6_tracker_profile_parcel" "test" {
name = "TF_TEST"
resource "sdwan_transport_ipv6_tracker_profile_parcel" "test-1" {
name = "TF_TEST_1"
description = "Terraform Test"
feature_profile_id = sdwan_transport_feature_profile.test.id
tracker_name = "TRACKER_1"
endpoint_api_url = "google.com"
endpoint_dns_name = "google.com"
endpoint_ip = "2001:0:0:1::0"
interval = 30
multiplier = 3
threshold = 300
endpoint_tracker_type = "ipv6-interface"
tracker_type = "endpoint"
}
resource "sdwan_transport_ipv6_tracker_profile_parcel" "test-2" {
name = "TF_TEST_2"
description = "Terraform Test"
feature_profile_id = sdwan_transport_feature_profile.test.id
tracker_name = "TRACKER_1"
Expand Down
25 changes: 21 additions & 4 deletions gen/definitions/profile_parcels/transport_tracker_group.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,18 @@ attributes:
mandatory: true
description: Feature Profile ID
example: f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac
test_value: sdwan_transport_feature_profile.test.id1
test_value: sdwan_transport_feature_profile.test.id
- model_name: trackerRefs
tf_name: tracker_elements
attributes:
- model_name: refId
tf_name: tracker_id
data_path: [trackerRef]
id: true
mandatory: true
example: 615d948f-34ee-4a2e-810e-a9bd8d3d48ec
test_value: sdwan_transport_tracker_profile_parcel.test.id
test_value: sdwan_transport_tracker_profile_parcel.test-1.id
secondary_test_value: sdwan_transport_tracker_profile_parcel.test-2.id
- model_name: combineBoolean
tf_name: tracker_boolean
example: or
Expand All @@ -31,8 +33,23 @@ test_prerequisites: |
description = "Terraform test"
}
resource "sdwan_transport_tracker_profile_parcel" "test" {
name = "TF_TEST"
resource "sdwan_transport_tracker_profile_parcel" "test-1" {
name = "TF_TEST_1"
description = "Terraform Test"
feature_profile_id = sdwan_transport_feature_profile.test.id
tracker_name = "TRACKER_1"
endpoint_api_url = "google.com"
endpoint_dns_name = "google.com"
endpoint_ip = "1.2.3.4"
interval = 30
multiplier = 3
threshold = 300
endpoint_tracker_type = "interface"
tracker_type = "endpoint"
}
resource "sdwan_transport_tracker_profile_parcel" "test-2" {
name = "TF_TEST_2"
description = "Terraform Test"
feature_profile_id = sdwan_transport_feature_profile.test.id
tracker_name = "TRACKER_1"
Expand Down
2 changes: 2 additions & 0 deletions gen/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ type YamlConfig struct {
SkipTemplates []string `yaml:"skip_templates"`
Attributes []YamlConfigAttribute `yaml:"attributes"`
TestTags []string `yaml:"test_tags"`
ExcludeMinimumTest bool `yaml:"exclude_minimum_test"`
TestPrerequisites string `yaml:"test_prerequisites"`
RemoveId bool `yaml:"remove_id"`
TypeValue string `yaml:"type_value"`
Expand Down Expand Up @@ -255,6 +256,7 @@ type YamlConfigAttribute struct {
DefaultValueEmptyString bool `yaml:"default_value_empty_string"`
Value string `yaml:"value"`
TestValue string `yaml:"test_value"`
SecondaryTestValue string `yaml:"secondary_test_value"`
MinimumTestValue string `yaml:"minimum_test_value"`
AlwaysInclude bool `yaml:"always_include"`
Attributes []YamlConfigAttribute `yaml:"attributes"`
Expand Down
2 changes: 2 additions & 0 deletions gen/schema/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ attribute:
default_value_empty_string: bool(required=False) # Set to true if default value should be an empty string
value: any(str(), int(), bool(), required=False) # Hardcoded value for the attribute
test_value: str(required=False) # Value used for acceptance test
secondary_test_value: str(required=False) # Value used for acceptance test
minimum_test_value: any(str(), int(), bool(), num(), required=False) # Value used for "minimum" resource acceptance test
exclude_minimum_test: bool(required=False)
always_include: bool(required=False) # Include attribute always in payload
attributes: list(include('attribute'), required=False) # List of attributes, only relevant if type is "List" or "Set"
conditional_attribute: include('conditional_attribute', required=False) # Add attribute to payload only if condition is true
Expand Down
20 changes: 16 additions & 4 deletions gen/templates/profile_parcels/data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,28 @@ func TestAccDataSourceSdwan{{camelCase .Name}}ProfileParcel(t *testing.T) {
var checks []resource.TestCheckFunc
{{- $name := .Name }}
{{- range .Attributes}}
{{- if and (not .WriteOnly) (not .ExcludeTest) (not .Reference) (not .Value)}}
{{- if and (not .WriteOnly) (not .ExcludeTest) (not .Reference) (not .Value) (not .TestValue)}}
{{- if isNestedListSet .}}
{{- $list := .TfName }}
{{- if len .TestTags}}
if {{range $i, $e := .TestTags}}{{if $i}} || {{end}}os.Getenv("{{$e}}") != ""{{end}} {
{{- end}}
{{- range .Attributes}}
{{- if and (not .WriteOnly) (not .ExcludeTest) (not .Reference) (not .Value)}}
{{- if and (not .WriteOnly) (not .ExcludeTest) (not .Reference) (not .Value) (not .TestValue)}}
{{- if isNestedListSet .}}
{{- $clist := .TfName }}
{{- if len .TestTags}}
if {{range $i, $e := .TestTags}}{{if $i}} || {{end}}os.Getenv("{{$e}}") != ""{{end}} {
{{- end}}
{{- range .Attributes}}
{{- if and (not .WriteOnly) (not .ExcludeTest) (not .Reference) (not .Value)}}
{{- if and (not .WriteOnly) (not .ExcludeTest) (not .Reference) (not .Value) (not .TestValue)}}
{{- if isNestedListSet .}}
{{- $cclist := .TfName }}
{{- if len .TestTags}}
if {{range $i, $e := .TestTags}}{{if $i}} || {{end}}os.Getenv("{{$e}}") != ""{{end}} {
{{- end}}
{{- range .Attributes}}
{{- if and (not .WriteOnly) (not .ExcludeTest) (not .Reference) (not .Value) (not (isListSet .))}}
{{- if and (not .WriteOnly) (not .ExcludeTest) (not .Reference) (not .Value) (not .TestValue) (not (isListSet .))}}
{{- if len .TestTags}}
if {{range $i, $e := .TestTags}}{{if $i}} || {{end}}os.Getenv("{{$e}}") != ""{{end}} {
checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_{{snakeCase $name}}_profile_parcel.test", "{{$list}}.0.{{$clist}}.0.{{$cclist}}.0.{{.TfName}}", "{{.Example}}"))
Expand Down Expand Up @@ -161,9 +161,13 @@ func testAccDataSourceSdwan{{camelCase .Name}}ProfileParcelConfig() string {
{{- if len .TestTags}}
if {{range $i, $e := .TestTags}}{{if $i}} || {{end}}os.Getenv("{{$e}}") != ""{{end}} {
config += ` {{.TfName}} = {{if .TestValue}}{{.TestValue}}{{else}}{{if eq .Type "String"}}"{{.Example}}"{{else if isStringListSet .}}["{{.Example}}"]{{else if isInt64ListSet .}}[{{.Example}}]{{else}}{{.Example}}{{end}}{{end}}` + "\n"
{{if .SecondaryTestValue}}config += ` }, {` + "\n"
config += ` {{.TfName}} = {{if .SecondaryTestValue}}{{.SecondaryTestValue}}{{end}}` + "\n"{{end}}
}
{{- else}}
config += ` {{.TfName}} = {{if .TestValue}}{{.TestValue}}{{else}}{{if eq .Type "String"}}"{{.Example}}"{{else if isStringListSet .}}["{{.Example}}"]{{else if isInt64ListSet .}}[{{.Example}}]{{else}}{{.Example}}{{end}}{{end}}` + "\n"
{{if .SecondaryTestValue}}config += ` }, {` + "\n"
config += ` {{.TfName}} = {{if .SecondaryTestValue}}{{.SecondaryTestValue}}{{end}}` + "\n"{{end}}
{{- end}}
{{- end}}
{{- end}}
Expand All @@ -175,9 +179,13 @@ func testAccDataSourceSdwan{{camelCase .Name}}ProfileParcelConfig() string {
{{- if len .TestTags}}
if {{range $i, $e := .TestTags}}{{if $i}} || {{end}}os.Getenv("{{$e}}") != ""{{end}} {
config += ` {{.TfName}} = {{if .TestValue}}{{.TestValue}}{{else}}{{if eq .Type "String"}}"{{.Example}}"{{else if isStringListSet .}}["{{.Example}}"]{{else if isInt64ListSet .}}[{{.Example}}]{{else}}{{.Example}}{{end}}{{end}}` + "\n"
{{if .SecondaryTestValue}}config += ` }, {` + "\n"
config += ` {{.TfName}} = {{if .SecondaryTestValue}}{{.SecondaryTestValue}}{{end}}` + "\n"{{end}}
}
{{- else}}
config += ` {{.TfName}} = {{if .TestValue}}{{.TestValue}}{{else}}{{if eq .Type "String"}}"{{.Example}}"{{else if isStringListSet .}}["{{.Example}}"]{{else if isInt64ListSet .}}[{{.Example}}]{{else}}{{.Example}}{{end}}{{end}}` + "\n"
{{if .SecondaryTestValue}}config += ` }, {` + "\n"
config += ` {{.TfName}} = {{if .SecondaryTestValue}}{{.SecondaryTestValue}}{{end}}` + "\n"{{end}}
{{- end}}
{{- end}}
{{- end}}
Expand All @@ -190,9 +198,13 @@ func testAccDataSourceSdwan{{camelCase .Name}}ProfileParcelConfig() string {
{{- if len .TestTags}}
if {{range $i, $e := .TestTags}}{{if $i}} || {{end}}os.Getenv("{{$e}}") != ""{{end}} {
config += ` {{.TfName}} = {{if .TestValue}}{{.TestValue}}{{else}}{{if eq .Type "String"}}"{{.Example}}"{{else if isStringListSet .}}["{{.Example}}"]{{else if isInt64ListSet .}}[{{.Example}}]{{else}}{{.Example}}{{end}}{{end}}` + "\n"
{{if .SecondaryTestValue}}config += ` }, {` + "\n"
config += ` {{.TfName}} = {{if .SecondaryTestValue}}{{.SecondaryTestValue}}{{end}}` + "\n"{{end}}
}
{{- else}}
config += ` {{.TfName}} = {{if .TestValue}}{{.TestValue}}{{else}}{{if eq .Type "String"}}"{{.Example}}"{{else if isStringListSet .}}["{{.Example}}"]{{else if isInt64ListSet .}}[{{.Example}}]{{else}}{{.Example}}{{end}}{{end}}` + "\n"
{{if .SecondaryTestValue}}config += ` }, {` + "\n"
config += ` {{.TfName}} = {{if .SecondaryTestValue}}{{.SecondaryTestValue}}{{end}}` + "\n"{{end}}
{{- end}}
{{- end}}
{{- end}}
Expand Down
28 changes: 20 additions & 8 deletions gen/templates/profile_parcels/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,28 @@ func TestAccSdwan{{camelCase .Name}}ProfileParcel(t *testing.T) {
var checks []resource.TestCheckFunc
{{- $name := .Name }}
{{- range .Attributes}}
{{- if and (not .WriteOnly) (not .ExcludeTest) (not .Reference) (not .Value)}}
{{- if and (not .WriteOnly) (not .ExcludeTest) (not .Reference) (not .Value) (not .TestValue)}}
{{- if isNestedListSet .}}
{{- $list := .TfName }}
{{- if len .TestTags}}
if {{range $i, $e := .TestTags}}{{if $i}} || {{end}}os.Getenv("{{$e}}") != ""{{end}} {
{{- end}}
{{- range .Attributes}}
{{- if and (not .WriteOnly) (not .ExcludeTest) (not .Reference) (not .Value)}}
{{- if and (not .WriteOnly) (not .ExcludeTest) (not .Reference) (not .Value) (not .TestValue)}}
{{- if isNestedListSet .}}
{{- $clist := .TfName }}
{{- if len .TestTags}}
if {{range $i, $e := .TestTags}}{{if $i}} || {{end}}os.Getenv("{{$e}}") != ""{{end}} {
{{- end}}
{{- range .Attributes}}
{{- if and (not .WriteOnly) (not .ExcludeTest) (not .Reference) (not .Value)}}
{{- if and (not .WriteOnly) (not .ExcludeTest) (not .Reference) (not .Value) (not .TestValue)}}
{{- if isNestedListSet .}}
{{- $cclist := .TfName }}
{{- if len .TestTags}}
if {{range $i, $e := .TestTags}}{{if $i}} || {{end}}os.Getenv("{{$e}}") != ""{{end}} {
{{- end}}
{{- range .Attributes}}
{{- if and (not .WriteOnly) (not .ExcludeTest) (not .Reference) (not .Value) (not (isListSet .))}}
{{- if and (not .WriteOnly) (not .ExcludeTest) (not .Reference) (not .Value) (not .TestValue) (not (isListSet .))}}
{{- if len .TestTags}}
if {{range $i, $e := .TestTags}}{{if $i}} || {{end}}os.Getenv("{{$e}}") != ""{{end}} {
checks = append(checks, resource.TestCheckResourceAttr("sdwan_{{snakeCase $name}}_profile_parcel.test", "{{$list}}.0.{{$clist}}.0.{{$cclist}}.0.{{.TfName}}", "{{.Example}}"))
Expand Down Expand Up @@ -113,9 +113,9 @@ func TestAccSdwan{{camelCase .Name}}ProfileParcel(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) },
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
Steps: []resource.TestStep{
{
{{if not .ExcludeMinimumTest}}{
Config: {{if .TestPrerequisites}}testAccSdwan{{camelCase .Name}}PrerequisitesProfileParcelConfig+{{end}}testAccSdwan{{camelCase .Name}}ProfileParcelConfig_minimum(),
},
},{{end}}
{
Config: {{if .TestPrerequisites}}testAccSdwan{{camelCase .Name}}PrerequisitesProfileParcelConfig+{{end}}testAccSdwan{{camelCase .Name}}ProfileParcelConfig_all(),
Check: resource.ComposeTestCheckFunc(checks...),
Expand All @@ -134,7 +134,7 @@ const testAccSdwan{{camelCase .Name}}PrerequisitesProfileParcelConfig = `
// End of section. //template:end testPrerequisites

// Section below is generated&owned by "gen/generator.go". //template:begin testAccConfigMinimum
func testAccSdwan{{camelCase .Name}}ProfileParcelConfig_minimum() string {
{{if not .ExcludeMinimumTest}}func testAccSdwan{{camelCase .Name}}ProfileParcelConfig_minimum() string {
config := `resource "sdwan_{{snakeCase $name}}_profile_parcel" "test" {` + "\n"
config += ` name = "TF_TEST_MIN"` + "\n"
config += ` description = "Terraform integration test"` + "\n"
Expand All @@ -151,7 +151,7 @@ func testAccSdwan{{camelCase .Name}}ProfileParcelConfig_minimum() string {
{{- end}}
config += `}` + "\n"
return config
}
}{{end}}
// End of section. //template:end testAccConfigMinimum

// Section below is generated&owned by "gen/generator.go". //template:begin testAccConfigAll
Expand Down Expand Up @@ -185,9 +185,13 @@ func testAccSdwan{{camelCase .Name}}ProfileParcelConfig_all() string {
{{- if len .TestTags}}
if {{range $i, $e := .TestTags}}{{if $i}} || {{end}}os.Getenv("{{$e}}") != ""{{end}} {
config += ` {{.TfName}} = {{if .TestValue}}{{.TestValue}}{{else}}{{if eq .Type "String"}}"{{.Example}}"{{else if isStringListSet .}}["{{.Example}}"]{{else if isInt64ListSet .}}[{{.Example}}]{{else}}{{.Example}}{{end}}{{end}}` + "\n"
{{if .SecondaryTestValue}}config += ` }, {` + "\n"
config += ` {{.TfName}} = {{if .SecondaryTestValue}}{{.SecondaryTestValue}}{{end}}` + "\n"{{end}}
}
{{- else}}
config += ` {{.TfName}} = {{if .TestValue}}{{.TestValue}}{{else}}{{if eq .Type "String"}}"{{.Example}}"{{else if isStringListSet .}}["{{.Example}}"]{{else if isInt64ListSet .}}[{{.Example}}]{{else}}{{.Example}}{{end}}{{end}}` + "\n"
{{if .SecondaryTestValue}}config += ` }, {` + "\n"
config += ` {{.TfName}} = {{if .SecondaryTestValue}}{{.SecondaryTestValue}}{{end}}` + "\n"{{end}}
{{- end}}
{{- end}}
{{- end}}
Expand All @@ -199,9 +203,13 @@ func testAccSdwan{{camelCase .Name}}ProfileParcelConfig_all() string {
{{- if len .TestTags}}
if {{range $i, $e := .TestTags}}{{if $i}} || {{end}}os.Getenv("{{$e}}") != ""{{end}} {
config += ` {{.TfName}} = {{if .TestValue}}{{.TestValue}}{{else}}{{if eq .Type "String"}}"{{.Example}}"{{else if isStringListSet .}}["{{.Example}}"]{{else if isInt64ListSet .}}[{{.Example}}]{{else}}{{.Example}}{{end}}{{end}}` + "\n"
{{if .SecondaryTestValue}}config += ` }, {` + "\n"
config += ` {{.TfName}} = {{if .SecondaryTestValue}}{{.SecondaryTestValue}}{{end}}` + "\n"{{end}}
}
{{- else}}
config += ` {{.TfName}} = {{if .TestValue}}{{.TestValue}}{{else}}{{if eq .Type "String"}}"{{.Example}}"{{else if isStringListSet .}}["{{.Example}}"]{{else if isInt64ListSet .}}[{{.Example}}]{{else}}{{.Example}}{{end}}{{end}}` + "\n"
{{if .SecondaryTestValue}}config += ` }, {` + "\n"
config += ` {{.TfName}} = {{if .SecondaryTestValue}}{{.SecondaryTestValue}}{{end}}` + "\n"{{end}}
{{- end}}
{{- end}}
{{- end}}
Expand All @@ -214,9 +222,13 @@ func testAccSdwan{{camelCase .Name}}ProfileParcelConfig_all() string {
{{- if len .TestTags}}
if {{range $i, $e := .TestTags}}{{if $i}} || {{end}}os.Getenv("{{$e}}") != ""{{end}} {
config += ` {{.TfName}} = {{if .TestValue}}{{.TestValue}}{{else}}{{if eq .Type "String"}}"{{.Example}}"{{else if isStringListSet .}}["{{.Example}}"]{{else if isInt64ListSet .}}[{{.Example}}]{{else}}{{.Example}}{{end}}{{end}}` + "\n"
{{if .SecondaryTestValue}}config += ` }, {` + "\n"
config += ` {{.TfName}} = {{if .SecondaryTestValue}}{{.SecondaryTestValue}}{{end}}` + "\n"{{end}}
}
{{- else}}
config += ` {{.TfName}} = {{if .TestValue}}{{.TestValue}}{{else}}{{if eq .Type "String"}}"{{.Example}}"{{else if isStringListSet .}}["{{.Example}}"]{{else if isInt64ListSet .}}[{{.Example}}]{{else}}{{.Example}}{{end}}{{end}}` + "\n"
{{if .SecondaryTestValue}}config += ` }, {` + "\n"
config += ` {{.TfName}} = {{if .SecondaryTestValue}}{{.SecondaryTestValue}}{{end}}` + "\n"{{end}}
{{- end}}
{{- end}}
{{- end}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,13 @@ func testAccDataSourceSdwanApplicationPriorityQoSPolicyProfileParcelConfig() str
config += ` target_interface = ["{{interface_var_1}}"]` + "\n"
config += ` qos_schedulers = [{` + "\n"
config += ` drops = "tail-drop"` + "\n"

config += ` queue = "0"` + "\n"

config += ` bandwidth = "10"` + "\n"

config += ` scheduling_type = "llq"` + "\n"

config += ` }]` + "\n"
config += `}` + "\n"

Expand Down
Loading

0 comments on commit b8fe4fd

Please sign in to comment.