Fixing scale test manager and CLIs.

Change-Id: I3d4120e68076cce0df33476dc15ee3cfcf4dfbc8
This commit is contained in:
Thomas Vachuska 2018-03-21 12:22:04 -07:00
parent 32b42208e0
commit 6205f69aba
3 changed files with 10 additions and 7 deletions

View File

@ -34,7 +34,7 @@ public class CreateFlows extends AbstractShellCommand {
@Override
protected void execute() {
ComponentConfigService service = get(ComponentConfigService.class);
service.setProperty("org.onosproject.routescale.ScaleManager",
service.setProperty("org.onosproject.routescale.ScaleTestManager",
"flowCount", String.valueOf(flowCount));
}

View File

@ -34,7 +34,7 @@ public class CreateRoutes extends AbstractShellCommand {
@Override
protected void execute() {
ComponentConfigService service = get(ComponentConfigService.class);
service.setProperty("org.onosproject.routescale.ScaleManager",
service.setProperty("org.onosproject.routescale.ScaleTestManager",
"routeCount", String.valueOf(routeCount));
}

View File

@ -103,6 +103,8 @@ public class ScaleTestManager {
private ApplicationId appId;
private long macBase = System.currentTimeMillis();
@Activate
protected void activate() {
appId = applicationService.getId("org.onosproject.routescale");
@ -172,11 +174,12 @@ public class ScaleTestManager {
FlowRuleOperations.Builder ops = FlowRuleOperations.builder();
for (int i = 0; i < c; i++) {
FlowRule.Builder frb = DefaultFlowRule.builder();
frb.fromApp(appId).makePermanent().withPriority(1000 + i);
frb.fromApp(appId).makePermanent().withPriority((currentFlowCount + i) % FlowRule.MAX_PRIORITY);
TrafficSelector.Builder tsb = DefaultTrafficSelector.builder();
TrafficTreatment.Builder ttb = DefaultTrafficTreatment.builder();
tsb.matchEthType(Ethernet.TYPE_IPV4);
tsb.matchEthDst(randomMac());
ttb.setEthDst(randomMac()).setEthSrc(randomMac());
ttb.setOutput(randomPort(ports));
frb.withSelector(tsb.build()).withTreatment(ttb.build());
@ -188,12 +191,14 @@ public class ScaleTestManager {
private void removeExcessFlows(int flowsPerDevice, DeviceId id,
int currentFlowCount) {
FlowRuleOperations.Builder ops = FlowRuleOperations.builder();
int c = flowsPerDevice - currentFlowCount;
int c = currentFlowCount - flowsPerDevice;
log.info("Removing {} flows from device {}", c, id);
for (FlowEntry e : flowRuleService.getFlowEntries(id)) {
if (Objects.equals(e.appId(), appId.id()) && c > 0) {
ops.remove(e);
c--;
} else if (c == 0) {
break;
}
}
flowRuleService.apply(ops.build());
@ -252,9 +257,7 @@ public class ScaleTestManager {
// Generates a random MAC address.
private MacAddress randomMac() {
byte[] bytes = new byte[6];
random.nextBytes(bytes);
return MacAddress.valueOf(bytes);
return MacAddress.valueOf(macBase++);
}
// Returns IP address of a host randomly chosen from the specified list.