Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add workflows for managing AddressGroup subnets.
Change-Id: I6bb6a494d2f1e5097aa3eb27e7f520ff50b7e1c9 Partial-Bug: #1772594 (cherry picked from commit 84f4434)
- Loading branch information
1 parent
0eead5a
commit 876ef99
Showing
55 changed files
with
565 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
o11nplugin-contrail-custom/src/main/kotlin/net/juniper/contrail/vro/CustomCodeGenerator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
...sts/src/test/groovy/net/juniper/contrail/vro/tests/actions/AddressGroupSubnetsSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package net.juniper.contrail.vro.tests.actions | ||
|
||
import net.juniper.contrail.api.types.AddressGroup | ||
import net.juniper.contrail.api.types.SubnetListType | ||
import net.juniper.contrail.api.types.SubnetType | ||
import static net.juniper.contrail.vro.model.UtilsKt.utils | ||
import static net.juniper.contrail.vro.config.Actions.addressGroupSubnets | ||
|
||
class AddressGroupSubnetsSpec extends ActionSpec { | ||
def action = actionFromScript(addressGroupSubnets) | ||
|
||
def "null address group results in null" () { | ||
given: "null address group" | ||
def addressGroup = null | ||
|
||
when: "retrieved subnet list" | ||
def result = invokeAction(action, addressGroup) | ||
|
||
then: "resulting list is null" | ||
result == null | ||
} | ||
|
||
def "empty address group results in null" () { | ||
given: "empty address group" | ||
def addressGroup = new AddressGroup() | ||
|
||
when: "retrieved subnet list" | ||
def result = invokeAction(action, addressGroup) | ||
|
||
then: "resulting list is null" | ||
result == null | ||
} | ||
|
||
def "address group with empty subnet list results in empty list" () { | ||
given: "empty address group" | ||
def addressGroup = new AddressGroup() | ||
def subnetListType = new SubnetListType() | ||
addressGroup.prefix = subnetListType | ||
subnetListType.subnet = new ArrayList<>() | ||
|
||
when: "retrieved subnet list" | ||
def result = invokeAction(action, addressGroup) as List<String> | ||
|
||
then: "resulting list is empty" | ||
result.isEmpty() | ||
} | ||
|
||
def "address group with single subnet results in list with single formatted subnet" () { | ||
given: "address group with single subnet" | ||
def addressGroup = new AddressGroup() | ||
def subnetListType = new SubnetListType() | ||
addressGroup.prefix = subnetListType | ||
def somePrefix = "1.2.3.4" | ||
def somePrefixLen = 16 | ||
def subnet = new SubnetType(somePrefix, somePrefixLen) | ||
subnetListType.addSubnet(subnet) | ||
|
||
when: "retrieved subnet list" | ||
def result = invokeAction(action, addressGroup) as List<String> | ||
|
||
then: "resulting list has one formatted element" | ||
result.size() == 1 | ||
result[0] == utils.subnetToString(subnet) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
...ests/src/test/groovy/net/juniper/contrail/vro/tests/actions/NetworkIpamSubnetsSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package net.juniper.contrail.vro.tests.actions | ||
|
||
import net.juniper.contrail.api.types.IpamSubnetType | ||
import net.juniper.contrail.api.types.IpamSubnets | ||
import net.juniper.contrail.api.types.NetworkIpam | ||
import net.juniper.contrail.api.types.SubnetType | ||
|
||
import static net.juniper.contrail.vro.config.Actions.networkIpamSubnets | ||
import static net.juniper.contrail.vro.model.UtilsKt.utils | ||
|
||
class NetworkIpamSubnetsSpec extends ActionSpec { | ||
def action = actionFromScript(networkIpamSubnets) | ||
|
||
def "null network IPAM results in null" () { | ||
given: "null address group" | ||
def ipam = null | ||
|
||
when: "retrieved subnet list" | ||
def result = invokeAction(action, ipam) | ||
|
||
then: "resulting list is null" | ||
result == null | ||
} | ||
|
||
def "empty IPAM results in null" () { | ||
given: "empty IPAM" | ||
def ipam = new NetworkIpam() | ||
|
||
when: "retrieved subnet list" | ||
def result = invokeAction(action, ipam) | ||
|
||
then: "resulting list is null" | ||
result == null | ||
} | ||
|
||
def "IPAM with empty subnet list results in empty list" () { | ||
given: "empty IPAM" | ||
def ipam = new NetworkIpam() | ||
def ipamSubnets = new IpamSubnets() | ||
ipam.ipamSubnets = ipamSubnets | ||
ipamSubnets.subnets = new ArrayList<>() | ||
|
||
when: "retrieved subnet list" | ||
def result = invokeAction(action, ipam) as List<String> | ||
|
||
then: "resulting list is empty" | ||
result.isEmpty() | ||
} | ||
|
||
def "IPAM with single subnet results in list with single formatted subnet" () { | ||
given: "IPAM with single subnet" | ||
def ipam = new NetworkIpam() | ||
def ipamSubnets = new IpamSubnets() | ||
ipam.ipamSubnets = ipamSubnets | ||
def somePrefix = "1.2.3.4" | ||
def somePrefixLen = 16 | ||
def ipamSubnet = new IpamSubnetType() | ||
def subnet = new SubnetType(somePrefix, somePrefixLen) | ||
ipamSubnet.setSubnet(subnet) | ||
ipamSubnets.addSubnets(ipamSubnet) | ||
|
||
when: "retrieved subnet list" | ||
def result = invokeAction(action, ipam) as List<String> | ||
|
||
then: "resulting list has one formatted element" | ||
result.size() == 1 | ||
result[0] == utils.ipamSubnetToString(ipamSubnet) | ||
} | ||
} |
Oops, something went wrong.