use of org.glassfish.jersey.client.ClientConfig in project open-kilda by telstra.
the class SwitchesUtils method knockoutSwitch.
/**
* Turns off switch.
* @param switchName switch name.
* @return true if result is success.
*/
public static boolean knockoutSwitch(String switchName) {
System.out.println("\n==> Knockout switch");
Client client = ClientBuilder.newClient(new ClientConfig());
Response result = client.target(trafficEndpoint).path("/knockoutswitch").queryParam("switch", switchName).request().post(Entity.json(""));
System.out.println(format("===> Response = %s", result.toString()));
return result.getStatus() == 200;
}
use of org.glassfish.jersey.client.ClientConfig in project open-kilda by telstra.
the class FlowCrudBasicRunTest method checkTraffic.
private int checkTraffic(String sourceSwitch, String destSwitch, int sourceVlan, int destinationVlan, int expectedStatus) {
if (isTrafficTestsEnabled()) {
System.out.print("=====> Send traffic");
long current = System.currentTimeMillis();
Client client = ClientBuilder.newClient(new ClientConfig());
// NOTE: current implementation requires two auxiliary switches in
// topology, one for generating traffic, another for receiving it.
// Originaly smallest meaningful topology was supposed to consist
// of three switches, thus switches 1 and 5 were used as auxiliary.
// Now some scenarios require even smaller topologies and at the same
// time they reuse small linear topology. This leads to shutting off of
// switches 1 and 5 from flows and to test failures. Since topology
// reuse speeds testing up the code below determines which switch:port
// pairs should be used as source and drains for traffic while keepig
// small linear topology in use.
int fromNum = Integer.parseInt(sourceSwitch.substring(sourceSwitch.length() - 1));
int toNum = Integer.parseInt(destSwitch.substring(destSwitch.length() - 1));
String from = "0000000" + (fromNum - 1);
String to = "0000000" + (toNum + 1);
int fromPort = from.equals("00000001") ? 1 : 2;
int toPort = 1;
System.out.println(String.format("from:%s:%d::%d via %s, To:%s:%d::%d via %s", from, fromPort, sourceVlan, sourceSwitch, to, toPort, destinationVlan, destSwitch));
Response result = client.target(trafficEndpoint).path("/checkflowtraffic").queryParam("srcswitch", from).queryParam("dstswitch", to).queryParam("srcport", fromPort).queryParam("dstport", toPort).queryParam("srcvlan", sourceVlan).queryParam("dstvlan", destinationVlan).request().get();
System.out.println(String.format("======> Response = %s", result.toString()));
System.out.println(String.format("======> Send traffic Time: %,.3f", getTimeDuration(current)));
return result.getStatus();
} else {
return expectedStatus;
}
}
use of org.glassfish.jersey.client.ClientConfig in project open-kilda by telstra.
the class FlowFFRTest method trafficIsOk.
private boolean trafficIsOk(boolean expectedResult) throws Throwable {
if (isTrafficTestsEnabled()) {
System.out.println("=====> Send traffic");
long current = System.currentTimeMillis();
Client client = ClientBuilder.newClient(new ClientConfig());
Response result = client.target(trafficEndpoint).path("/checkflowtraffic").queryParam("srcswitch", "s1").queryParam("dstswitch", "s8").queryParam("srcport", "1").queryParam("dstport", "1").queryParam("srcvlan", "1000").queryParam("dstvlan", "1000").request().get();
System.out.println(String.format("======> Response = %s", result.toString()));
System.out.println(String.format("======> Send traffic Time: %,.3f", getTimeDuration(current)));
return result.getStatus() == 200;
} else {
return expectedResult;
}
}
use of org.glassfish.jersey.client.ClientConfig in project open-kilda by telstra.
the class FlowFFRTest method portUp.
private boolean portUp(String switchName, String portNo) throws Throwable {
System.out.println("\n==> Set Port Up");
long current = System.currentTimeMillis();
Client client = ClientBuilder.newClient(new ClientConfig());
Response result = client.target(trafficEndpoint).path("/port/up").queryParam("switch", switchName).queryParam("port", portNo).request().post(Entity.json(""));
System.out.println(String.format("===> Response = %s", result.toString()));
System.out.println(String.format("===> Set Port Up Time: %,.3f", getTimeDuration(current)));
return result.getStatus() == 200;
}
use of org.glassfish.jersey.client.ClientConfig in project open-kilda by telstra.
the class StatisticsBasicTest method getNumberOfDatapoints.
private List<Metric> getNumberOfDatapoints() throws Throwable {
System.out.println("\n==> OpenTSDB Metrics request");
long current = System.currentTimeMillis();
Client client = ClientBuilder.newClient(new ClientConfig());
Response response = client.target(opentsdbEndpoint).path("/api/query").queryParam("start", "24h-ago").queryParam("m", "sum:pen.switch.tx-bytes").queryParam("timezone", "Australia/Melbourne").request().get();
System.out.println(String.format("===> Response = %s", response));
System.out.println(String.format("===> OpenTSDB Metrics Time: %,.3f", getTimeDuration(current)));
List<Metric> metrics = new ObjectMapper().readValue(response.readEntity(String.class), new TypeReference<List<Metric>>() {
});
System.out.println(String.format("====> Metrics = %s", metrics));
return metrics;
}
Aggregations