Skip to content

Commit

Permalink
Adding pdpScope field to PAP resource (#12803)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruv-23101998 authored Jan 21, 2025
1 parent 80c24b1 commit 327e1af
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 2 deletions.
17 changes: 17 additions & 0 deletions mmv1/products/compute/PublicAdvertisedPrefix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ examples:
# PAPs have very low quota limits and a shared testing range so serialized tests exist in:
# resource_compute_public_advertised_prefix_test.go
exclude_test: true
- name: 'public_advertised_prefixes_pdp_scope'
primary_resource_id: 'prefixes'
vars:
prefixes_name: 'my-pap'
test_env_vars:
desc: 'PAP_DESCRIPTION'
# PAPs have very low quota limits and a shared testing range so serialized tests exist in:
# resource_compute_public_advertised_prefix_test.go
exclude_test: true
parameters:
properties:
- name: 'description'
Expand All @@ -70,6 +79,14 @@ properties:
The IPv4 address range, in CIDR format, represented by this public
advertised prefix.
required: true
- name: 'pdpScope'
type: Enum
description: |
Specifies how child public delegated prefix will be scoped. pdpScope
must be one of: GLOBAL, REGIONAL
enum_values:
- 'GLOBAL'
- 'REGIONAL'
- name: 'sharedSecret'
type: String
description: |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
resource "google_compute_public_advertised_prefix" "{{$.PrimaryResourceId}}" {
name = "{{index $.Vars "prefixes_name"}}"
description = "{{index $.TestEnvVars "desc"}}"
dns_verification_ip = "127.127.0.0"
ip_cidr_range = "127.127.0.0/16"
pdp_scope = "REGIONAL"
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ import (
// Since we only have access to one test prefix range we cannot run tests in parallel
func TestAccComputePublicPrefixes(t *testing.T) {
testCases := map[string]func(t *testing.T){
"delegated_prefix": testAccComputePublicDelegatedPrefix_publicDelegatedPrefixesBasicTest,
"advertised_prefix": testAccComputePublicAdvertisedPrefix_publicAdvertisedPrefixesBasicTest,
"delegated_prefix": testAccComputePublicDelegatedPrefix_publicDelegatedPrefixesBasicTest,
"advertised_prefix": testAccComputePublicAdvertisedPrefix_publicAdvertisedPrefixesBasicTest,
"advertised_prefix_pdp_scope": testAccComputePublicAdvertisedPrefix_publicAdvertisedPrefixesPdpScopeTest,
}

for name, tc := range testCases {
Expand All @@ -32,6 +33,41 @@ func TestAccComputePublicPrefixes(t *testing.T) {
}
}

func testAccComputePublicAdvertisedPrefix_publicAdvertisedPrefixesPdpScopeTest(t *testing.T) {
context := map[string]interface{}{
"description": envvar.GetTestPublicAdvertisedPrefixDescriptionFromEnv(t),
"random_suffix": acctest.RandString(t, 10),
}

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckComputePublicAdvertisedPrefixDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccComputePublicAdvertisedPrefix_publicAdvertisedPrefixesPdpScopeExample(context),
},
{
ResourceName: "google_compute_public_advertised_prefix.prefix",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func testAccComputePublicAdvertisedPrefix_publicAdvertisedPrefixesPdpScopeExample(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_compute_public_advertised_prefix" "prefix" {
name = "tf-test-my-prefix%{random_suffix}"
description = "%{description}"
dns_verification_ip = "127.127.0.0"
ip_cidr_range = "127.127.0.0/16"
pdp_scope = "REGIONAL"
}
`, context)
}

func testAccComputePublicAdvertisedPrefix_publicAdvertisedPrefixesBasicTest(t *testing.T) {
t.Parallel()

Expand Down

0 comments on commit 327e1af

Please sign in to comment.