public static WorkItem getWorkItemParse(String containerName, String testrigName) { WorkItem wItem = new WorkItem(containerName, testrigName); wItem.addRequestParam(BfConsts.COMMAND_PARSE_VENDOR_INDEPENDENT, ""); wItem.addRequestParam(BfConsts.COMMAND_PARSE_VENDOR_SPECIFIC, ""); wItem.addRequestParam(BfConsts.COMMAND_INIT_INFO, ""); wItem.addRequestParam(BfConsts.ARG_IGNORE_MANAGEMENT_INTERFACES, ""); return wItem; }
public static WorkItem getWorkItemGenerateDeltaDataPlane( String containerName, String testrigName, String deltaTestrigName) { WorkItem wItem = new WorkItem(containerName, testrigName); wItem.addRequestParam(BfConsts.COMMAND_DUMP_DP, ""); wItem.addRequestParam(BfConsts.ARG_DELTA_TESTRIG, deltaTestrigName); wItem.addRequestParam(BfConsts.ARG_DIFF_ACTIVE, ""); return wItem; }
public static WorkItem getWorkItemRunAnalysis( String analysisName, String containerName, String testrigName, String deltaTestrig, boolean delta, boolean differential) { WorkItem wItem = new WorkItem(containerName, testrigName); wItem.addRequestParam(BfConsts.COMMAND_ANALYZE, ""); wItem.addRequestParam(BfConsts.ARG_ANALYSIS_NAME, analysisName); wItem.addRequestParam(BfConsts.ARG_TESTRIG, testrigName); if (differential || delta) { wItem.addRequestParam(BfConsts.ARG_DELTA_TESTRIG, deltaTestrig); } if (delta) { wItem.addRequestParam(BfConsts.ARG_DIFF_ACTIVE, ""); } if (differential) { wItem.addRequestParam(BfConsts.ARG_DIFFERENTIAL, ""); } return wItem; }
public static WorkItem getWorkItemAnswerQuestion( String questionName, String containerName, String testrigName, String deltaTestrig, String analysisName, boolean isDifferential, boolean isDelta) { WorkItem wItem = new WorkItem(containerName, testrigName); wItem.addRequestParam(BfConsts.COMMAND_ANSWER, ""); wItem.addRequestParam(BfConsts.ARG_QUESTION_NAME, questionName); if (isDifferential) { wItem.addRequestParam(BfConsts.ARG_DIFFERENTIAL, ""); } if (deltaTestrig != null) { wItem.addRequestParam(BfConsts.ARG_DELTA_TESTRIG, deltaTestrig); } if (isDelta) { wItem.addRequestParam(BfConsts.ARG_DIFF_ACTIVE, ""); } if (analysisName != null) { wItem.addRequestParam(BfConsts.ARG_ANALYSIS_NAME, analysisName); } return wItem; }
public static WorkItem getWorkItemGenerateDataPlane(String containerName, String testrigName) { WorkItem wItem = new WorkItem(containerName, testrigName); wItem.addRequestParam(BfConsts.COMMAND_DUMP_DP, ""); return wItem; }
private boolean execute(WorkItem wItem, @Nullable FileWriter outWriter) { _logger.infof("work-id is %s\n", wItem.getId()); ActiveSpan activeSpan = GlobalTracer.get().activeSpan(); if (activeSpan != null) { activeSpan.setTag("work-id", wItem.getId().toString()); } wItem.addRequestParam(BfConsts.ARG_LOG_LEVEL, _settings.getBatfishLogLevel()); for (String option : _additionalBatfishOptions.keySet()) { wItem.addRequestParam(option, _additionalBatfishOptions.get(option)); } boolean queueWorkResult = _workHelper.queueWork(wItem); _logger.infof("Queuing result: %s\n", queueWorkResult); if (!queueWorkResult) { return queueWorkResult; } boolean result = true; if (!_backgroundExecution) { _polledWorkItem = wItem; result = pollWorkAndGetAnswer(wItem, outWriter); _polledWorkItem = null; } return result; }
@Test public void getMatchingWorkPresent() throws Exception { initSnapshotMetadata("testrig", ProcessingStatus.UNINITIALIZED); WorkItem wItem1 = new WorkItem(NETWORK, "testrig"); wItem1.addRequestParam("key1", "value1"); QueuedWork work1 = resolvedQueuedWork(wItem1, new WorkDetails("testrig", WorkType.UNKNOWN)); QueuedWork work2 = resolvedQueuedWork( new WorkItem(NETWORK, "testrig"), new WorkDetails("testrig", WorkType.UNKNOWN)); _workQueueMgr.queueUnassignedWork(work1); _workQueueMgr.queueUnassignedWork(work2); // build a work item that should match wItem1 WorkItem wItem3 = WorkMgr.resolveIds(new WorkItem(NETWORK, "testrig")); wItem3.addRequestParam("key1", "value1"); QueuedWork matchingWork = _workQueueMgr.getMatchingWork(wItem3, QueueType.INCOMPLETE); assertThat(matchingWork, equalTo(work1)); }
@Test public void getMatchingWorkAbsent() throws Exception { initSnapshotMetadata("testrig", ProcessingStatus.UNINITIALIZED); WorkItem wItem = new WorkItem(NETWORK, "testrig"); wItem.addRequestParam("key", "value"); // get matching work should be null on an empty queue QueuedWork matchingWork = _workQueueMgr.getMatchingWork(wItem, QueueType.INCOMPLETE); assertThat(matchingWork, equalTo(null)); // build two work items that do not match WorkItem wItem1 = new WorkItem(NETWORK, "testrig"); wItem1.addRequestParam("key1", "value1"); QueuedWork work1 = resolvedQueuedWork(wItem1, new WorkDetails("testrig", WorkType.UNKNOWN)); QueuedWork work2 = resolvedQueuedWork( new WorkItem(NETWORK, "testrig"), new WorkDetails("testrig", WorkType.UNKNOWN)); _workQueueMgr.queueUnassignedWork(work1); _workQueueMgr.queueUnassignedWork(work2); // should be null again QueuedWork matchingWorkAgain = _workQueueMgr.getMatchingWork(WorkMgr.resolveIds(wItem), QueueType.INCOMPLETE); assertThat(matchingWorkAgain, equalTo(null)); }