Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mrhamburg authored and vaerh committed Jun 19, 2023
1 parent 188345a commit 817ec14
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 53 deletions.
18 changes: 10 additions & 8 deletions routeros/resource_routing_ospf_area.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,35 +27,37 @@ func ResourceRoutingOspfArea() *schema.Resource {
KeyName: PropNameForceNewRw,
KeyComment: PropCommentRw,
KeyDisabled: PropDisabledRw,
"area-id": {
"area_id": {
Type: schema.TypeString,
Default: "0.0.0.0",
Optional: true,
Description: "OSPF area identifier.",
},
"default-cost": {
"default_cost": {
Type: schema.TypeInt,
Required: false,
Optional: true,
Description: "Default cost of injected LSAs into the area.",
},
"instance": {
Type: schema.TypeString,
Required: true,
Description: "Name of the OSPF instance this area belongs to.",
},
"no-summaries": {
"no_summaries": {
Type: schema.TypeBool,
Default: false,
Required: false,
Optional: true,
Description: "If set then the area will not flood summary LSAs in the stub area.",
},
"nssa-translate": {
"nssa_translate": {
Type: schema.TypeString,
Required: false,
Optional: true,
Description: "The parameter indicates which ABR will be used as a translator from type7 to type5 LSA.",
ValidateFunc: validation.StringInSlice([]string{"no", "yes", "candidate"}, false),
},
"type": {
Type: schema.TypeString,
Required: true,
Optional: true,
Default: "default",
Description: "The area type.",
ValidateFunc: validation.StringInSlice([]string{"default", "nssa", "stub"}, true),
Expand Down
6 changes: 6 additions & 0 deletions routeros/resource_routing_ospf_area_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,15 @@ provider "routeros" {
insecure = true
}
resource "routeros_routing_ospf_instance" "test_routing_ospf_instance" {
name = "test_routing_ospf_instance"
disabled = false
}
resource "routeros_routing_ospf_area" "test_routing_ospf_area" {
name = "test_routing_ospf_area"
disabled = true
instance = routeros_routing_ospf_instance.test_routing_ospf_instance.name
}
`
Expand Down
28 changes: 16 additions & 12 deletions routeros/resource_routing_ospf_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,44 +34,45 @@ func ResourceRoutingOspfInstance() *schema.Resource {
KeyName: PropNameForceNewRw,
KeyComment: PropCommentRw,
KeyDisabled: PropDisabledRw,
"domain-id": {
"domain_id": {
Type: schema.TypeString,
Optional: true,
Description: "MPLS-related parameter.",
},
"domain-tag": {
"domain_tag": {
Type: schema.TypeInt,
Optional: true,
Description: "if set, then used in route redistribution (as route-tag in all external LSAs " +
"generated by this router), and in route calculation (all external LSAs having this route " +
"tag are ignored). Needed for interoperability with older Cisco systems. By default not set.",
},
"in-filter": {
"in_filter": {
Type: schema.TypeString,
Optional: true,
Description: "name of the routing filter chain used for incoming prefixes",
},
"mpls-te-address": {
"mpls_te_address": {
Type: schema.TypeString,
Optional: true,
Description: "the area used for MPLS traffic engineering.",
},
"mpls-te-area": {
"mpls_te_area": {
Type: schema.TypeString,
Optional: true,
Description: "the area used for MPLS traffic engineering.",
},
"originate-default": {
"originate_default": {
Type: schema.TypeString,
Default: "never",
Optional: true,
Description: "Specifies default route (0.0.0.0/0) distribution method.",
},
"out-filter-chain": {
"out_filter_chain": {
Type: schema.TypeString,
Optional: true,
Description: "name of the routing filter chain used for outgoing prefixes filtering.",
},
"out-filter-select": {
"out_filter_select": {
Type: schema.TypeString,
Optional: true,
Description: "name of the routing filter select chain, used for output selection.",
Expand All @@ -81,24 +82,27 @@ func ResourceRoutingOspfInstance() *schema.Resource {
Optional: true,
Description: "Enable redistribution of specific route types.",
},
"router-id": {
Type: schema.TypeString,
Default: "main",
"router_id": {
Type: schema.TypeString,
Default: "main",
Optional: true,
Description: "OSPF Router ID. Can be set explicitly as an IP address, or as the name " +
"of the router-id instance.",
},
"version": {
Type: schema.TypeInt,
Default: 2,
Optional: true,
Description: "OSPF version this instance will be running (v2 for IPv4, v3 for IPv6).",
ValidateFunc: validation.IntBetween(2, 3),
},
"vrf": {
Type: schema.TypeString,
Default: "main",
Optional: true,
Description: "the VRF table this OSPF instance operates on",
},
"use-dn": {
"use_dn": {
Type: schema.TypeString,
Optional: true,
Description: "",
Expand Down
84 changes: 53 additions & 31 deletions routeros/resource_routing_ospf_interface_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,19 @@ import (
func ResourceRoutingOspfInterfaceTemplate() *schema.Resource {
resSchema := map[string]*schema.Schema{
MetaResourcePath: PropResourcePath("/routing/ospf/interface-template"),
MetaId: PropId(Name),
MetaId: PropId(Id),

KeyComment: PropCommentRw,
KeyDisabled: PropDisabledRw,
"interfaces": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
Type: schema.TypeString,
Optional: true,
Default: "none",
Description: "Interfaces to match.",
},
"network": {
Type: schema.TypeString,
Optional: true,
Description: "The network prefix associated with the area.",
},
"area": {
Expand All @@ -58,76 +57,99 @@ func ResourceRoutingOspfInterfaceTemplate() *schema.Resource {
},
"auth": {
Type: schema.TypeString,
Optional: true,
Description: "Specifies authentication method for OSPF protocol messages.",
ValidateFunc: validation.StringInSlice([]string{"simple", "md5", "sha1", "sha256", "sha384", "sha512"}, true),
},
"auth-id": {
"auth_id": {
Type: schema.TypeInt,
Optional: true,
Description: "The key id is used to calculate message digest (used when MD5 or SHA authentication is enabled).",
},
"authentication-key": {
"authentication_key": {
Type: schema.TypeString,
Optional: true,
Description: "The authentication key to be used, should match on all the neighbors of the network segment.",
},
"cost": {
Type: schema.TypeInt,
Optional: true,
Default: 1,
Description: "Interface cost expressed as link state metric.",
ValidateFunc: validation.IntBetween(0, 65535),
},
"dead-interval": {
Type: schema.TypeString,
Default: "00:00:40",
Description: "Specifies the interval after which a neighbor is declared dead.",
},
"hello-interval": {
Type: schema.TypeString,
Default: "00:00:10",
Description: "The interval between HELLO packets that the router sends out this interface.",
},
"instance-id": {
"dead_interval": {
Type: schema.TypeString,
Optional: true,
Default: "40s",
ValidateFunc: ValidationTime,
DiffSuppressFunc: TimeEquall,
Description: "Specifies the interval after which a neighbor is declared dead.",
},
"hello_interval": {
Type: schema.TypeString,
Optional: true,
Default: "10s",
ValidateFunc: ValidationTime,
DiffSuppressFunc: TimeEquall,
Description: "The interval between HELLO packets that the router sends out this interface.",
},
"instance_id": {
Type: schema.TypeInt,
Optional: true,
Description: "Interface cost expressed as link state metric.",
Default: 0,
ValidateFunc: validation.IntBetween(0, 255),
},
"passive": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "If enabled, then do not send or receive OSPF traffic on the matching interfaces",
},
"prefix-list": {
"prefix_list": {
Type: schema.TypeString,
Optional: true,
Description: "Name of the address list containing networks that should be advertised to the v3 interface.",
},
"priority": {
Type: schema.TypeInt,
Optional: true,
Description: "Router's priority. Used to determine the designated router in a broadcast network.",
Default: 128,
ValidateFunc: validation.IntBetween(0, 255),
},
"retransmit-interval": {
Type: schema.TypeString,
Default: "00:00:05",
Description: "Time interval the lost link state advertisement will be resent.",
},
"transmit-delay": {
Type: schema.TypeString,
Default: "00:00:01",
Description: "Link-state transmit delay is the estimated time it takes to transmit a link-state update packet on the interface.",
"retransmit_interval": {
Type: schema.TypeString,
Optional: true,
Default: "5s",
ValidateFunc: ValidationTime,
DiffSuppressFunc: TimeEquall,
Description: "Time interval the lost link state advertisement will be resent.",
},
"transmit_delay": {
Type: schema.TypeString,
Optional: true,
Default: "1s",
ValidateFunc: ValidationTime,
DiffSuppressFunc: TimeEquall,
Description: "Link-state transmit delay is the estimated time it takes to transmit a link-state update packet on the interface.",
},
"type": {
Type: schema.TypeString,
Description: "The OSPF network type on this interface.",
Optional: true,
Default: "broadcast",
ValidateFunc: validation.StringInSlice([]string{"broadcast", "nbma", "ptp", "ptmp", "ptp-unnumbered", "virtual-link"}, true),
},
"vlink-neighbor-id": {
"vlink_neighbor_id": {
Type: schema.TypeString,
Optional: true,
Description: "Specifies the router-id of the neighbor which should be connected over the virtual link.",
},
"vlink-transit-area": {
"vlink_transit_area": {
Type: schema.TypeString,
Optional: true,
Description: "A non-backbone area the two routers have in common over which the virtual link will be established.",
},
}
Expand Down
10 changes: 8 additions & 2 deletions routeros/resource_routing_ospf_interface_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestAccRoutingOspfInterfaceTemplateTest_basic(t *testing.T) {
Config: testAccCheckRoutingOspfInterfaceTemplateConfig(),
Check: resource.ComposeTestCheckFunc(
testAccCheckRoutingOspfInterfaceTemplateExists(testRoutingOspfInterfaceTemplate),
resource.TestCheckResourceAttr(testRoutingOspfInterfaceTemplate, "name", "test_routing_ospf_interface_template"),
resource.TestCheckResourceAttr(testRoutingOspfInterfaceTemplate, "area", "test_routing_ospf_area"),
),
},
},
Expand Down Expand Up @@ -57,9 +57,15 @@ provider "routeros" {
insecure = true
}
resource "routeros_routing_ospf_instance" "test_routing_ospf_instance" {
name = "test_routing_ospf_instance"
disabled = false
}
resource "routeros_routing_ospf_area" "test_routing_ospf_area" {
name = "test_routing_ospf_area"
disabled = true
disabled = false
instance = routeros_routing_ospf_instance.test_routing_ospf_instance.name
}
resource "routeros_routing_ospf_interface_template" "test_routing_ospf_interface_template" {
Expand Down

0 comments on commit 817ec14

Please sign in to comment.