Skip to content

Commit

Permalink
fiexed test files after rebase (#68)
Browse files Browse the repository at this point in the history
* fiexed test files after rebase

* updated test files after rebase

Co-authored-by: harshthakkar_crest <[email protected]>
  • Loading branch information
RutvikS-crest and harshthakkar_crest authored Dec 31, 2021
1 parent 373ba7d commit 9737a35
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 148 deletions.
16 changes: 10 additions & 6 deletions aci/resource_aci_fvbd.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func resourceAciBridgeDomain() *schema.Resource {
Optional: true,
},
"relation_fv_rs_mldsn": &schema.Schema{
Type: schema.TypeString,
Type: schema.TypeString,

Optional: true,
},
Expand All @@ -244,7 +244,7 @@ func resourceAciBridgeDomain() *schema.Resource {
Optional: true,
},
"relation_fv_rs_bd_to_nd_p": &schema.Schema{
Type: schema.TypeString,
Type: schema.TypeString,

Optional: true,
},
Expand All @@ -265,7 +265,7 @@ func resourceAciBridgeDomain() *schema.Resource {
Optional: true,
},
"relation_fv_rs_ctx": &schema.Schema{
Type: schema.TypeString,
Type: schema.TypeString,

Optional: true,
},
Expand All @@ -286,12 +286,12 @@ func resourceAciBridgeDomain() *schema.Resource {
},
},
"relation_fv_rs_igmpsn": &schema.Schema{
Type: schema.TypeString,
Type: schema.TypeString,

Optional: true,
},
"relation_fv_rs_bd_to_ep_ret": &schema.Schema{
Type: schema.TypeString,
Type: schema.TypeString,

Optional: true,
},
Expand Down Expand Up @@ -338,7 +338,11 @@ func setBridgeDomainAttributes(fvBD *models.BridgeDomain, d *schema.ResourceData
d.Set("annotation", fvBDMap["annotation"])
d.Set("arp_flood", fvBDMap["arpFlood"])
d.Set("ep_clear", fvBDMap["epClear"])
d.Set("ep_move_detect_mode", fvBDMap["epMoveDetectMode"])
if fvBDMap["epMoveDetectMode"] == "" {
d.Set("ep_move_detect_mode", "disable")
} else {
d.Set("ep_move_detect_mode", fvBDMap["epMoveDetectMode"])
}
d.Set("host_based_routing", fvBDMap["hostBasedRouting"])
d.Set("intersite_bum_traffic_allow", fvBDMap["intersiteBumTrafficAllow"])
d.Set("intersite_l2_stretch", fvBDMap["intersiteL2Stretch"])
Expand Down
18 changes: 2 additions & 16 deletions aci/resource_aci_fvesg.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,13 @@ func setEndpointSecurityGroupAttributes(fvESg *models.EndpointSecurityGroup, d *
return d, err
}
d.Set("annotation", fvESgMap["annotation"])
d.Set("flood_on_encap", fvESgMap["floodOnEncap"])

d.Set("match_t", fvESgMap["matchT"])
d.Set("name", fvESgMap["name"])
d.Set("application_profile_dn", GetParentDn(fvESg.DistinguishedName, fmt.Sprintf("/esg-%s", fvESgMap["name"])))
d.Set("pc_enf_pref", fvESgMap["pcEnfPref"])
d.Set("pref_gr_memb", fvESgMap["prefGrMemb"])
d.Set("prio", fvESgMap["prio"])

d.Set("name_alias", fvESgMap["nameAlias"])
return d, nil
}
Expand Down Expand Up @@ -251,10 +251,6 @@ func resourceAciEndpointSecurityGroupCreate(ctx context.Context, d *schema.Resou
fvESgAttr.Annotation = "{}"
}

if FloodOnEncap, ok := d.GetOk("flood_on_encap"); ok {
fvESgAttr.FloodOnEncap = FloodOnEncap.(string)
}

if MatchT, ok := d.GetOk("match_t"); ok {
fvESgAttr.MatchT = MatchT.(string)
}
Expand All @@ -271,9 +267,6 @@ func resourceAciEndpointSecurityGroupCreate(ctx context.Context, d *schema.Resou
fvESgAttr.PrefGrMemb = PrefGrMemb.(string)
}

if Prio, ok := d.GetOk("prio"); ok {
fvESgAttr.Prio = Prio.(string)
}
fvESg := models.NewEndpointSecurityGroup(fmt.Sprintf("esg-%s", name), ApplicationProfileDn, desc, nameAlias, fvESgAttr)

err := aciClient.Save(fvESg)
Expand Down Expand Up @@ -450,10 +443,6 @@ func resourceAciEndpointSecurityGroupUpdate(ctx context.Context, d *schema.Resou
fvESgAttr.Annotation = "{}"
}

if FloodOnEncap, ok := d.GetOk("flood_on_encap"); ok {
fvESgAttr.FloodOnEncap = FloodOnEncap.(string)
}

if MatchT, ok := d.GetOk("match_t"); ok {
fvESgAttr.MatchT = MatchT.(string)
}
Expand All @@ -470,9 +459,6 @@ func resourceAciEndpointSecurityGroupUpdate(ctx context.Context, d *schema.Resou
fvESgAttr.PrefGrMemb = PrefGrMemb.(string)
}

if Prio, ok := d.GetOk("prio"); ok {
fvESgAttr.Prio = Prio.(string)
}
fvESg := models.NewEndpointSecurityGroup(fmt.Sprintf("esg-%s", name), ApplicationProfileDn, desc, nameAlias, fvESgAttr)

fvESg.Status = "modified"
Expand Down
2 changes: 0 additions & 2 deletions testacc/data_source_aci_fvesg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,9 @@ func TestAccAciEndpointSecurityGroupDataSource_Basic(t *testing.T) {
resource.TestCheckResourceAttrPair(dataSourceName, "annotation", resourceName, "annotation"),
resource.TestCheckResourceAttrPair(dataSourceName, "description", resourceName, "description"),
resource.TestCheckResourceAttrPair(dataSourceName, "name_alias", resourceName, "name_alias"),
resource.TestCheckResourceAttrPair(dataSourceName, "flood_on_encap", resourceName, "flood_on_encap"),
resource.TestCheckResourceAttrPair(dataSourceName, "match_t", resourceName, "match_t"),
resource.TestCheckResourceAttrPair(dataSourceName, "pc_enf_pref", resourceName, "pc_enf_pref"),
resource.TestCheckResourceAttrPair(dataSourceName, "pref_gr_memb", resourceName, "pref_gr_memb"),
resource.TestCheckResourceAttrPair(dataSourceName, "prio", resourceName, "prio"),
),
},
{
Expand Down
8 changes: 4 additions & 4 deletions testacc/resource_aci_fvany_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func TestAccAciAny_Basic(t *testing.T) {
),
},
{
Config: CreateAccAnyConfigUpdateWithoutVRFdn(rName),
Config: CreateAccAnyConfigUpdateWithoutVRFdn(),
ExpectError: regexp.MustCompile(`Missing required argument`),
},
{
Expand Down Expand Up @@ -315,7 +315,7 @@ func CreateAccAnyWithoutVRFdn(rName string) string {
`, rName, rName)
return resource
}
func CreateAccAnyConfigUpdateWithoutVRFdn(rName string) string {
func CreateAccAnyConfigUpdateWithoutVRFdn() string {
fmt.Println("=== STEP Basic: testing any update without required argument")
resource := fmt.Sprintln(`
resource "aci_any" "test" {
Expand All @@ -325,7 +325,7 @@ func CreateAccAnyConfigUpdateWithoutVRFdn(rName string) string {
name_alias = "alias_any"
pref_gr_memb = "enabled"
}
`, rName, rName)
`)
return resource
}
func CreateAccAnyConfigWithAnotherVRFdn(rName, rOther string) string {
Expand Down Expand Up @@ -361,7 +361,7 @@ func CreateAccAnyConfigWithInvaliVRFdn(rName string) string {
return resource
}
func CreateAccAnyConfig(rName string) string {
fmt.Println("=== STEP testing any creation with required argument")
fmt.Println("=== STEP testing any creation with required argument")
resource := fmt.Sprintf(`
resource "aci_tenant" "test" {
name = "%s"
Expand Down
7 changes: 4 additions & 3 deletions testacc/resource_aci_fvbd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestAccAciBridgeDomain_Basic(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "annotation", "orchestrator:terraform"),
resource.TestCheckResourceAttr(resourceName, "arp_flood", "no"),
resource.TestCheckResourceAttr(resourceName, "ep_clear", "no"),
//resource.TestCheckResourceAttr(resourceName, "ep_move_detect_mode", ""), no need to check these parameter for now will look into it in regression testing
resource.TestCheckResourceAttr(resourceName, "ep_move_detect_mode", "disable"),
resource.TestCheckResourceAttr(resourceName, "host_based_routing", "no"),
resource.TestCheckResourceAttr(resourceName, "intersite_bum_traffic_allow", "no"),
resource.TestCheckResourceAttr(resourceName, "intersite_l2_stretch", "no"),
Expand Down Expand Up @@ -79,7 +79,7 @@ func TestAccAciBridgeDomain_Basic(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "annotation", "test_annotation"),
resource.TestCheckResourceAttr(resourceName, "arp_flood", "yes"),
resource.TestCheckResourceAttr(resourceName, "ep_clear", "yes"),
//resource.TestCheckResourceAttr(resourceName, "ep_move_detect_mode", ""),
resource.TestCheckResourceAttr(resourceName, "ep_move_detect_mode", "garp"),
resource.TestCheckResourceAttr(resourceName, "host_based_routing", "yes"),
resource.TestCheckResourceAttr(resourceName, "intersite_bum_traffic_allow", "yes"),
resource.TestCheckResourceAttr(resourceName, "intersite_l2_stretch", "yes"),
Expand Down Expand Up @@ -516,7 +516,7 @@ func CreateAccBridgeDomainRelConfigFinal(rName, relName1, relName2 string) strin
}

func CreateAccBridgeDomainRelConfigInitial(rName, relName string) string {
fmt.Println("=== STEP testing bridge domain with final relational parameters")
fmt.Println("=== STEP testing bridge domain with initial relational parameters")
resource := fmt.Sprintf(`
resource "aci_tenant" "test" {
name = "%s"
Expand Down Expand Up @@ -641,6 +641,7 @@ func CreateAccBridgeDomainConfigWithOptionalValues(rName string) string {
arp_flood= "yes"
description= "test_desc"
ep_clear="yes"
ep_move_detect_mode = "garp"
host_based_routing="yes"
intersite_bum_traffic_allow="yes"
intersite_l2_stretch="yes"
Expand Down
57 changes: 0 additions & 57 deletions testacc/resource_aci_fvesg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,11 @@ func TestAccAciEndpointSecurityGroup_Basic(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "annotation", "orchestrator:terraform"),
resource.TestCheckResourceAttr(resourceName, "application_profile_dn", fmt.Sprintf("uni/tn-%s/ap-%s", rName, rName)),
resource.TestCheckResourceAttr(resourceName, "description", ""),
resource.TestCheckResourceAttr(resourceName, "flood_on_encap", "disabled"),
resource.TestCheckResourceAttr(resourceName, "match_t", "AtleastOne"),
resource.TestCheckResourceAttr(resourceName, "name", rName),
resource.TestCheckResourceAttr(resourceName, "name_alias", ""),
resource.TestCheckResourceAttr(resourceName, "pc_enf_pref", "unenforced"),
resource.TestCheckResourceAttr(resourceName, "pref_gr_memb", "exclude"),
resource.TestCheckResourceAttr(resourceName, "prio", "unspecified"),
resource.TestCheckResourceAttr(resourceName, "relation_fv_rs_cons.#", "0"),
resource.TestCheckResourceAttr(resourceName, "relation_fv_rs_cons_if.#", "0"),
resource.TestCheckResourceAttr(resourceName, "relation_fv_rs_prov.#", "0"),
Expand All @@ -59,13 +57,11 @@ func TestAccAciEndpointSecurityGroup_Basic(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "annotation", "test_annotation"),
resource.TestCheckResourceAttr(resourceName, "application_profile_dn", fmt.Sprintf("uni/tn-%s/ap-%s", rName, rName)),
resource.TestCheckResourceAttr(resourceName, "description", "test_description"),
resource.TestCheckResourceAttr(resourceName, "flood_on_encap", "enabled"),
resource.TestCheckResourceAttr(resourceName, "match_t", "All"),
resource.TestCheckResourceAttr(resourceName, "name", rName),
resource.TestCheckResourceAttr(resourceName, "name_alias", "test_name_alias"),
resource.TestCheckResourceAttr(resourceName, "pc_enf_pref", "enforced"),
resource.TestCheckResourceAttr(resourceName, "pref_gr_memb", "include"),
resource.TestCheckResourceAttr(resourceName, "prio", "level1"),
resource.TestCheckResourceAttr(resourceName, "relation_fv_rs_cons.#", "0"),
resource.TestCheckResourceAttr(resourceName, "relation_fv_rs_cons_if.#", "0"),
resource.TestCheckResourceAttr(resourceName, "relation_fv_rs_intra_epg.#", "0"),
Expand Down Expand Up @@ -137,46 +133,6 @@ func TestAccAciEndpointSecurityGroup_Update(t *testing.T) {
testAccCheckAciEndpointSecurityGroupIdEqual(&esg_default, &esg_updated),
),
},
{
Config: CreateAccEndpointSecurityGroupConfigWithUpdatedAttr(rName, "prio", "level2"),
Check: resource.ComposeTestCheckFunc(
testAccCheckAciEndpointSecurityGroupExists(resourceName, &esg_updated),
resource.TestCheckResourceAttr(resourceName, "prio", "level2"),
testAccCheckAciEndpointSecurityGroupIdEqual(&esg_default, &esg_updated),
),
},
{
Config: CreateAccEndpointSecurityGroupConfigWithUpdatedAttr(rName, "prio", "level3"),
Check: resource.ComposeTestCheckFunc(
testAccCheckAciEndpointSecurityGroupExists(resourceName, &esg_updated),
resource.TestCheckResourceAttr(resourceName, "prio", "level3"),
testAccCheckAciEndpointSecurityGroupIdEqual(&esg_default, &esg_updated),
),
},
{
Config: CreateAccEndpointSecurityGroupConfigWithUpdatedAttr(rName, "prio", "level4"),
Check: resource.ComposeTestCheckFunc(
testAccCheckAciEndpointSecurityGroupExists(resourceName, &esg_updated),
resource.TestCheckResourceAttr(resourceName, "prio", "level4"),
testAccCheckAciEndpointSecurityGroupIdEqual(&esg_default, &esg_updated),
),
},
{
Config: CreateAccEndpointSecurityGroupConfigWithUpdatedAttr(rName, "prio", "level5"),
Check: resource.ComposeTestCheckFunc(
testAccCheckAciEndpointSecurityGroupExists(resourceName, &esg_updated),
resource.TestCheckResourceAttr(resourceName, "prio", "level5"),
testAccCheckAciEndpointSecurityGroupIdEqual(&esg_default, &esg_updated),
),
},
{
Config: CreateAccEndpointSecurityGroupConfigWithUpdatedAttr(rName, "prio", "level6"),
Check: resource.ComposeTestCheckFunc(
testAccCheckAciEndpointSecurityGroupExists(resourceName, &esg_updated),
resource.TestCheckResourceAttr(resourceName, "prio", "level6"),
testAccCheckAciEndpointSecurityGroupIdEqual(&esg_default, &esg_updated),
),
},
},
})
}
Expand Down Expand Up @@ -211,10 +167,6 @@ func TestAccAciEndpointSecurityGroup_NegativeCases(t *testing.T) {
Config: CreateAccEndpointSecurityGroupConfigWithUpdatedAttr(rName, "name_alias", longNameAlias),
ExpectError: regexp.MustCompile(`property nameAlias of (.)+ failed validation for value '(.)+'`),
},
{
Config: CreateAccEndpointSecurityGroupConfigWithUpdatedAttr(rName, "flood_on_encap", randomValue),
ExpectError: regexp.MustCompile(`expected flood_on_encap to be one of (.)+, got (.)+`),
},
{
Config: CreateAccEndpointSecurityGroupConfigWithUpdatedAttr(rName, "match_t", randomValue),
ExpectError: regexp.MustCompile(`expected match_t to be one of (.)+, got (.)+`),
Expand All @@ -227,10 +179,6 @@ func TestAccAciEndpointSecurityGroup_NegativeCases(t *testing.T) {
Config: CreateAccEndpointSecurityGroupConfigWithUpdatedAttr(rName, "pref_gr_memb", randomValue),
ExpectError: regexp.MustCompile(`expected pref_gr_memb to be one of (.)+, got (.)+`),
},
{
Config: CreateAccEndpointSecurityGroupConfigWithUpdatedAttr(rName, "prio", randomValue),
ExpectError: regexp.MustCompile(`expected prio to be one of (.)+, got (.)+`),
},
{
Config: CreateAccEndpointSecurityGroupConfigWithUpdatedAttr(rName, randomParameter, randomValue),
ExpectError: regexp.MustCompile(`An argument named (.)+ is not expected here.`),
Expand Down Expand Up @@ -336,12 +284,10 @@ func CreateAccEndpointSecurityGroupConfigWithParentAndName(prName, rName string)
application_profile_dn = aci_application_profile.test.id
annotation = "test_annotation"
description = "test_description"
flood_on_encap = "enabled"
match_t = "All"
name_alias = "test_name_alias"
pc_enf_pref = "enforced"
pref_gr_memb = "include"
prio = "level1"
}
`, prName, prName, rName)
return resource
Expand All @@ -358,7 +304,6 @@ func CreateAccEndpointSecurityGroupRemovingRequiredField() string {
name_alias = "test_name_alias"
pc_enf_pref = "enforced"
pref_gr_memb = "include"
prio = "level1"
}
`)
return resource
Expand Down Expand Up @@ -402,12 +347,10 @@ func CreateAccEndpointSecurityGroupConfigWithOptionalValues(rName string) string
application_profile_dn = aci_application_profile.test.id
annotation = "test_annotation"
description = "test_description"
flood_on_encap = "enabled"
match_t = "All"
name_alias = "test_name_alias"
pc_enf_pref = "enforced"
pref_gr_memb = "include"
prio = "level1"
}
`, rName, rName, rName)
return resource
Expand Down
Loading

0 comments on commit 9737a35

Please sign in to comment.