summaryrefslogtreecommitdiffstats
path: root/dhcp/dhcp-impl/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'dhcp/dhcp-impl/src/test')
-rw-r--r--dhcp/dhcp-impl/src/test/java/io/fd/hc2vpp/dhcp/read/DhcpRelayCustomizerTest.java48
-rw-r--r--dhcp/dhcp-impl/src/test/java/io/fd/hc2vpp/dhcp/write/DhcpRelayCustomizerTest.java31
-rw-r--r--dhcp/dhcp-impl/src/test/resources/relay/ipv4DhcpRelay.json13
-rw-r--r--dhcp/dhcp-impl/src/test/resources/relay/ipv6DhcpRelay.json13
-rw-r--r--dhcp/dhcp-impl/src/test/resources/relay/ipv6DhcpRelayAfter.json17
-rw-r--r--dhcp/dhcp-impl/src/test/resources/relay/ipv6DhcpRelayBefore.json21
6 files changed, 99 insertions, 44 deletions
diff --git a/dhcp/dhcp-impl/src/test/java/io/fd/hc2vpp/dhcp/read/DhcpRelayCustomizerTest.java b/dhcp/dhcp-impl/src/test/java/io/fd/hc2vpp/dhcp/read/DhcpRelayCustomizerTest.java
index 79a1f44c8..0a64dd880 100644
--- a/dhcp/dhcp-impl/src/test/java/io/fd/hc2vpp/dhcp/read/DhcpRelayCustomizerTest.java
+++ b/dhcp/dhcp-impl/src/test/java/io/fd/hc2vpp/dhcp/read/DhcpRelayCustomizerTest.java
@@ -28,6 +28,7 @@ import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.vpp.jvpp.core.dto.DhcpProxyDetails;
import io.fd.vpp.jvpp.core.dto.DhcpProxyDetailsReplyDump;
import io.fd.vpp.jvpp.core.dto.DhcpProxyDump;
+import io.fd.vpp.jvpp.core.types.DhcpServer;
import java.util.List;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev170315.Dhcp;
@@ -38,19 +39,20 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev170315.dhcp.attributes.relays.Relay;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev170315.dhcp.attributes.relays.RelayBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev170315.dhcp.attributes.relays.RelayKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.dhcp.rev170315.relay.attributes.Server;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
public class DhcpRelayCustomizerTest extends InitializingListReaderCustomizerTest<Relay, RelayKey, RelayBuilder> {
+ private static InstanceIdentifier<Relays> RELAYS = InstanceIdentifier.create(Dhcp.class).child(Relays.class);
+ private KeyedInstanceIdentifier<Relay, RelayKey> IP4_IID =
+ RELAYS.child(Relay.class, new RelayKey(Ipv4.class, 123L));
+ private KeyedInstanceIdentifier<Relay, RelayKey> IP6_IID =
+ RELAYS.child(Relay.class, new RelayKey(Ipv6.class, 321L));
public DhcpRelayCustomizerTest() {
super(Relay.class, RelaysBuilder.class);
}
- private static InstanceIdentifier<Relays> RELAYS = InstanceIdentifier.create(Dhcp.class).child(Relays.class);
-
- private KeyedInstanceIdentifier<Relay, RelayKey> IP4_IID = RELAYS.child(Relay.class, new RelayKey(Ipv4.class, 123L));
- private KeyedInstanceIdentifier<Relay, RelayKey> IP6_IID = RELAYS.child(Relay.class, new RelayKey(Ipv6.class, 321L));
-
@Override
protected ReaderCustomizer<Relay, RelayBuilder> initCustomizer() {
return new DhcpRelayCustomizer(api);
@@ -61,9 +63,14 @@ public class DhcpRelayCustomizerTest extends InitializingListReaderCustomizerTes
final DhcpProxyDetailsReplyDump ip4 = new DhcpProxyDetailsReplyDump();
final DhcpProxyDetails ip4Proxy = new DhcpProxyDetails();
ip4Proxy.rxVrfId = 123;
- ip4Proxy.dhcpSrcAddress = new byte[]{1,2,3,4};
- ip4Proxy.serverVrfId = 11;
- ip4Proxy.dhcpServer = new byte[]{8,8,8,8};
+ ip4Proxy.dhcpSrcAddress = new byte[] {1, 2, 3, 4};
+ final DhcpServer ip4server1 = new DhcpServer();
+ ip4server1.serverVrfId = 11;
+ ip4server1.dhcpServer = new byte[] {8, 8, 8, 8};
+ final DhcpServer ip4server2 = new DhcpServer();
+ ip4server2.serverVrfId = 12;
+ ip4server2.dhcpServer = new byte[] {8, 8, 8, 4};
+ ip4Proxy.servers = new DhcpServer[] {ip4server1, ip4server2};
ip4.dhcpProxyDetails.add(ip4Proxy);
when(api.dhcpProxyDump(new DhcpProxyDump())).thenReturn(future(ip4));
@@ -71,12 +78,15 @@ public class DhcpRelayCustomizerTest extends InitializingListReaderCustomizerTes
final DhcpProxyDetails ip6Proxy = new DhcpProxyDetails();
ip6Proxy.rxVrfId = 321;
// 2001:0db8:0a0b:12f0:0000:0000:0000:0001
- ip6Proxy.dhcpSrcAddress = new byte[] {0x20, 0x01, 0x0d, (byte) 0xb8, 0x0a, 0x0b, 0x12, (byte) 0xf0, 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0x01};
- ip6Proxy.serverVrfId = 22;
- ip6Proxy.isIpv6 = 1;
+ ip6Proxy.dhcpSrcAddress =
+ new byte[] {0x20, 0x01, 0x0d, (byte) 0xb8, 0x0a, 0x0b, 0x12, (byte) 0xf0, 0, 0, 0, 0, 0, 0, 0, 0x01};
+ final DhcpServer ip6server = new DhcpServer();
+ ip6server.serverVrfId = 22;
// 2001:0db8:0a0b:12f0:0000:0000:0000:0002
- ip6Proxy.dhcpServer = new byte[] {0x20, 0x01, 0x0d, (byte) 0xb8, 0x0a, 0x0b, 0x12, (byte) 0xf0, 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0x02};
-
+ ip6server.dhcpServer =
+ new byte[] {0x20, 0x01, 0x0d, (byte) 0xb8, 0x0a, 0x0b, 0x12, (byte) 0xf0, 0, 0, 0, 0, 0, 0, 0, 0x02};
+ ip6Proxy.servers = new DhcpServer[] {ip6server};
+ ip6Proxy.isIpv6 = 1;
final DhcpProxyDump ip6Dump = new DhcpProxyDump();
ip6Dump.isIp6 = 1;
ip6.dhcpProxyDetails.add(ip6Proxy);
@@ -96,9 +106,13 @@ public class DhcpRelayCustomizerTest extends InitializingListReaderCustomizerTes
getCustomizer().readCurrentAttributes(IP4_IID, builder, ctx);
assertEquals(IP4_IID.getKey().getAddressType(), builder.getAddressType());
assertEquals(IP4_IID.getKey().getRxVrfId(), builder.getRxVrfId());
- assertEquals(11L, builder.getServerVrfId().longValue());
assertArrayEquals("1.2.3.4".toCharArray(), builder.getGatewayAddress().getValue());
- assertArrayEquals("8.8.8.8".toCharArray(), builder.getServerAddress().getValue());
+ final List<Server> server = builder.getServer();
+ assertEquals(2, server.size());
+ assertEquals(11L, server.get(0).getVrfId().longValue());
+ assertArrayEquals("8.8.8.8".toCharArray(), server.get(0).getAddress().getValue());
+ assertEquals(12L, server.get(1).getVrfId().longValue());
+ assertArrayEquals("8.8.8.4".toCharArray(), server.get(1).getAddress().getValue());
}
@Test
@@ -107,9 +121,9 @@ public class DhcpRelayCustomizerTest extends InitializingListReaderCustomizerTes
getCustomizer().readCurrentAttributes(IP6_IID, builder, ctx);
assertEquals(IP6_IID.getKey().getAddressType(), builder.getAddressType());
assertEquals(IP6_IID.getKey().getRxVrfId(), builder.getRxVrfId());
- assertEquals(22L, builder.getServerVrfId().longValue());
+ assertEquals(22L, builder.getServer().get(0).getVrfId().longValue());
assertArrayEquals("2001:db8:a0b:12f0::1".toCharArray(), builder.getGatewayAddress().getValue());
- assertArrayEquals("2001:db8:a0b:12f0::2".toCharArray(), builder.getServerAddress().getValue());
+ assertArrayEquals("2001:db8:a0b:12f0::2".toCharArray(), builder.getServer().get(0).getAddress().getValue());
}
@Test
diff --git a/dhcp/dhcp-impl/src/test/java/io/fd/hc2vpp/dhcp/write/DhcpRelayCustomizerTest.java b/dhcp/dhcp-impl/src/test/java/io/fd/hc2vpp/dhcp/write/DhcpRelayCustomizerTest.java
index d13990c7a..a6a407ae4 100644
--- a/dhcp/dhcp-impl/src/test/java/io/fd/hc2vpp/dhcp/write/DhcpRelayCustomizerTest.java
+++ b/dhcp/dhcp-impl/src/test/java/io/fd/hc2vpp/dhcp/write/DhcpRelayCustomizerTest.java
@@ -17,7 +17,6 @@
package io.fd.hc2vpp.dhcp.write;
import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -43,7 +42,8 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
public class DhcpRelayCustomizerTest extends WriterCustomizerTest implements SchemaContextTestHelper {
private static final String RELAYS_PATH = "/dhcp:dhcp/dhcp:relays";
- private static final InstanceIdentifier<Relays> RELAYS_IID = InstanceIdentifier.create(Dhcp.class).child(Relays.class);
+ private static final InstanceIdentifier<Relays> RELAYS_IID =
+ InstanceIdentifier.create(Dhcp.class).child(Relays.class);
private DhcpRelayCustomizer customizer;
@@ -63,24 +63,29 @@ public class DhcpRelayCustomizerTest extends WriterCustomizerTest implements Sch
request.rxVrfId = rxVrfId;
request.isIpv6 = 0;
request.isAdd = 1;
- request.dhcpServer = new byte[]{1,2,3,4};
- request.dhcpSrcAddress = new byte[]{5,6,7,8};
+ request.dhcpServer = new byte[] {1, 2, 3, 4};
+ request.dhcpSrcAddress = new byte[] {5, 6, 7, 8};
+ verify(api).dhcpProxyConfig(request);
+ request.dhcpServer = new byte[] {1, 2, 3, 5};
verify(api).dhcpProxyConfig(request);
}
@Test
- public void testUpdate(@InjectTestData(resourcePath = "/relay/ipv6DhcpRelay.json", id = RELAYS_PATH) Relays relays)
+ public void testUpdate(
+ @InjectTestData(resourcePath = "/relay/ipv6DhcpRelayBefore.json", id = RELAYS_PATH) Relays relaysBefore,
+ @InjectTestData(resourcePath = "/relay/ipv6DhcpRelayAfter.json", id = RELAYS_PATH) Relays relayAfter)
throws WriteFailedException {
- final Relay data = relays.getRelay().get(0);
+ final Relay before = relaysBefore.getRelay().get(0);
+ final Relay after = relayAfter.getRelay().get(0);
final int rxVrfId = 1;
- customizer.updateCurrentAttributes(getId(rxVrfId, Ipv6.class), mock(Relay.class), data, writeContext);
+ customizer.updateCurrentAttributes(getId(rxVrfId, Ipv6.class), before, after, writeContext);
final DhcpProxyConfig request = new DhcpProxyConfig();
request.rxVrfId = rxVrfId;
request.serverVrfId = 2;
request.isIpv6 = 1;
- request.isAdd = 1;
- request.dhcpServer = new byte[]{0x20, 0x01, 0, 0, 0, 0, 0, 0, 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0x01};
- request.dhcpSrcAddress = new byte[]{0x20, 0x01, 0, 0, 0, 0, 0, 0, 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0x02};
+ request.isAdd = 0;
+ request.dhcpServer = new byte[] {0x20, 0x01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x01};
+ request.dhcpSrcAddress = new byte[] {0x20, 0x01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x02};
verify(api).dhcpProxyConfig(request);
}
@@ -94,8 +99,10 @@ public class DhcpRelayCustomizerTest extends WriterCustomizerTest implements Sch
request.rxVrfId = rxVrfId;
request.isIpv6 = 0;
request.isAdd = 0;
- request.dhcpServer = new byte[]{1,2,3,4};
- request.dhcpSrcAddress = new byte[]{5,6,7,8};
+ request.dhcpServer = new byte[] {1, 2, 3, 4};
+ request.dhcpSrcAddress = new byte[] {5, 6, 7, 8};
+ verify(api).dhcpProxyConfig(request);
+ request.dhcpServer = new byte[] {1, 2, 3, 5};
verify(api).dhcpProxyConfig(request);
}
diff --git a/dhcp/dhcp-impl/src/test/resources/relay/ipv4DhcpRelay.json b/dhcp/dhcp-impl/src/test/resources/relay/ipv4DhcpRelay.json
index 27550e45f..2c7dda289 100644
--- a/dhcp/dhcp-impl/src/test/resources/relay/ipv4DhcpRelay.json
+++ b/dhcp/dhcp-impl/src/test/resources/relay/ipv4DhcpRelay.json
@@ -4,8 +4,17 @@
{
"address-type": "ipv4",
"rx-vrf-id": 0,
- "server-address": "1.2.3.4",
- "gateway-address": "5.6.7.8"
+ "gateway-address": "5.6.7.8",
+ "server" : [
+ {
+ "vrf-id": 0,
+ "address": "1.2.3.4"
+ },
+ {
+ "vrf-id": 0,
+ "address": "1.2.3.5"
+ }
+ ]
}
]
}
diff --git a/dhcp/dhcp-impl/src/test/resources/relay/ipv6DhcpRelay.json b/dhcp/dhcp-impl/src/test/resources/relay/ipv6DhcpRelay.json
deleted file mode 100644
index ca7e51ace..000000000
--- a/dhcp/dhcp-impl/src/test/resources/relay/ipv6DhcpRelay.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "relays": {
- "relay": [
- {
- "address-type": "ipv6",
- "rx-vrf-id": 1,
- "server-address": "2001::1",
- "server-vrf-id": 2,
- "gateway-address": "2001::2"
- }
- ]
- }
-}
diff --git a/dhcp/dhcp-impl/src/test/resources/relay/ipv6DhcpRelayAfter.json b/dhcp/dhcp-impl/src/test/resources/relay/ipv6DhcpRelayAfter.json
new file mode 100644
index 000000000..7c2518b54
--- /dev/null
+++ b/dhcp/dhcp-impl/src/test/resources/relay/ipv6DhcpRelayAfter.json
@@ -0,0 +1,17 @@
+{
+ "relays": {
+ "relay": [
+ {
+ "address-type": "ipv6",
+ "rx-vrf-id": 1,
+ "gateway-address": "2001::2",
+ "server" : [
+ {
+ "vrf-id": 2,
+ "address": "2001::10"
+ }
+ ]
+ }
+ ]
+ }
+}
diff --git a/dhcp/dhcp-impl/src/test/resources/relay/ipv6DhcpRelayBefore.json b/dhcp/dhcp-impl/src/test/resources/relay/ipv6DhcpRelayBefore.json
new file mode 100644
index 000000000..94f7c6558
--- /dev/null
+++ b/dhcp/dhcp-impl/src/test/resources/relay/ipv6DhcpRelayBefore.json
@@ -0,0 +1,21 @@
+{
+ "relays": {
+ "relay": [
+ {
+ "address-type": "ipv6",
+ "rx-vrf-id": 1,
+ "gateway-address": "2001::2",
+ "server" : [
+ {
+ "vrf-id": 2,
+ "address": "2001::1"
+ },
+ {
+ "vrf-id": 2,
+ "address": "2001::10"
+ }
+ ]
+ }
+ ]
+ }
+}