Created
July 10, 2014 13:30
-
-
Save Mierdin/f6e6fdf166ccc4cdf050 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void createManager() throws IOException, InterruptedException, ExecutionException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { | |
//proceed only if schema was already retrieved successfully | |
Assert.assertNotNull(dbSchema); | |
//create new manager and set target string | |
Manager mgr = ovs.createTypedRowWrapper(Manager.class); | |
mgr.setTarget("ptcp:6641"); | |
String transactionUuidStr = "foobar"; | |
int insertOperationIndex = 0; | |
Global glbl = this.ovs.createTypedRowWrapper(Global.class); | |
glbl.setManagers(Sets.newHashSet(new UUID(transactionUuidStr))); | |
TransactionBuilder transactionBuilder = ovs.transactBuilder(dbSchema) | |
.add(op.insert(mgr.getSchema()) | |
.withId(transactionUuidStr) | |
.value(mgr.getTargetColumn())) | |
.add(op.mutate(glbl.getSchema()) | |
.addMutation(glbl.getManagersColumn().getSchema(), Mutator.INSERT, | |
glbl.getManagersColumn().getData())); | |
ListenableFuture<List<OperationResult>> results = transactionBuilder.execute(); | |
List<OperationResult> operationResults = results.get(); | |
//ensure we received the results of the operation | |
Assert.assertFalse(operationResults.isEmpty()); | |
// Check if Results matches the number of operations in transaction | |
Assert.assertEquals(transactionBuilder.getOperations().size(), operationResults.size()); | |
logger.info("Insert & Mutate operation results for new manager = " + operationResults); | |
// Check for any errors | |
for (OperationResult result : operationResults) { | |
Assert.assertNull(result.getError()); | |
} | |
HardwareVtepSchemaSuiteIT.setTestManagerUuid(operationResults.get(insertOperationIndex).getUuid()); | |
Thread.sleep(3000); // Wait for cache to catchup | |
Row managerRow = HardwareVtepSchemaSuiteIT.getTableCache().get(mgr.getSchema()).get(HardwareVtepSchemaSuiteIT.getTestManagerUuid()); | |
Manager monitoredManager = ovs.getTypedRowWrapper(Manager.class, managerRow); | |
Assert.assertEquals(monitoredManager.getTargetColumn().getData(), mgr.getTargetColumn().getData()); | |
Assert.assertNotNull(monitoredManager.getUuid()); | |
Assert.assertNotNull(monitoredManager.getVersion()); | |
Assert.assertNotNull(this.getGlobalTableUuid(ovs, HardwareVtepSchemaSuiteIT.getTableCache())); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment