From 6f99d701f347a88f56790c08e0ab402e7af226cd Mon Sep 17 00:00:00 2001 From: Mike Hansen Date: Fri, 4 Sep 2020 15:17:33 -0400 Subject: [PATCH] WIFI-442: APNOS Synthetic client RADIUS probes Support changes to the Network Probe reporting from the MQTT messages proto files. Add/update JUnit tests in concert with above. --- ...ternalIntegrationMqttMessageProcessor.java | 72 +++++++++---------- ...alIntegrationMqttMessageProcessorTest.java | 12 ++-- 2 files changed, 39 insertions(+), 45 deletions(-) diff --git a/opensync-ext-cloud/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationMqttMessageProcessor.java b/opensync-ext-cloud/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationMqttMessageProcessor.java index 4466d7e..c02360a 100644 --- a/opensync-ext-cloud/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationMqttMessageProcessor.java +++ b/opensync-ext-cloud/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationMqttMessageProcessor.java @@ -1165,30 +1165,30 @@ public class OpensyncExternalIntegrationMqttMessageProcessor { DNSProbeMetric dnsProbeMetricFromAp = networkProbe.getDnsProbe(); - DnsProbeMetric dnsProbeMetric = new DnsProbeMetric(); + DnsProbeMetric cloudDnsProbeMetric = new DnsProbeMetric(); if (dnsProbeMetricFromAp.hasLatency()) { networkProbeMetrics.setDnsLatencyMs(dnsProbeMetricFromAp.getLatency()); - dnsProbeMetric.setDnsLatencyMs(dnsProbeMetricFromAp.getLatency()); + cloudDnsProbeMetric.setDnsLatencyMs(dnsProbeMetricFromAp.getLatency()); } if (dnsProbeMetricFromAp.hasState()) { switch (dnsProbeMetricFromAp.getState()) { case SUD_down: networkProbeMetrics.setDnsState(StateUpDownError.disabled); - dnsProbeMetric.setDnsState(StateUpDownError.disabled); + cloudDnsProbeMetric.setDnsState(StateUpDownError.disabled); break; case SUD_up: networkProbeMetrics.setDnsState(StateUpDownError.enabled); - dnsProbeMetric.setDnsState(StateUpDownError.enabled); + cloudDnsProbeMetric.setDnsState(StateUpDownError.enabled); break; case SUD_error: networkProbeMetrics.setDnsState(StateUpDownError.error); - dnsProbeMetric.setDnsState(StateUpDownError.error); + cloudDnsProbeMetric.setDnsState(StateUpDownError.error); break; default: networkProbeMetrics.setDnsState(StateUpDownError.UNSUPPORTED); - dnsProbeMetric.setDnsState(StateUpDownError.UNSUPPORTED); + cloudDnsProbeMetric.setDnsState(StateUpDownError.UNSUPPORTED); } } @@ -1196,56 +1196,48 @@ public class OpensyncExternalIntegrationMqttMessageProcessor { InetAddress ipAddress; try { ipAddress = InetAddress.getByName(dnsProbeMetricFromAp.getServerIP()); - dnsProbeMetric.setDnsServerIp(ipAddress); - + cloudDnsProbeMetric.setDnsServerIp(ipAddress); } catch (UnknownHostException e) { LOG.error("Could not get DNS Server IP from network_probe metrics", e); } } - dnsProbeResults.add(dnsProbeMetric); + dnsProbeResults.add(cloudDnsProbeMetric); } networkProbeMetrics.setDnsProbeResults(dnsProbeResults); for (RADIUSMetrics radiusMetrics : networkProbe.getRadiusProbeList()) { - if (networkProbe.hasVlanProbe()) { - if (networkProbe.getVlanProbe().hasObsV200RadiusLatency()) { - networkProbeMetrics.setRadiusLatencyInMs(networkProbe.getVlanProbe().getObsV200RadiusLatency()); - } - if (networkProbe.getVlanProbe().hasObsV200RadiusState()) { - switch (networkProbe.getVlanProbe().getObsV200RadiusState()) { - case SUD_down: - networkProbeMetrics.setRadiusState(StateUpDownError.disabled); - break; - case SUD_up: - networkProbeMetrics.setRadiusState(StateUpDownError.enabled); - break; - case SUD_error: - networkProbeMetrics.setRadiusState(StateUpDownError.error); - break; - default: - networkProbeMetrics.setRadiusState(StateUpDownError.UNSUPPORTED); - } - } - } else { - // take the average if we don't have from the VLAN Probe - if (radiusMetrics.hasLatencyAve()) { - networkProbeMetrics.setRadiusLatencyInMs(radiusMetrics.getLatencyAve()); + if (radiusMetrics.hasLatency()) { + networkProbeMetrics.setRadiusLatencyInMs(radiusMetrics.getLatency()); + } + if (radiusMetrics.hasRadiusState()) { + + switch (radiusMetrics.getRadiusState()) { + case SUD_down: + networkProbeMetrics.setRadiusState(StateUpDownError.disabled); + break; + case SUD_up: + networkProbeMetrics.setRadiusState(StateUpDownError.enabled); + break; + case SUD_error: + networkProbeMetrics.setRadiusState(StateUpDownError.error); + break; + default: + networkProbeMetrics.setRadiusState(StateUpDownError.UNSUPPORTED); } + } } + if (networkProbe.hasVlanProbe()) { VLANMetrics vlanMetrics = networkProbe.getVlanProbe(); - if (vlanMetrics.hasVlanIF()) { networkProbeMetrics.setVlanIF(vlanMetrics.getVlanIF()); - } - if (vlanMetrics.hasDhcpLatency()) { - networkProbeMetrics.setDhcpLatencyMs(vlanMetrics.getDhcpLatency()); - } + } if (vlanMetrics.hasDhcpState()) { + switch (vlanMetrics.getDhcpState()) { case SUD_down: networkProbeMetrics.setDhcpState(StateUpDownError.disabled); @@ -1258,9 +1250,11 @@ public class OpensyncExternalIntegrationMqttMessageProcessor { break; default: networkProbeMetrics.setDhcpState(StateUpDownError.UNSUPPORTED); - } + } + } + if (vlanMetrics.hasLatency()) { + networkProbeMetrics.setDhcpLatencyMs(vlanMetrics.getLatency()); } - } networkProbeMetricsList.add(networkProbeMetrics); diff --git a/opensync-ext-cloud/src/test/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationMqttMessageProcessorTest.java b/opensync-ext-cloud/src/test/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationMqttMessageProcessorTest.java index e5bcbe3..f62292b 100644 --- a/opensync-ext-cloud/src/test/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationMqttMessageProcessorTest.java +++ b/opensync-ext-cloud/src/test/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationMqttMessageProcessorTest.java @@ -246,10 +246,10 @@ public class OpensyncExternalIntegrationMqttMessageProcessorTest { DNSProbeMetric dnsProbeMetric = DNSProbeMetric.getDefaultInstance().toBuilder().setLatency(10) .setState(StateUpDown.SUD_up).setServerIP(ip.getHostName()).build(); - RADIUSMetrics radiusProbeMetric = RADIUSMetrics.getDefaultInstance().toBuilder().setLatencyAve(10).build(); - VLANMetrics vlanMetrics = VLANMetrics.getDefaultInstance().toBuilder().setDhcpLatency(10) - .setDhcpState(StateUpDown.SUD_up).setVlanIF("vlan-1").setObsV200RadiusLatency(15) - .setObsV200RadiusState(StateUpDown.SUD_up).build(); + RADIUSMetrics radiusProbeMetric = RADIUSMetrics.getDefaultInstance().toBuilder().setLatency(10) + .setRadiusState(StateUpDown.SUD_up).setServerIP(ip.getHostName()).build(); + VLANMetrics vlanMetrics = VLANMetrics.getDefaultInstance().toBuilder().setLatency(10) + .setDhcpState(StateUpDown.SUD_up).setVlanIF("vlan-1").build(); NetworkProbe networkProbe = NetworkProbe.getDefaultInstance().toBuilder().setVlanProbe(vlanMetrics) .setDnsProbe(dnsProbeMetric).addRadiusProbe(radiusProbeMetric).build(); @@ -262,12 +262,12 @@ public class OpensyncExternalIntegrationMqttMessageProcessorTest { assertNotNull(apNodeMetrics.getNetworkProbeMetrics()); - assert (apNodeMetrics.getNetworkProbeMetrics().get(0).getDhcpLatencyMs() == 10); assert (apNodeMetrics.getNetworkProbeMetrics().get(0).getDnsLatencyMs() == 10); + assert (apNodeMetrics.getNetworkProbeMetrics().get(0).getDhcpLatencyMs() == 10); assert (apNodeMetrics.getNetworkProbeMetrics().get(0).getRadiusState().equals(StateUpDownError.enabled)); assert (apNodeMetrics.getNetworkProbeMetrics().get(0).getDhcpState().equals(StateUpDownError.enabled)); assert (apNodeMetrics.getNetworkProbeMetrics().get(0).getDnsState().equals(StateUpDownError.enabled)); - assert (apNodeMetrics.getNetworkProbeMetrics().get(0).getRadiusLatencyInMs() == 15); + assert (apNodeMetrics.getNetworkProbeMetrics().get(0).getRadiusLatencyInMs() == 10); assert (apNodeMetrics.getNetworkProbeMetrics().get(0).getVlanIF().equals("vlan-1")); }