Merge "Added Security Rule for Custom ICMP"
[ovsdb.git] / library / it / src / test / java / org / opendaylight / ovsdb / integrationtest / schema / openvswitch / OpenVSwitchIT.java
1 /*
2  *  Copyright (C) 2014 Red Hat, Inc.
3  *
4  *  This program and the accompanying materials are made available under the
5  *  terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  *  and is available at http://www.eclipse.org/legal/epl-v10.html
7  *
8  *  Authors : Sam Hague, Matt Oswalt
9  */
10 package org.opendaylight.ovsdb.integrationtest.schema.openvswitch;
11
12 import static org.junit.Assert.assertEquals;
13 import static org.junit.Assert.assertFalse;
14 import static org.junit.Assert.assertNotNull;
15 import static org.junit.Assert.assertNotSame;
16 import static org.junit.Assert.assertNull;
17 import static org.junit.Assert.assertSame;
18 import static org.junit.Assert.assertTrue;
19 import static org.junit.Assert.fail;
20 import static org.junit.Assume.assumeTrue;
21 import static org.opendaylight.ovsdb.lib.operations.Operations.op;
22
23 import com.google.common.collect.ImmutableMap;
24 import com.google.common.collect.ImmutableSet;
25 import com.google.common.collect.Lists;
26 import com.google.common.collect.Maps;
27 import com.google.common.collect.Sets;
28 import com.google.common.util.concurrent.ListenableFuture;
29 import java.io.IOException;
30 import java.util.HashMap;
31 import java.util.List;
32 import java.util.Map;
33 import java.util.Set;
34 import java.util.concurrent.ExecutionException;
35 import javax.inject.Inject;
36 import org.junit.Before;
37 import org.junit.Test;
38 import org.junit.runner.RunWith;
39 import org.opendaylight.ovsdb.lib.MonitorCallBack;
40 import org.opendaylight.ovsdb.lib.OvsdbClient;
41 import org.opendaylight.ovsdb.lib.error.SchemaVersionMismatchException;
42 import org.opendaylight.ovsdb.lib.it.LibraryIntegrationTestBase;
43 import org.opendaylight.ovsdb.lib.it.LibraryIntegrationTestUtils;
44 import org.opendaylight.ovsdb.lib.message.MonitorRequest;
45 import org.opendaylight.ovsdb.lib.message.MonitorRequestBuilder;
46 import org.opendaylight.ovsdb.lib.message.MonitorSelect;
47 import org.opendaylight.ovsdb.lib.message.TableUpdate;
48 import org.opendaylight.ovsdb.lib.message.TableUpdates;
49 import org.opendaylight.ovsdb.lib.notation.Mutator;
50 import org.opendaylight.ovsdb.lib.notation.Row;
51 import org.opendaylight.ovsdb.lib.notation.UUID;
52 import org.opendaylight.ovsdb.lib.notation.Version;
53 import org.opendaylight.ovsdb.lib.operations.OperationResult;
54 import org.opendaylight.ovsdb.lib.operations.TransactionBuilder;
55 import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
56 import org.opendaylight.ovsdb.lib.schema.GenericTableSchema;
57 import org.opendaylight.ovsdb.lib.schema.TableSchema;
58 import org.opendaylight.ovsdb.lib.schema.typed.TypedBaseTable;
59 import org.opendaylight.ovsdb.schema.openvswitch.Bridge;
60 import org.opendaylight.ovsdb.schema.openvswitch.Controller;
61 import org.opendaylight.ovsdb.schema.openvswitch.FlowSampleCollectorSet;
62 import org.opendaylight.ovsdb.schema.openvswitch.FlowTable;
63 import org.opendaylight.ovsdb.schema.openvswitch.Interface;
64 import org.opendaylight.ovsdb.schema.openvswitch.IPFIX;
65 import org.opendaylight.ovsdb.schema.openvswitch.Manager;
66 import org.opendaylight.ovsdb.schema.openvswitch.Mirror;
67 import org.opendaylight.ovsdb.schema.openvswitch.NetFlow;
68 import org.opendaylight.ovsdb.schema.openvswitch.OpenVSwitch;
69 import org.opendaylight.ovsdb.schema.openvswitch.Port;
70 import org.opendaylight.ovsdb.schema.openvswitch.Qos;
71 import org.opendaylight.ovsdb.schema.openvswitch.Queue;
72 import org.opendaylight.ovsdb.schema.openvswitch.SFlow;
73 import org.opendaylight.ovsdb.schema.openvswitch.SSL;
74 import org.ops4j.pax.exam.junit.PaxExam;
75 import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
76 import org.ops4j.pax.exam.spi.reactors.PerSuite;
77 import org.osgi.framework.Bundle;
78 import org.osgi.framework.BundleContext;
79 import org.slf4j.Logger;
80 import org.slf4j.LoggerFactory;
81
82 @RunWith(PaxExam.class)
83 @ExamReactorStrategy(PerSuite.class)
84 public class OpenVSwitchIT extends LibraryIntegrationTestBase {
85     private static final Logger LOG = LoggerFactory.getLogger(OpenVSwitchIT.class);
86     private static boolean monitorReady = false;
87     private static boolean schemaSupported = false;
88     private static final String TEST_BRIDGE_NAME = "br_test";
89     private static final String TEST_MANAGER_UUID_STR = "managerUuidName";
90     private static final String ASSERT_TRANS_ERROR = "Transaction should not have errors";
91     private static final String ASSERT_TRANS_RESULT_EMPTY = "Transaction should not be empty";
92     private static final String ASSERT_TRANS_OPERATION_COUNT = "Transaction should match number of operations";
93     private static final String ASSERT_TRANS_UUID = "Transaction UUID should not be null";
94     private Version schemaVersion;
95     private UUID testBridgeUuid = null;
96     private UUID testController1Uuid = null;
97     private UUID testController2Uuid = null;
98     private UUID testFlowSampleCollectorSetUuid = null;
99     private UUID testFlowTableUuid = null;
100     private UUID testInterfaceUuid = null;
101     private UUID testIpfixUuid = null;
102     private UUID testManagerUuid = null;
103     private UUID testMirrorUuid = null;
104     private UUID testNetFlowUuid = null;
105     private UUID testPortUuid = null;
106     private UUID testQosUuid = null;
107     private UUID testQueueUuid = null;
108     private UUID testSFlowUuid = null;
109     private UUID testSslUuid = null;
110     private Version flowSampleCollectorSetFromVersion = Version.fromString("7.1.0");
111     private Version flowTableFromVersion = Version.fromString("6.5.0");
112     private Version prefixesAddedVersion = Version.fromString("7.4.0");
113     private Version externalIdAddedVerson = Version.fromString("7.5.0");
114     private Version ipfixFromVersion = Version.fromString("7.1.0");
115     private Version ipfixCacheFromVersion = Version.fromString("7.3.0");
116
117     private static Map<String, Map<UUID, Row>> tableCache = new HashMap<>();
118     private static Map<String, Map<UUID, Row>> getTableCache () {
119         return tableCache;
120     }
121
122     private static OvsdbClient ovsdbClient;
123     private OvsdbClient getClient () {
124         return ovsdbClient;
125     }
126
127     private static DatabaseSchema dbSchema;
128     private DatabaseSchema getDbSchema () {
129         return dbSchema;
130     }
131
132     @Inject
133     private BundleContext bc;
134
135     @Before
136     public void areWeReady() throws InterruptedException, IOException, ExecutionException {
137         assertNotNull(bc);
138         boolean debugit = false;
139         Bundle b[] = bc.getBundles();
140         for (Bundle element : b) {
141             int state = element.getState();
142             if (state != Bundle.ACTIVE && state != Bundle.RESOLVED) {
143                 LOG.info("Bundle: {} state: {}", element.getSymbolicName(),
144                         LibraryIntegrationTestUtils.bundleStateToString(state));
145                 debugit = true;
146             }
147         }
148         if (debugit) {
149             LOG.debug("Do some debugging because some bundle is unresolved");
150             Thread.sleep(600000);
151         }
152
153         // Assert if true, if false we are good to go!
154         assertFalse(debugit);
155
156         assertTrue(LibraryIntegrationTestUtils.OPEN_VSWITCH_SCHEMA + " is required.", checkSchema(LibraryIntegrationTestUtils.OPEN_VSWITCH_SCHEMA));
157         assertTrue("Failed to monitor tables", monitorTables());
158         schemaVersion = getClient().getDatabaseSchema(LibraryIntegrationTestUtils.OPEN_VSWITCH_SCHEMA).getVersion();
159         LOG.info("{} schema version = {}", LibraryIntegrationTestUtils.OPEN_VSWITCH_SCHEMA, schemaVersion);
160     }
161
162     public boolean checkSchema (String schema) {
163         if (schemaSupported) {
164             LOG.info("Schema ({}) is supported", schema);
165             return true;
166         }
167         try {
168             ovsdbClient = LibraryIntegrationTestUtils.getTestConnection(this);
169             assertNotNull("Invalid Client. Check connection params", ovsdbClient);
170             //Thread.sleep(3000); // Wait for a few seconds to get the Schema exchange done
171             if (isSchemaSupported(ovsdbClient, schema)) {
172                 dbSchema = ovsdbClient.getSchema(schema).get();
173                 assertNotNull(dbSchema);
174                 LOG.info("{} schema in {} with tables: {}",
175                         schema, ovsdbClient.getConnectionInfo(), dbSchema.getTables());
176                 schemaSupported = true;
177                 return true;
178             }
179         } catch (Exception e) {
180             fail("Exception : "+e.getMessage());
181         }
182
183         LOG.info("Schema ({}) is not supported", schema);
184         return false;
185     }
186
187     public UUID getOpenVSwitchTableUuid (OvsdbClient ovs, Map<String, Map<UUID, Row>> tableCache) {
188         OpenVSwitch openVSwitch = getClient().getTypedRowWrapper(OpenVSwitch.class, null);
189         Map<UUID, Row> ovsTable = tableCache.get(openVSwitch.getSchema().getName());
190         if (ovsTable != null) {
191             if (ovsTable.keySet().size() >= 1) {
192                 return (UUID)ovsTable.keySet().toArray()[0];
193             }
194         }
195         return null;
196     }
197
198     public boolean isSchemaSupported (OvsdbClient client, String schema) throws ExecutionException, InterruptedException {
199         ListenableFuture<List<String>> databases = client.getDatabases();
200         List<String> dbNames = databases.get();
201         assertNotNull(dbNames);
202         return dbNames.contains(schema);
203     }
204
205     /**
206      * As per RFC 7047, section 4.1.5, if a Monitor request is sent without any columns, the update response will not include
207      * the _uuid column.
208      * ----------------------------------------------------------------------------------------------------------------------------------
209      * Each <monitor-request> specifies one or more columns and the manner in which the columns (or the entire table) are to be monitored.
210      * The "columns" member specifies the columns whose values are monitored. It MUST NOT contain duplicates.
211      * If "columns" is omitted, all columns in the table, except for "_uuid", are monitored.
212      * ----------------------------------------------------------------------------------------------------------------------------------
213      * In order to overcome this limitation, this method
214      *
215      * @return MonitorRequest that includes all the Bridge Columns including _uuid
216      */
217     public <T extends TypedBaseTable<GenericTableSchema>> MonitorRequest<GenericTableSchema> getAllColumnsMonitorRequest (Class <T> klazz) {
218         TypedBaseTable<GenericTableSchema> table = getClient().createTypedRowWrapper(klazz);
219         GenericTableSchema tableSchema = table.getSchema();
220         Set<String> columns = tableSchema.getColumns();
221         MonitorRequestBuilder<GenericTableSchema> bridgeBuilder = MonitorRequestBuilder.builder(table.getSchema());
222         for (String column : columns) {
223             bridgeBuilder.addColumn(column);
224         }
225         return bridgeBuilder.with(new MonitorSelect(true, true, true, true)).build();
226     }
227
228     public <T extends TableSchema<T>> MonitorRequest<T> getAllColumnsMonitorRequest (T tableSchema) {
229         Set<String> columns = tableSchema.getColumns();
230         MonitorRequestBuilder<T> monitorBuilder = MonitorRequestBuilder.builder(tableSchema);
231         for (String column : columns) {
232             monitorBuilder.addColumn(column);
233         }
234         return monitorBuilder.with(new MonitorSelect(true, true, true, true)).build();
235     }
236
237     public boolean monitorTables () throws ExecutionException, InterruptedException, IOException {
238         if (monitorReady) {
239             LOG.info("Monitoring is already initialized.");
240             return monitorReady;
241         }
242
243         assertNotNull(getDbSchema());
244
245         List<MonitorRequest<GenericTableSchema>> monitorRequests = Lists.newArrayList();
246         Set<String> tables = getDbSchema().getTables();
247         assertNotNull("ovsdb tables should not be null", tables);
248
249         for (String tableName : tables) {
250             GenericTableSchema tableSchema = getDbSchema().table(tableName, GenericTableSchema.class);
251             monitorRequests.add(this.getAllColumnsMonitorRequest(tableSchema));
252         }
253         TableUpdates updates = getClient().monitor(getDbSchema(), monitorRequests, new UpdateMonitor());
254         assertNotNull(updates);
255         this.updateTableCache(updates);
256
257         monitorReady = true;
258         LOG.info("Monitoring is initialized.");
259         return monitorReady;
260     }
261
262     private void updateTableCache (TableUpdates updates) {
263         for (String tableName : updates.getUpdates().keySet()) {
264             Map<UUID, Row> tUpdate = getTableCache().get(tableName);
265             TableUpdate update = updates.getUpdates().get(tableName);
266             for (UUID uuid : (Set<UUID>)update.getRows().keySet()) {
267                 if (update.getNew(uuid) != null) {
268                     if (tUpdate == null) {
269                         tUpdate = new HashMap<>();
270                         getTableCache().put(tableName, tUpdate);
271                     }
272                     tUpdate.put(uuid, update.getNew(uuid));
273                 } else {
274                     tUpdate.remove(uuid);
275                 }
276             }
277         }
278     }
279
280     private class UpdateMonitor implements MonitorCallBack {
281         @Override
282         public void update(TableUpdates result, DatabaseSchema dbSchema) {
283             updateTableCache(result);
284         }
285
286         @Override
287         public void exception(Throwable t) {
288             LOG.error("Exception t = " + t);
289         }
290     }
291
292     public List<OperationResult> executeTransaction (TransactionBuilder transactionBuilder, String text)
293             throws ExecutionException, InterruptedException {
294         ListenableFuture<List<OperationResult>> results = transactionBuilder.execute();
295         List<OperationResult> operationResults = results.get();
296         LOG.info("{}: {}", text, operationResults);
297         org.junit.Assert.assertFalse(ASSERT_TRANS_RESULT_EMPTY, operationResults.isEmpty());
298         assertEquals(ASSERT_TRANS_OPERATION_COUNT, transactionBuilder.getOperations().size(), operationResults.size());
299         for (OperationResult result : operationResults) {
300             assertNull(ASSERT_TRANS_ERROR, result.getError());
301         }
302         //Thread.sleep(500); // Wait for a few seconds to ensure the cache updates
303         return operationResults;
304     }
305
306     public UUID bridgeInsert () throws ExecutionException, InterruptedException {
307         Bridge bridge = getClient().createTypedRowWrapper(Bridge.class);
308         bridge.setName(TEST_BRIDGE_NAME);
309         bridge.setStatus(ImmutableMap.of("key", "value"));
310         bridge.setFloodVlans(Sets.newHashSet(34L));
311
312         OpenVSwitch openVSwitch = getClient().createTypedRowWrapper(OpenVSwitch.class);
313         openVSwitch.setBridges(Sets.newHashSet(new UUID(TEST_BRIDGE_NAME)));
314
315         TransactionBuilder transactionBuilder = getClient().transactBuilder(getDbSchema())
316                 .add(op.insert(bridge.getSchema())
317                         .withId(TEST_BRIDGE_NAME)
318                         .value(bridge.getNameColumn()))
319                 .add(op.comment("Bridge: Inserting " + TEST_BRIDGE_NAME))
320                 .add(op.update(bridge.getSchema())
321                         .set(bridge.getStatusColumn())
322                         .set(bridge.getFloodVlansColumn())
323                         .where(bridge.getNameColumn().getSchema().opEqual(bridge.getName()))
324                         .and(bridge.getNameColumn().getSchema().opEqual(bridge.getName()))
325                         .build())
326                 .add(op.comment("Bridge: Updating " + TEST_BRIDGE_NAME))
327                 .add(op.mutate(openVSwitch.getSchema())
328                         .addMutation(openVSwitch.getBridgesColumn().getSchema(), Mutator.INSERT,
329                                 openVSwitch.getBridgesColumn().getData()))
330                 .add(op.comment("Open_vSwitch: Mutating " + TEST_BRIDGE_NAME));
331
332         List<OperationResult> operationResults = executeTransaction(transactionBuilder,
333                 "Bridge Insert, Update and Mutate operation results");
334         UUID bridgeUuid = operationResults.get(0).getUuid();
335         assertNotNull(ASSERT_TRANS_UUID, bridgeUuid);
336         return bridgeUuid;
337     }
338
339     public void bridgeDelete (UUID bridgeUuid) throws ExecutionException, InterruptedException {
340         Bridge bridge = getClient().getTypedRowWrapper(Bridge.class, null);
341         OpenVSwitch openVSwitch = getClient().getTypedRowWrapper(OpenVSwitch.class, null);
342
343         TransactionBuilder transactionBuilder = getClient().transactBuilder(getDbSchema())
344                 .add(op.delete(bridge.getSchema())
345                         .where(bridge.getNameColumn().getSchema().opEqual(TEST_BRIDGE_NAME))
346                         .build())
347                 .add(op.comment("Bridge: Deleting " + TEST_BRIDGE_NAME))
348                 .add(op.mutate(openVSwitch.getSchema())
349                         .addMutation(openVSwitch.getBridgesColumn().getSchema(), Mutator.DELETE,
350                                 Sets.newHashSet(bridgeUuid)))
351                 .add(op.comment("Open_vSwitch: Mutating " + TEST_BRIDGE_NAME + " " + bridgeUuid))
352                 .add(op.commit(true));
353
354         executeTransaction(transactionBuilder, "Bridge delete operation results");
355     }
356
357     @Test
358     public void testBridge () throws ExecutionException, InterruptedException {
359         testBridgeUuid = bridgeInsert();
360
361         // Verify that the local cache was updated with the remote changes
362         Bridge bridge = getClient().createTypedRowWrapper(Bridge.class);
363         Row bridgeRow = getTableCache().get(bridge.getSchema().getName()).get(testBridgeUuid);
364         Bridge monitoredBridge = getClient().getTypedRowWrapper(Bridge.class, bridgeRow);
365         assertEquals(TEST_BRIDGE_NAME, monitoredBridge.getNameColumn().getData());
366
367         bridgeDelete(testBridgeUuid);
368     }
369
370     private void controllerInsert () throws ExecutionException, InterruptedException {
371         String controllerUuidStr = "controller";
372         Controller controller1 = getClient().createTypedRowWrapper(Controller.class);
373         controller1.setTarget("tcp:1.1.1.1:6640");
374         Controller controller2 = getClient().createTypedRowWrapper(Controller.class);
375         controller2.setTarget("tcp:2.2.2.2:6640");
376         Bridge bridge = getClient().getTypedRowWrapper(Bridge.class, null);
377
378         // Insert row to Controller table with address in target column
379         // Update row in Bridge table with controller uuid in controller column
380         TransactionBuilder transactionBuilder = getClient().transactBuilder(getDbSchema())
381                 .add(op.insert(controller1.getSchema())
382                         .withId(controllerUuidStr)
383                         .value(controller1.getTargetColumn()))
384                 .add(op.comment("Controller: Inserting controller1 " + controller1.getTargetColumn().getData()))
385                 .add(op.mutate(bridge.getSchema())
386                         .addMutation(bridge.getControllerColumn().getSchema(), Mutator.INSERT,
387                                 Sets.newHashSet(new UUID(controllerUuidStr)))
388                         .where(bridge.getNameColumn().getSchema().opEqual(TEST_BRIDGE_NAME))
389                         .build())
390                 .add(op.comment("Bridge: Mutating controller1 " + controller1.getTargetColumn().getData()));
391
392         List<OperationResult> operationResults = executeTransaction(transactionBuilder,
393                 "Controller: Insert & Mutate operation results for controller1");
394         testController1Uuid = operationResults.get(0).getUuid();
395         assertNotNull(ASSERT_TRANS_UUID, testController1Uuid);
396
397         // Verify that the local cache was updated with the remote changes
398         Row controllerRow = getTableCache().get(controller1.getSchema().getName()).get(testController1Uuid);
399         Controller monitoredController = getClient().getTypedRowWrapper(Controller.class, controllerRow);
400         assertEquals(controller1.getTargetColumn().getData(), monitoredController.getTargetColumn().getData());
401
402         Row bridgeRow = getTableCache().get(bridge.getSchema().getName()).get(testBridgeUuid);
403         Bridge monitoredBridge = getClient().getTypedRowWrapper(Bridge.class, bridgeRow);
404         assertEquals(1, monitoredBridge.getControllerColumn().getData().size());
405
406         transactionBuilder = getClient().transactBuilder(getDbSchema())
407                 .add(op.insert(controller2.getSchema())
408                         .withId(controllerUuidStr)
409                         .value(controller2.getTargetColumn()))
410                 .add(op.comment("Controller: Inserting controller2 " + controller2.getTargetColumn().getData()))
411                 .add(op.mutate(bridge.getSchema())
412                         .addMutation(bridge.getControllerColumn().getSchema(), Mutator.INSERT,
413                                 Sets.newHashSet(new UUID(controllerUuidStr)))
414                         .where(bridge.getNameColumn().getSchema().opEqual(TEST_BRIDGE_NAME))
415                         .build())
416                 .add(op.comment("Bridge: Mutating controller2 " + controller2.getTargetColumn().getData()));
417
418         operationResults = executeTransaction(transactionBuilder,
419                 "Controller: Insert & Mutate operation results for controller2");
420         testController2Uuid = operationResults.get(0).getUuid();
421         assertNotNull(ASSERT_TRANS_UUID, testController2Uuid);
422
423         // Verify that the local cache was updated with the remote changes
424         controllerRow = getTableCache().get(controller2.getSchema().getName()).get(testController2Uuid);
425         monitoredController = getClient().getTypedRowWrapper(Controller.class, controllerRow);
426         assertEquals(controller2.getTargetColumn().getData(), monitoredController.getTargetColumn().getData());
427
428         bridgeRow = getTableCache().get(bridge.getSchema().getName()).get(testBridgeUuid);
429         monitoredBridge = getClient().getTypedRowWrapper(Bridge.class, bridgeRow);
430         assertEquals(2, monitoredBridge.getControllerColumn().getData().size());
431     }
432
433     private void controllerDelete () throws ExecutionException, InterruptedException {
434         Controller controller = getClient().getTypedRowWrapper(Controller.class, null);
435         Bridge bridge = getClient().getTypedRowWrapper(Bridge.class, null);
436         DatabaseSchema dbSchema = getClient().getSchema(LibraryIntegrationTestUtils.OPEN_VSWITCH_SCHEMA).get();
437
438         TransactionBuilder transactionBuilder = getClient().transactBuilder(dbSchema)
439                 .add(op.delete(controller.getSchema())
440                         .where(controller.getUuidColumn().getSchema().opEqual(testController1Uuid))
441                         .build())
442                 .add(op.comment("Controller: Deleting " + testController1Uuid))
443                 .add(op.mutate(bridge.getSchema()) // Delete a controller column in the Bridge table
444                         .addMutation(bridge.getControllerColumn().getSchema(), Mutator.DELETE,
445                                 Sets.newHashSet(testController1Uuid)))
446                 .add(op.comment("Bridge: Mutating " + testController1Uuid))
447                 .add(op.commit(true));
448
449         executeTransaction(transactionBuilder, "Controller: Delete operation results for controller1");
450
451         transactionBuilder
452                 .add(op.delete(controller.getSchema())
453                         .where(controller.getUuidColumn().getSchema().opEqual(testController2Uuid))
454                         .build())
455                 .add(op.comment("Controller: Deleting " + testController2Uuid))
456                 .add(op.mutate(bridge.getSchema()) // Delete a controller column in the Bridge table
457                         .addMutation(bridge.getControllerColumn().getSchema(), Mutator.DELETE,
458                                 Sets.newHashSet(testController2Uuid)))
459                 .add(op.comment("Bridge: Mutating " + testController2Uuid))
460                 .add(op.commit(true));
461
462         executeTransaction(transactionBuilder, "Controller: Delete operation results for controller2");
463     }
464
465     @Test
466     public void testController () throws ExecutionException, InterruptedException {
467         testBridgeUuid = bridgeInsert();
468         controllerInsert();
469         controllerDelete();
470         bridgeDelete(testBridgeUuid);
471     }
472
473     @Test
474     public void testFlowSampleCollectorSetTableNotSupported () {
475         // Don't run this test if the table is not supported
476         assumeTrue(schemaVersion.compareTo(flowSampleCollectorSetFromVersion) < 0);
477
478         boolean isExceptionRaised = false;
479         try {
480             getClient().createTypedRowWrapper(FlowSampleCollectorSet.class);
481         } catch (SchemaVersionMismatchException e) {
482             isExceptionRaised = true;
483         }
484         assertTrue(isExceptionRaised);
485     }
486
487     public void flowSampleCollectorSetInsert () throws ExecutionException, InterruptedException {
488         // Don't run this test if the table is not supported
489         assumeTrue(schemaVersion.compareTo(flowSampleCollectorSetFromVersion) >= 0);
490
491         FlowSampleCollectorSet flowSampleCollectorSet =
492                 getClient().createTypedRowWrapper(FlowSampleCollectorSet.class);
493         flowSampleCollectorSet.setId(1L);
494         flowSampleCollectorSet.setExternalIds(ImmutableMap.of("I <3", "ovs"));
495         flowSampleCollectorSet.setBridge(testBridgeUuid);
496
497         TransactionBuilder transactionBuilder = getClient().transactBuilder(getDbSchema())
498                 .add(op.insert(flowSampleCollectorSet.getSchema())
499                         .value(flowSampleCollectorSet.getIdColumn())
500                         .value(flowSampleCollectorSet.getExternalIdsColumn())
501                         .value(flowSampleCollectorSet.getBridgeColumn()))
502                 .add(op.comment("FlowSampleCollectorSet: Inserting"));
503
504         List<OperationResult> operationResults = executeTransaction(transactionBuilder,
505                 "FlowSampleCollectorSet: Insert results");
506         testFlowSampleCollectorSetUuid = operationResults.get(0).getUuid();
507         assertNotNull(ASSERT_TRANS_UUID, testFlowSampleCollectorSetUuid);
508
509         // Verify that the local cache was updated with the remote changes
510         Row flowSampleCollectorSetRow = getTableCache().get(flowSampleCollectorSet.getSchema().getName())
511                 .get(testFlowSampleCollectorSetUuid);
512         FlowSampleCollectorSet monitoredflowSampleCollectorSet =
513                 getClient().getTypedRowWrapper(FlowSampleCollectorSet.class, flowSampleCollectorSetRow);
514         assertEquals(flowSampleCollectorSet.getIdColumn().getData(),
515                 monitoredflowSampleCollectorSet.getIdColumn().getData());
516     }
517
518     public void flowSampleCollectorSetDelete () throws ExecutionException, InterruptedException {
519         assumeTrue(schemaVersion.compareTo(flowSampleCollectorSetFromVersion) >= 0);
520
521         FlowSampleCollectorSet flowSampleCollectorSet = getClient().getTypedRowWrapper(FlowSampleCollectorSet.class, null);
522         TransactionBuilder transactionBuilder = getClient().transactBuilder(getDbSchema())
523                 .add(op.delete(flowSampleCollectorSet.getSchema())
524                         .where(flowSampleCollectorSet.getUuidColumn().getSchema().opEqual(testFlowSampleCollectorSetUuid))
525                         .build())
526                 .add(op.comment("FlowSampleCollectorSet: Deleting " + testFlowSampleCollectorSetUuid))
527                 .add(op.commit(true));
528
529         executeTransaction(transactionBuilder, "Bridge delete operation results");
530     }
531
532     @Test
533     public void testFlowSampleCollectorSet () throws ExecutionException, InterruptedException {
534         // Don't run this test if the table is not supported
535         assumeTrue(schemaVersion.compareTo(flowSampleCollectorSetFromVersion) >= 0);
536
537         testBridgeUuid = bridgeInsert();
538         flowSampleCollectorSetInsert();
539         flowSampleCollectorSetDelete();
540         bridgeDelete(testBridgeUuid);
541     }
542
543     @Test
544     public void testFlowTableTableNotSupported () {
545         // Don't run this test if the table is not supported
546         assumeTrue(schemaVersion.compareTo(flowTableFromVersion) < 0);
547
548         boolean isExceptionRaised = false;
549         try {
550             getClient().createTypedRowWrapper(FlowTable.class);
551         } catch (SchemaVersionMismatchException e) {
552             isExceptionRaised = true;
553         }
554         assertTrue(isExceptionRaised);
555     }
556
557     public void flowTableInsert () throws ExecutionException, InterruptedException {
558         // Don't run this test if the table is not supported
559         assumeTrue(schemaVersion.compareTo(flowTableFromVersion) >= 0);
560
561         String flowTableUuidStr = "testFlowTable";
562         String tableName = "flow_table_row_name";
563         String overflowPolicy = "evict";
564         String groups = "group name";
565         String prefixes = "wildcarding prefixes";
566         Long flowLimit = 50000L;
567         Map<Long, UUID> flowTableBrRef = new HashMap<>();
568         flowTableBrRef.put(1L, new UUID(flowTableUuidStr));
569         FlowTable flowTable = getClient().createTypedRowWrapper(FlowTable.class);
570         flowTable.setName(ImmutableSet.of(tableName));
571         flowTable.setOverflowPolicy(ImmutableSet.of(overflowPolicy));
572         flowTable.setGroups(ImmutableSet.of(groups));
573         if (schemaVersion.compareTo(prefixesAddedVersion) >= 0) {
574             flowTable.setPrefixes(ImmutableSet.of(prefixes));
575         }
576         if (schemaVersion.compareTo(externalIdAddedVerson) >= 0) {
577             flowTable.setExternalIds(ImmutableMap.of("I <3", "OVS"));
578         }
579         flowTable.setFlowLimit(ImmutableSet.of(flowLimit));
580         Bridge bridge = getClient().getTypedRowWrapper(Bridge.class, null);
581
582         TransactionBuilder transactionBuilder = getClient().transactBuilder(getDbSchema())
583                 .add(op.insert(flowTable)
584                         .withId(flowTableUuidStr))
585                 .add(op.comment("Flowtable: Inserting " + flowTableUuidStr))
586                 .add(op.mutate(bridge.getSchema())
587                         .addMutation(bridge.getFlowTablesColumn().getSchema(), Mutator.INSERT, flowTableBrRef)
588                         .where(bridge.getNameColumn().getSchema().opEqual(TEST_BRIDGE_NAME))
589                         .build())
590                 .add(op.comment("Bridge: Mutating " + TEST_BRIDGE_NAME));
591
592         List<OperationResult> operationResults = executeTransaction(transactionBuilder,
593                 "FlowTable: Insert and Mutate results");
594         testFlowTableUuid = operationResults.get(0).getUuid();
595         assertNotNull(ASSERT_TRANS_UUID, testFlowTableUuid);
596
597         // Verify that the local cache was updated with the remote changes
598         Row flowTableRow = getTableCache().get(flowTable.getSchema().getName()).get(testFlowTableUuid);
599         FlowTable monitoredFlowTable = getClient().getTypedRowWrapper(FlowTable.class, flowTableRow);
600         assertEquals(flowTable.getNameColumn().getData(), monitoredFlowTable.getNameColumn().getData());
601     }
602
603     public void flowTableDelete () throws ExecutionException, InterruptedException {
604         // Don't run this test if the table is not supported
605         assumeTrue(schemaVersion.compareTo(flowTableFromVersion) >= 0);
606
607         FlowTable flowTable = getClient().getTypedRowWrapper(FlowTable.class, null);
608         Bridge bridge = getClient().getTypedRowWrapper(Bridge.class, null);
609
610         TransactionBuilder transactionBuilder = getClient().transactBuilder(getDbSchema())
611                 .add(op.delete(flowTable.getSchema())
612                         .where(flowTable.getUuidColumn().getSchema().opEqual(testFlowTableUuid))
613                         .build())
614                 .add(op.comment("FlowTable: Deleting " + testFlowTableUuid))
615                 .add(op.mutate(bridge.getSchema())
616                         .addMutation(bridge.getFlowTablesColumn().getSchema(), Mutator.DELETE,
617                                 Maps.newHashMap(ImmutableMap.of(1L, testFlowTableUuid))))
618                 .add(op.comment("Bridge: Mutating " + testFlowTableUuid))
619                 .add(op.commit(true));
620
621         executeTransaction(transactionBuilder, "FlowTable delete operation results");
622     }
623
624     @Test
625     public void setTestFlowTableSet () throws ExecutionException, InterruptedException {
626         // Don't run this test if the table is not supported
627         assumeTrue(schemaVersion.compareTo(flowTableFromVersion) >= 0);
628
629         UUID testBridgeUuid = bridgeInsert();
630         flowTableInsert();
631         flowTableDelete();
632         bridgeDelete(testBridgeUuid);
633     }
634
635     @Test
636     public void testIpfixTableNotSupported () {
637         // Don't run this test if the table is not supported
638         assumeTrue(schemaVersion.compareTo(ipfixFromVersion) < 0);
639
640         boolean isExceptionRaised = false;
641         try {
642             getClient().createTypedRowWrapper(IPFIX.class);
643         } catch (SchemaVersionMismatchException e) {
644             isExceptionRaised = true;
645         }
646         assertTrue(isExceptionRaised);
647     }
648
649     public void ipfixInsert () throws ExecutionException, InterruptedException {
650         // Don't run this test if the table is not supported
651         assumeTrue(schemaVersion.compareTo(ipfixFromVersion) >= 0);
652
653         String ipfixUuidStr = "testIpfix";
654         String ipfixTarget = "172.16.20.1:4739";
655         Long obsDomainId = 112L;
656         Long obsPointId = 358L;
657         Long cacheMax = 132L;
658         Long cacheTimeout = 134L;
659         Long sampling = 558L;
660
661         IPFIX ipfix = getClient().createTypedRowWrapper(IPFIX.class);
662         ipfix.setTargets(ImmutableSet.of(ipfixTarget));
663         ipfix.setObsDomainId(ImmutableSet.of(obsDomainId));
664         ipfix.setObsPointId(ImmutableSet.of(obsPointId));
665         // Only set these rows if the schema version supports it
666         if (schemaVersion.compareTo(ipfixCacheFromVersion) >= 0) {
667             ipfix.setCacheMaxFlows(ImmutableSet.of(cacheMax));
668             ipfix.setCacheActiveTimeout(ImmutableSet.of(cacheTimeout));
669         }
670         ipfix.setSampling(ImmutableSet.of(sampling));
671         ipfix.setExternalIds(ImmutableMap.of("I <3", "ovs"));
672         Bridge bridge = getClient().getTypedRowWrapper(Bridge.class, null);
673
674         TransactionBuilder transactionBuilder = getClient().transactBuilder(getDbSchema())
675                 .add(op.insert(ipfix)
676                         .withId(ipfixUuidStr))
677                 .add(op.comment("IPFIX: Inserting " + ipfixUuidStr))
678                 .add(op.mutate(bridge.getSchema())
679                         .addMutation(bridge.getIpfixColumn().getSchema(), Mutator.INSERT,
680                                 Sets.newHashSet(new UUID(ipfixUuidStr)))
681                         .where(bridge.getNameColumn().getSchema().opEqual(TEST_BRIDGE_NAME))
682                         .build())
683                 .add(op.comment("Bridge: Mutating " + ipfixUuidStr));
684
685         List<OperationResult> operationResults = executeTransaction(transactionBuilder,
686                 "IPFIX: Insert and Mutate results");
687         testIpfixUuid = operationResults.get(0).getUuid();
688         assertNotNull(ASSERT_TRANS_UUID, testIpfixUuid);
689
690         // Verify that the local cache was updated with the remote changes
691         Row ipfixRow = getTableCache().get(ipfix.getSchema().getName()).get(testIpfixUuid);
692         IPFIX monitoredIPFIX = getClient().getTypedRowWrapper(IPFIX.class, ipfixRow);
693         assertEquals(testIpfixUuid, monitoredIPFIX.getUuidColumn().getData());
694     }
695
696     public void ipfixDelete () throws ExecutionException, InterruptedException {
697         // Don't run this test if the table is not supported
698         assumeTrue(schemaVersion.compareTo(ipfixFromVersion) >= 0);
699
700         FlowTable flowTable = getClient().getTypedRowWrapper(FlowTable.class, null);
701         Bridge bridge = getClient().getTypedRowWrapper(Bridge.class, null);
702
703         TransactionBuilder transactionBuilder = getClient().transactBuilder(getDbSchema())
704                 .add(op.delete(flowTable.getSchema())
705                         .where(flowTable.getUuidColumn().getSchema().opEqual(testIpfixUuid))
706                         .build())
707                 .add(op.comment("IPFIX: Deleting " + testIpfixUuid))
708                 .add(op.mutate(bridge.getSchema()) // Delete a controller column in the Bridge table
709                         .addMutation(bridge.getMirrorsColumn().getSchema(), Mutator.DELETE,
710                                 Sets.newHashSet(testIpfixUuid)))
711                 .add(op.comment("Bridge: Mutating " + testIpfixUuid))
712                 .add(op.commit(true));
713
714         executeTransaction(transactionBuilder, "IPFIX delete operation results");
715     }
716
717     @Test
718     public void testIpfix () throws ExecutionException, InterruptedException {
719         // Don't run this test if the table is not supported
720         assumeTrue(schemaVersion.compareTo(ipfixFromVersion) >= 0);
721
722         testBridgeUuid = bridgeInsert();
723         ipfixInsert();
724         ipfixDelete();
725         bridgeDelete(testBridgeUuid);
726     }
727
728     public void managerInsert() throws ExecutionException, InterruptedException {
729         ImmutableMap<String, String> externalIds = ImmutableMap.of("slaveof", "themaster");
730         UUID openVSwitchRowUuid = getOpenVSwitchTableUuid(getClient(), getTableCache());
731         OpenVSwitch openVSwitch = getClient().getTypedRowWrapper(OpenVSwitch.class, null);
732         Manager manager = getClient().createTypedRowWrapper(Manager.class);
733         manager.setInactivityProbe(Sets.newHashSet(8192L));
734         manager.setMaxBackoff(Sets.newHashSet(4094L));
735         manager.setTarget("tcp:172.16.50.50:6640");
736         manager.setExternalIds(externalIds);
737
738         TransactionBuilder transactionBuilder = getClient().transactBuilder(getDbSchema())
739                 .add(op.insert(manager.getSchema())
740                         .withId(TEST_MANAGER_UUID_STR)
741                         .value(manager.getTargetColumn())
742                         .value(manager.getInactivityProbeColumn())
743                         .value(manager.getMaxBackoffColumn())
744                         .value(manager.getExternalIdsColumn()))
745                 .add(op.comment("Manager: Inserting Slave Manager " + TEST_MANAGER_UUID_STR))
746                 .add(op.mutate(openVSwitch.getSchema())
747                         .addMutation(openVSwitch.getManagerOptionsColumn().getSchema(), Mutator.INSERT,
748                                 Sets.newHashSet(new UUID(TEST_MANAGER_UUID_STR)))
749                         .where(openVSwitch.getUuidColumn().getSchema().opEqual(openVSwitchRowUuid))
750                         .build())
751                 .add(op.comment("Open_vSwitch: Mutating " + TEST_MANAGER_UUID_STR));
752
753         List<OperationResult> operationResults = executeTransaction(transactionBuilder,
754                 "Manager: Insert & Mutate operation results");
755         testManagerUuid = operationResults.get(0).getUuid();
756         assertNotNull(ASSERT_TRANS_UUID, testManagerUuid);
757
758         // Verify that the local cache was updated with the remote changes
759         Row managerRow = getTableCache().get(manager.getSchema().getName()).get(testManagerUuid);
760         Manager monitoredManager = getClient().getTypedRowWrapper(Manager.class, managerRow);
761         assertEquals(externalIds, monitoredManager.getExternalIdsColumn().getData());
762     }
763
764     public void managerDelete () throws ExecutionException, InterruptedException {
765         Manager manager = getClient().getTypedRowWrapper(Manager.class, null);
766         OpenVSwitch openVSwitch = getClient().getTypedRowWrapper(OpenVSwitch.class, null);
767
768         TransactionBuilder transactionBuilder = getClient().transactBuilder(getDbSchema())
769                 .add(op.delete(manager.getSchema())
770                         .where(manager.getUuidColumn().getSchema().opEqual(testManagerUuid))
771                         .build())
772                 .add(op.comment("Manager: Deleting " + TEST_MANAGER_UUID_STR))
773                 .add(op.mutate(openVSwitch.getSchema())
774                         .addMutation(openVSwitch.getManagerOptionsColumn().getSchema(), Mutator.DELETE,
775                                 Sets.newHashSet(testManagerUuid)))
776                 .add(op.comment("Open_vSwitch: Mutating " + TEST_MANAGER_UUID_STR + " " + testManagerUuid))
777                 .add(op.commit(true));
778
779         executeTransaction(transactionBuilder, "Manager: Delete operation results");
780     }
781
782     @Test
783     public void testManager () throws ExecutionException, InterruptedException {
784         managerInsert();
785         managerDelete();
786     }
787
788     public void mirrorInsert () throws ExecutionException, InterruptedException {
789         String mirrorUuidStr = "testMirror";
790         String mirrorName = "my_name_is_mirror";
791         Long outputVid = 1024L;
792         Long selectVid = 2048L;
793
794         Mirror mirror = getClient().createTypedRowWrapper(Mirror.class);
795         mirror.setName(ImmutableSet.of(mirrorName));
796         mirror.setExternalIds(ImmutableMap.of("overlays", "ftw"));
797         mirror.setOutputVlan(ImmutableSet.of(outputVid));
798         mirror.setSelectVlan(ImmutableSet.of(selectVid));
799         mirror.setExternalIds(ImmutableMap.of("reading", "urmail"));
800         Bridge bridge = getClient().getTypedRowWrapper(Bridge.class, null);
801
802         TransactionBuilder transactionBuilder = getClient().transactBuilder(getDbSchema())
803                 .add(op.insert(mirror.getSchema())
804                         .withId(mirrorUuidStr)
805                         .value(mirror.getNameColumn())
806                         .value(mirror.getExternalIdsColumn()))
807                 .add(op.comment("Mirror: Inserting " + mirrorUuidStr))
808                 .add(op.mutate(bridge.getSchema())
809                         .addMutation(bridge.getMirrorsColumn().getSchema(), Mutator.INSERT,
810                                 Sets.newHashSet(new UUID(mirrorUuidStr)))
811                         .where(bridge.getNameColumn().getSchema().opEqual(TEST_BRIDGE_NAME))
812                         .build())
813                 .add(op.comment("Bridge: Mutating " + TEST_BRIDGE_NAME));
814
815         List<OperationResult> operationResults = executeTransaction(transactionBuilder,
816                 "Insert and Mutate operation results for Mirror");
817         testMirrorUuid = operationResults.get(0).getUuid();
818         assertNotNull(ASSERT_TRANS_UUID, testMirrorUuid);
819
820         // Verify that the local cache was updated with the remote changes
821         Row mirrorRow = getTableCache().get(mirror.getSchema().getName()).get(testMirrorUuid);
822         Mirror monitoredMirror = getClient().getTypedRowWrapper(Mirror.class, mirrorRow);
823         assertEquals(mirror.getExternalIdsColumn().getData(), monitoredMirror.getExternalIdsColumn().getData());
824     }
825
826     private void mirrorDelete () throws ExecutionException, InterruptedException {
827         Mirror mirror = getClient().getTypedRowWrapper(Mirror.class, null);
828         Bridge bridge = getClient().getTypedRowWrapper(Bridge.class, null);
829         DatabaseSchema dbSchema = getClient().getSchema(LibraryIntegrationTestUtils.OPEN_VSWITCH_SCHEMA).get();
830
831         TransactionBuilder transactionBuilder = getClient().transactBuilder(dbSchema)
832                 .add(op.delete(mirror.getSchema())
833                         .where(mirror.getUuidColumn().getSchema().opEqual(testMirrorUuid))
834                         .build())
835                 .add(op.comment("Mirror: Deleting " + testMirrorUuid))
836                 .add(op.mutate(bridge.getSchema()) // Delete a controller column in the Bridge table
837                         .addMutation(bridge.getMirrorsColumn().getSchema(), Mutator.DELETE,
838                                 Sets.newHashSet(testMirrorUuid)))
839                 .add(op.comment("Bridge: Mutating " + testMirrorUuid))
840                 .add(op.commit(true));
841
842         executeTransaction(transactionBuilder, "Mirror: Delete operation results");
843     }
844
845     @Test
846     public void testMirror () throws ExecutionException, InterruptedException {
847         testBridgeUuid = bridgeInsert();
848         mirrorInsert();
849         mirrorDelete();
850         bridgeDelete(testBridgeUuid);
851     }
852
853     public void netFlowInsert () throws ExecutionException, InterruptedException {
854         String netFlowUuidStr = "testNetFlow";
855         String netFlowTargets = "172.16.20.200:6343";
856         Long engineType = 128L;
857         Long engineID = 32L;
858         Long activityTimeout = 1L;
859         NetFlow netFlow = getClient().createTypedRowWrapper(NetFlow.class);
860         netFlow.setTargets(ImmutableSet.of(netFlowTargets));
861         netFlow.setEngineType(ImmutableSet.of(engineType));
862         netFlow.setEngineId(ImmutableSet.of(engineID));
863         netFlow.setActivityTimeout(ImmutableSet.of(activityTimeout));
864         netFlow.setExternalIds(ImmutableMap.of("big", "baby"));
865         Bridge bridge = getClient().getTypedRowWrapper(Bridge.class, null);
866         TransactionBuilder transactionBuilder = getClient().transactBuilder(getDbSchema())
867                 .add(op.insert(netFlow.getSchema())
868                         .withId(netFlowUuidStr)
869                         .value(netFlow.getTargetsColumn())
870                         .value(netFlow.getEngineTypeColumn())
871                         .value(netFlow.getEngineIdColumn())
872                         .value(netFlow.getActiveTimeoutColumn())
873                         .value(netFlow.getExternalIdsColumn()))
874                 .add(op.comment("Mirror: Inserting " + netFlowUuidStr))
875                 .add(op.mutate(bridge.getSchema())
876                         .addMutation(bridge.getNetflowColumn().getSchema(), Mutator.INSERT,
877                                 Sets.newHashSet(new UUID(netFlowUuidStr)))
878                         .where(bridge.getNameColumn().getSchema().opEqual(TEST_BRIDGE_NAME))
879                         .build())
880                 .add(op.comment("Bridge: Mutating " + TEST_BRIDGE_NAME));
881
882         List<OperationResult> operationResults = executeTransaction(transactionBuilder,
883                 "Insert and Mutate operation results for NetFlow");
884         testNetFlowUuid = operationResults.get(0).getUuid();
885         assertNotNull(ASSERT_TRANS_UUID, testNetFlowUuid);
886
887         // Verify that the local cache was updated with the remote changes
888         Row netFlowRow = getTableCache().get(netFlow.getSchema().getName()).get(testNetFlowUuid);
889         Mirror monitoredNetFlow = getClient().getTypedRowWrapper(Mirror.class, netFlowRow);
890         assertEquals(netFlow.getExternalIdsColumn().getData(), monitoredNetFlow.getExternalIdsColumn().getData());
891     }
892
893     private void netFlowDelete () throws ExecutionException, InterruptedException {
894         NetFlow netFlow = getClient().getTypedRowWrapper(NetFlow.class, null);
895         Bridge bridge = getClient().getTypedRowWrapper(Bridge.class, null);
896         DatabaseSchema dbSchema = getClient().getSchema(LibraryIntegrationTestUtils.OPEN_VSWITCH_SCHEMA).get();
897
898         TransactionBuilder transactionBuilder = getClient().transactBuilder(dbSchema)
899                 .add(op.delete(netFlow.getSchema())
900                         .where(netFlow.getUuidColumn().getSchema().opEqual(testNetFlowUuid))
901                         .build())
902                 .add(op.comment("NetFlow: Deleting " + testNetFlowUuid))
903                 .add(op.mutate(bridge.getSchema()) // Delete a controller column in the Bridge table
904                         .addMutation(bridge.getNetflowColumn().getSchema(), Mutator.DELETE,
905                                 Sets.newHashSet(testNetFlowUuid)))
906                 .add(op.comment("Bridge: Mutating " + testNetFlowUuid))
907                 .add(op.commit(true));
908
909         executeTransaction(transactionBuilder, "NetFlow: Delete operation results");
910     }
911
912     @Test
913     public void testNetFlow () throws ExecutionException, InterruptedException {
914         testBridgeUuid = bridgeInsert();
915         netFlowInsert();
916         netFlowDelete();
917         bridgeDelete(testBridgeUuid);
918     }
919
920     public void portAndInterfaceInsert () throws ExecutionException, InterruptedException {
921         String portUuidStr = "testPort";
922         String intfUuidStr = "testIntf";
923         String tunnelEncap = "vxlan";
924         Port port = getClient().createTypedRowWrapper(Port.class);
925         port.setName("testPort");
926         port.setTag(ImmutableSet.of(1L));
927         port.setMac(ImmutableSet.of("00:00:00:00:00:01"));
928         port.setInterfaces(ImmutableSet.of(new UUID(intfUuidStr)));
929
930         Interface intf = getClient().createTypedRowWrapper(Interface.class);
931         intf.setName(port.getNameColumn().getData());
932         intf.setType(tunnelEncap);
933         intf.setExternalIds(ImmutableMap.of("vm-id", "12345abcedf78910"));
934         // For per Flow TEPs use remote_ip=flow
935         // For per Port TEPs use remote_ip=x.x.x.x (ipv4)
936         intf.setOptions(ImmutableMap.of("local_ip", "172.16.24.145",
937                 "remote_ip", "flow",
938                 "key", "flow",
939                 "dst_port", "8472"));
940
941         Bridge bridge = getClient().getTypedRowWrapper(Bridge.class, null);
942         TransactionBuilder transactionBuilder = getClient().transactBuilder(getDbSchema())
943                 .add(op.insert(port.getSchema())
944                         .withId(portUuidStr)
945                         .value(port.getNameColumn())
946                         .value(port.getMacColumn()))
947                 .add(op.comment("Port: Inserting " + portUuidStr))
948                 .add(op.insert(intf.getSchema())
949                         .withId(intfUuidStr)
950                         .value(intf.getNameColumn()))
951                 .add(op.comment("Interface: Inserting " + intfUuidStr))
952                 .add(op.update(port.getSchema())
953                         .set(port.getTagColumn())
954                         .set(port.getMacColumn())
955                         .set(port.getInterfacesColumn())
956                         .where(port.getNameColumn().getSchema().opEqual(port.getName()))
957                         .build())
958                 .add(op.comment("Port: Updating " + portUuidStr))
959                 .add(op.update(intf.getSchema())
960                         .set(intf.getTypeColumn())
961                         .set(intf.getExternalIdsColumn())
962                         .set(intf.getOptionsColumn())
963                         .where(intf.getNameColumn().getSchema().opEqual(intf.getName()))
964                         .build())
965                 .add(op.comment("Interface: Updating " + intfUuidStr))
966                 .add(op.mutate(bridge.getSchema())
967                         .addMutation(bridge.getPortsColumn().getSchema(), Mutator.INSERT, Sets.newHashSet(new UUID(portUuidStr)))
968                         .where(bridge.getNameColumn().getSchema().opEqual(TEST_BRIDGE_NAME))
969                         .build())
970                 .add(op.comment("Bridge: Mutating " + TEST_BRIDGE_NAME));
971
972         List<OperationResult> operationResults = executeTransaction(transactionBuilder,
973                 "Insert and Mutate operation results for Port and Interface");
974         testPortUuid = operationResults.get(0).getUuid();
975         assertNotNull(ASSERT_TRANS_UUID, testPortUuid);
976         testInterfaceUuid = operationResults.get(2).getUuid();
977         assertNotNull(ASSERT_TRANS_UUID, testInterfaceUuid);
978
979         // Verify that the local cache was updated with the remote changes
980         Row portRow = getTableCache().get(port.getSchema().getName()).get(testPortUuid);
981         Port monitoredPort = getClient().getTypedRowWrapper(Port.class, portRow);
982         assertEquals(port.getNameColumn().getData(), monitoredPort.getNameColumn().getData());
983
984         Row interfaceRow = getTableCache().get(intf.getSchema().getName()).get(testInterfaceUuid);
985         Interface monitoredInterface = getClient().getTypedRowWrapper(Interface.class, interfaceRow);
986         assertEquals(intf.getNameColumn().getData(), monitoredInterface.getNameColumn().getData());
987     }
988
989     private void portAndInterfaceDelete () throws ExecutionException, InterruptedException {
990         Port port = getClient().getTypedRowWrapper(Port.class, null);
991         Interface intf = getClient().getTypedRowWrapper(Interface.class, null);
992         Bridge bridge = getClient().getTypedRowWrapper(Bridge.class, null);
993         DatabaseSchema dbSchema = getClient().getSchema(LibraryIntegrationTestUtils.OPEN_VSWITCH_SCHEMA).get();
994
995         TransactionBuilder transactionBuilder = getClient().transactBuilder(dbSchema)
996                 .add(op.delete(port.getSchema())
997                         .where(port.getUuidColumn().getSchema().opEqual(testPortUuid))
998                         .build())
999                 .add(op.comment("Port: Deleting " + testPortUuid))
1000                 .add(op.delete(intf.getSchema())
1001                         .where(intf.getUuidColumn().getSchema().opEqual(testInterfaceUuid))
1002                         .build())
1003                 .add(op.comment("Interface: Deleting " + testInterfaceUuid))
1004                 .add(op.mutate(bridge.getSchema()) // Delete a port column in the Bridge table
1005                         .addMutation(bridge.getPortsColumn().getSchema(), Mutator.DELETE,
1006                                 Sets.newHashSet(testPortUuid)))
1007                 .add(op.comment("Bridge: Mutating " + testPortUuid))
1008                 .add(op.commit(true));
1009
1010         executeTransaction(transactionBuilder, "Port and Interface: Delete operation results");
1011     }
1012
1013     @Test
1014     public void testPortAndInterface () throws ExecutionException, InterruptedException {
1015         testBridgeUuid = bridgeInsert();
1016         portAndInterfaceInsert();
1017         portAndInterfaceDelete();
1018         bridgeDelete(testBridgeUuid);
1019     }
1020
1021     public void qosInsert() throws ExecutionException, InterruptedException {
1022         String portUuidStr = "testQosPortUuid";
1023         String intfUuidStr = "testQosIntfUuid";
1024         String qosUuidStr = "testQosUuid";
1025         String qosPort = "testQosPort";
1026
1027         Port port = getClient().createTypedRowWrapper(Port.class);
1028         port.setName(qosPort);
1029         port.setInterfaces(ImmutableSet.of(new UUID(intfUuidStr)));
1030         port.setQos(ImmutableSet.of(new UUID(qosUuidStr)));
1031         port.setOtherConfig(ImmutableMap.of("m0r3", "c0ff33"));
1032
1033         Interface intf = getClient().createTypedRowWrapper(Interface.class);
1034         intf.setName(port.getNameColumn().getData());
1035         intf.setOtherConfig(ImmutableMap.of("proto", "duction"));
1036         intf.setExternalIds(ImmutableMap.of("stringly", "typed"));
1037
1038         Qos qos = getClient().createTypedRowWrapper(Qos.class);
1039         qos.setOtherConfig(ImmutableMap.of("mmm", "kay"));
1040         qos.setType(ImmutableSet.of("404"));
1041
1042         Bridge bridge = getClient().getTypedRowWrapper(Bridge.class, null);
1043
1044         TransactionBuilder transactionBuilder = getClient().transactBuilder(getDbSchema())
1045                 .add(op.insert(port.getSchema())
1046                         .withId(portUuidStr)
1047                         .value(port.getNameColumn()))
1048                 .add(op.comment("Port: Inserting " + portUuidStr))
1049                 .add(op.insert(intf.getSchema())
1050                         .withId(intfUuidStr)
1051                         .value(intf.getExternalIdsColumn())
1052                         .value(intf.getNameColumn())
1053                         .value(intf.getOtherConfigColumn()))
1054                 .add(op.comment("Interface: Inserting " + intfUuidStr))
1055                 .add(op.insert(qos.getSchema())
1056                         .withId(qosUuidStr)
1057                         .value(qos.getTypeColumn())
1058                         .value(qos.getOtherConfigColumn()))
1059                 .add(op.comment("QOS: Inserting " + qosUuidStr))
1060                 .add(op.update(port.getSchema())
1061                         .set(port.getOtherConfigColumn())
1062                         .set(port.getInterfacesColumn())
1063                         .set(port.getQosColumn())
1064                         .where(port.getNameColumn().getSchema().opEqual(port.getName()))
1065                         .build())
1066                 .add(op.comment("Interface: Updating " + intfUuidStr))
1067                 .add(op.mutate(bridge.getSchema())
1068                         .addMutation(bridge.getPortsColumn().getSchema(), Mutator.INSERT,
1069                                 Sets.newHashSet(new UUID(portUuidStr)))
1070                         .where(bridge.getNameColumn().getSchema().opEqual(TEST_BRIDGE_NAME))
1071                         .build())
1072                 .add(op.comment("Bridge: Mutating " + TEST_BRIDGE_NAME));
1073
1074         int insertPortOperationIndex = 0;
1075         int insertInterfaceOperationIndex = 2;
1076         int insertQosOperationIndex = 4;
1077         List<OperationResult> operationResults = executeTransaction(transactionBuilder,
1078                 "Insert and Mutate operation results for Port and Interface");
1079         testPortUuid = operationResults.get(insertPortOperationIndex).getUuid();
1080         assertNotNull(ASSERT_TRANS_UUID, testPortUuid);
1081         testInterfaceUuid = operationResults.get(insertInterfaceOperationIndex).getUuid();
1082         assertNotNull(ASSERT_TRANS_UUID, testInterfaceUuid);
1083         testQosUuid = operationResults.get(insertQosOperationIndex).getUuid();
1084         assertNotNull(ASSERT_TRANS_UUID, testQosUuid);
1085
1086         // Verify that the local cache was updated with the remote changes
1087         Row portRow = getTableCache().get(port.getSchema().getName()).get(testPortUuid);
1088         Port monitoredPort = getClient().getTypedRowWrapper(Port.class, portRow);
1089         assertEquals(port.getNameColumn().getData(), monitoredPort.getNameColumn().getData());
1090
1091         Row interfaceRow = getTableCache().get(intf.getSchema().getName()).get(testInterfaceUuid);
1092         Interface monitoredInterface = getClient().getTypedRowWrapper(Interface.class, interfaceRow);
1093         assertEquals(intf.getNameColumn().getData(), monitoredInterface.getNameColumn().getData());
1094
1095         Row qosRow = getTableCache().get(qos.getSchema().getName()).get(testQosUuid);
1096         Qos monitoredQos = getClient().getTypedRowWrapper(Qos.class, qosRow);
1097         assertEquals(qos.getTypeColumn().getData().toArray()[0], monitoredQos.getTypeColumn().getData());
1098     }
1099
1100     private void qosDelete () throws ExecutionException, InterruptedException {
1101         Port port = getClient().getTypedRowWrapper(Port.class, null);
1102         Interface intf = getClient().getTypedRowWrapper(Interface.class, null);
1103         Qos qos = getClient().getTypedRowWrapper(Qos.class, null);
1104         Bridge bridge = getClient().getTypedRowWrapper(Bridge.class, null);
1105         DatabaseSchema dbSchema = getClient().getSchema(LibraryIntegrationTestUtils.OPEN_VSWITCH_SCHEMA).get();
1106
1107         TransactionBuilder transactionBuilder = getClient().transactBuilder(dbSchema)
1108                 .add(op.delete(port.getSchema())
1109                         .where(port.getUuidColumn().getSchema().opEqual(testPortUuid))
1110                         .build())
1111                 .add(op.comment("Port: Deleting " + testPortUuid))
1112                 .add(op.delete(intf.getSchema())
1113                         .where(intf.getUuidColumn().getSchema().opEqual(testInterfaceUuid))
1114                         .build())
1115                 .add(op.comment("Interface: Deleting " + testInterfaceUuid))
1116                 .add(op.delete(qos.getSchema())
1117                         .where(qos.getUuidColumn().getSchema().opEqual(testQosUuid))
1118                         .build())
1119                 .add(op.comment("Qos: Deleting " + testQosUuid))
1120                 .add(op.mutate(bridge.getSchema()) // Delete a port column in the Bridge table
1121                         .addMutation(bridge.getPortsColumn().getSchema(), Mutator.DELETE,
1122                                 Sets.newHashSet(testPortUuid)))
1123                 .add(op.comment("Bridge: Mutating " + testPortUuid))
1124                 .add(op.mutate(port.getSchema()) // Delete a qos column in the Port table
1125                         .addMutation(port.getQosColumn().getSchema(), Mutator.DELETE,
1126                                 Sets.newHashSet(testQosUuid)))
1127                 .add(op.comment("Port: Mutating " + testPortUuid))
1128                 .add(op.commit(true));
1129
1130         executeTransaction(transactionBuilder, "Qos, Port and Interface: Delete operation results");
1131     }
1132
1133     @Test
1134     public void testQos () throws ExecutionException, InterruptedException {
1135         testBridgeUuid = bridgeInsert();
1136         qosInsert();
1137         qosDelete();
1138         bridgeDelete(testBridgeUuid);
1139     }
1140
1141     public void queueInsert() throws InterruptedException, ExecutionException {
1142         /**
1143          * This is an arbitrary String that is a placeholder for
1144          * the future UUID generated by the OVSDB Server in the
1145          * future transaction. While it is possible to generate
1146          * ones own UUID for the transaction it is not recommended
1147          * since it wouldn't add any conceivable value.
1148          */
1149         String queueUuidStr = "queueUuidStr";
1150         Long dscpVal = 4L;
1151         Queue queue = getClient().createTypedRowWrapper(Queue.class);
1152         // Example of explicit ImmutableSet/Map Attribute declaration
1153         ImmutableSet<Long> dscp = ImmutableSet.of(dscpVal);
1154         ImmutableMap<String, String> externalIds = ImmutableMap.of("little", "coat");
1155         // Example of condensing the attributes bindings in one line
1156         queue.setOtherConfig(ImmutableMap.of("war", "onfun"));
1157         // Bind the Attributes to the transaction. These values end up in columns.
1158         queue.setExternalIds(externalIds);
1159         queue.setDscp(dscp);
1160         // Get the parent Qos table row UUID to insert the queue.
1161         Qos qos = getClient().getTypedRowWrapper(Qos.class, null);
1162         // Queue key that is mapped to the queue record/value/ofp_action_enqueue
1163         Long queueKey = 0L;
1164         // Reference the Port row to insert the Queue with UID or Port name
1165         TransactionBuilder transactionBuilder = getClient().transactBuilder(getDbSchema())
1166                 .add(op.insert(queue.getSchema())
1167                         .withId(queueUuidStr)
1168                         .value(queue.getDscpColumn())
1169                         .value(queue.getExternalIdsColumn())
1170                         .value(queue.getOtherConfigColumn()))
1171                 .add(op.comment("Queue: Inserting " + queueUuidStr))
1172                 .add(op.mutate(qos.getSchema())
1173                         .addMutation(qos.getQueuesColumn().getSchema(), Mutator.INSERT,
1174                                 ImmutableMap.of(queueKey, new UUID(queueUuidStr)))
1175                         .where(qos.getUuidColumn().getSchema().opEqual(testQosUuid))
1176                         .build())
1177                 .add(op.comment("Qos: Mutating " + testQosUuid));
1178
1179         // The transaction index for the Queue insert is used to store the Queue UUID
1180         int insertQueueOperationIndex = 0;
1181         List<OperationResult> operationResults = executeTransaction(transactionBuilder,
1182                 "Insert and Mutate operation results for Queue");
1183         testQueueUuid = operationResults.get(insertQueueOperationIndex).getUuid();
1184         assertNotNull(ASSERT_TRANS_UUID, testQueueUuid);
1185
1186         // Verify that the local cache was updated with the remote changes
1187         Row queueRow = getTableCache().get(queue.getSchema().getName()).get(testQueueUuid);
1188         Queue monitoredQueue = getClient().getTypedRowWrapper(Queue.class, queueRow);
1189         assertEquals(queue.getExternalIdsColumn().getData(), monitoredQueue.getExternalIdsColumn().getData());
1190     }
1191
1192     private void queueDelete () throws ExecutionException, InterruptedException {
1193         Queue queue = getClient().getTypedRowWrapper(Queue.class, null);
1194         Qos qos = getClient().getTypedRowWrapper(Qos.class, null);
1195         DatabaseSchema dbSchema = getClient().getSchema(LibraryIntegrationTestUtils.OPEN_VSWITCH_SCHEMA).get();
1196
1197         TransactionBuilder transactionBuilder = getClient().transactBuilder(dbSchema)
1198                 .add(op.delete(queue.getSchema())
1199                         .where(queue.getUuidColumn().getSchema().opEqual(testQueueUuid))
1200                         .build())
1201                 .add(op.comment("Queue: Deleting " + testQueueUuid))
1202                 .add(op.mutate(qos.getSchema()) // Delete a queue column in the Qos table
1203                         .addMutation(qos.getQueuesColumn().getSchema(), Mutator.DELETE,
1204                                 Maps.newHashMap(ImmutableMap.of(0L,testQueueUuid))))
1205                 .add(op.comment("Queue: Mutating " + testQueueUuid))
1206                 .add(op.commit(true));
1207
1208         executeTransaction(transactionBuilder, "Queue: Delete operation results");
1209     }
1210
1211     @Test
1212     public void testQueue () throws ExecutionException, InterruptedException {
1213         testBridgeUuid = bridgeInsert();
1214         qosInsert();
1215         queueInsert();
1216         queueDelete();
1217         qosDelete();
1218         bridgeDelete(testBridgeUuid);
1219     }
1220
1221     public void sFlowInsert () throws ExecutionException, InterruptedException {
1222         String sFlowUuidStr = "testSFlow";
1223         String sFlowTarget = "172.16.20.200:6343";
1224         Long header = 128L;
1225         Long obsPointId = 358L;
1226         Long polling =10L;
1227         String agent = "172.16.20.210";
1228         Long sampling = 64L;
1229         SFlow sFlow = getClient().createTypedRowWrapper(SFlow.class);
1230         sFlow.setTargets(ImmutableSet.of(sFlowTarget));
1231         sFlow.setHeader(ImmutableSet.of(header));
1232         sFlow.setPolling(ImmutableSet.of(obsPointId));
1233         sFlow.setPolling(ImmutableSet.of(polling));
1234         sFlow.setAgent(ImmutableSet.of(agent));
1235         sFlow.setSampling(ImmutableSet.of(sampling));
1236         sFlow.setExternalIds(ImmutableMap.of("kit", "tah"));
1237         Bridge bridge = getClient().getTypedRowWrapper(Bridge.class, null);
1238         TransactionBuilder transactionBuilder = getClient().transactBuilder(getDbSchema())
1239                 .add(op.insert(sFlow.getSchema())
1240                         .withId(sFlowUuidStr)
1241                         .value(sFlow.getTargetsColumn())
1242                         .value(sFlow.getHeaderColumn())
1243                         .value(sFlow.getPollingColumn())
1244                         .value(sFlow.getAgentColumn())
1245                         .value(sFlow.getSamplingColumn())
1246                         .value(sFlow.getExternalIdsColumn()))
1247                 .add(op.comment("sFlow: Inserting " + sFlowUuidStr))
1248                 .add(op.mutate(bridge.getSchema())
1249                         .addMutation(bridge.getSflowColumn().getSchema(), Mutator.INSERT,
1250                                 Sets.newHashSet(new UUID(sFlowUuidStr)))
1251                         .where(bridge.getNameColumn().getSchema().opEqual(TEST_BRIDGE_NAME))
1252                         .build())
1253                 .add(op.comment("Bridge: Mutating " + TEST_BRIDGE_NAME));
1254         int insertSFlowOperationIndex = 0;
1255         List<OperationResult> operationResults = executeTransaction(transactionBuilder,
1256                 "Insert and Mutate operation results for sFlow");
1257         testSFlowUuid = operationResults.get(insertSFlowOperationIndex).getUuid();
1258         assertNotNull(ASSERT_TRANS_UUID, testSFlowUuid);
1259
1260         // Verify that the local cache was updated with the remote changes
1261         Row sFlowRow = getTableCache().get(sFlow.getSchema().getName()).get(testSFlowUuid);
1262         Queue monitoredSFlow = getClient().getTypedRowWrapper(Queue.class, sFlowRow);
1263         assertEquals(sFlow.getExternalIdsColumn().getData(), monitoredSFlow.getExternalIdsColumn().getData());
1264     }
1265
1266     private void sFlowDelete () throws ExecutionException, InterruptedException {
1267         SFlow sFlow = getClient().getTypedRowWrapper(SFlow.class, null);
1268         Bridge bridge = getClient().getTypedRowWrapper(Bridge.class, null);
1269         DatabaseSchema dbSchema = getClient().getSchema(LibraryIntegrationTestUtils.OPEN_VSWITCH_SCHEMA).get();
1270
1271         TransactionBuilder transactionBuilder = getClient().transactBuilder(dbSchema)
1272                 .add(op.delete(sFlow.getSchema())
1273                         .where(sFlow.getUuidColumn().getSchema().opEqual(testSFlowUuid))
1274                         .build())
1275                 .add(op.comment("SFlow: Deleting " + testSFlowUuid))
1276                 .add(op.mutate(bridge.getSchema()) // Delete an sflow column in the Bridge table
1277                         .addMutation(bridge.getSflowColumn().getSchema(), Mutator.DELETE,
1278                                 Sets.newHashSet(testSFlowUuid)))
1279                 .add(op.comment("Bridge: Mutating " + testSFlowUuid))
1280                 .add(op.commit(true));
1281
1282         executeTransaction(transactionBuilder, "Queue: Delete operation results");
1283     }
1284
1285     @Test
1286     public void testSFlow () throws ExecutionException, InterruptedException {
1287         testBridgeUuid = bridgeInsert();
1288         sFlowInsert();
1289         sFlowDelete();
1290         bridgeDelete(testBridgeUuid);
1291     }
1292
1293     public void sslInsert () throws ExecutionException, InterruptedException {
1294
1295         String sslUuidStr = "sslUuidName";
1296         String caCert = "PARC";
1297         String certificate = "01101110 01100101 01110010 01100100";
1298         String privateKey = "SSL_Table_Test_Secret";
1299         ImmutableMap<String, String> externalIds = ImmutableMap.of("roomba", "powered");
1300
1301         SSL ssl = getClient().createTypedRowWrapper(SSL.class);
1302         ssl.setCaCert(caCert);
1303         ssl.setCertificate(certificate);
1304         ssl.setPrivateKey(privateKey);
1305         ssl.setExternalIds(externalIds);
1306         // Get the parent OVS table UUID in it's single row
1307         UUID openVSwitchRowUuid = getOpenVSwitchTableUuid(getClient(), getTableCache());
1308         OpenVSwitch openVSwitch = getClient().getTypedRowWrapper(OpenVSwitch.class, null);
1309         TransactionBuilder transactionBuilder = getClient().transactBuilder(getDbSchema())
1310                 .add(op.insert(ssl.getSchema())
1311                         .withId(sslUuidStr)
1312                         .value(ssl.getCertificateColumn())
1313                         .value(ssl.getPrivateKeyColumn())
1314                         .value(ssl.getCaCertColumn())
1315                         .value(ssl.getExternalIdsColumn()))
1316                 .add(op.comment("SSL: Inserting " + sslUuidStr))
1317                 .add(op.mutate(openVSwitch.getSchema())
1318                         .addMutation(openVSwitch.getSslColumn().getSchema(), Mutator.INSERT,
1319                                 Sets.newHashSet(new UUID(sslUuidStr)))
1320                         .where(openVSwitch.getUuidColumn().getSchema().opEqual(openVSwitchRowUuid))
1321                         .build())
1322                 .add(op.comment("Open_vSwitch: Mutating " + sslUuidStr));
1323
1324         // The transaction index for the SSL insert is used to store the SSL UUID
1325         int insertSslOperationIndex = 0;
1326         List<OperationResult> operationResults = executeTransaction(transactionBuilder,
1327                 "Insert and Mutate operation results for SSL");
1328         testSslUuid = operationResults.get(insertSslOperationIndex).getUuid();
1329         assertNotNull(ASSERT_TRANS_UUID, testSslUuid);
1330
1331         // Verify that the local cache was updated with the remote changes
1332         Row sslRow = getTableCache().get(ssl.getSchema().getName()).get(testSslUuid);
1333         SSL monitoredSsl = getClient().getTypedRowWrapper(SSL.class, sslRow);
1334         assertEquals(ssl.getExternalIdsColumn().getData(), monitoredSsl.getExternalIdsColumn().getData());
1335     }
1336
1337     public void sslDelete () throws ExecutionException, InterruptedException {
1338         SSL ssl = getClient().getTypedRowWrapper(SSL.class, null);
1339         OpenVSwitch openVSwitch = getClient().getTypedRowWrapper(OpenVSwitch.class, null);
1340
1341         TransactionBuilder transactionBuilder = getClient().transactBuilder(getDbSchema())
1342                 .add(op.delete(ssl.getSchema())
1343                         .where(ssl.getUuidColumn().getSchema().opEqual(testSslUuid))
1344                         .build())
1345                 .add(op.comment("SSL: Deleting " + testSslUuid))
1346                 .add(op.mutate(openVSwitch.getSchema())
1347                         .addMutation(openVSwitch.getSslColumn().getSchema(), Mutator.DELETE,
1348                                 Sets.newHashSet(testSslUuid)))
1349                 .add(op.comment("Open_vSwitch: Mutating " + testSslUuid))
1350                 .add(op.commit(true));
1351
1352         executeTransaction(transactionBuilder, "SSL delete operation results");
1353     }
1354
1355     @Test
1356     public void testSsl () throws ExecutionException, InterruptedException {
1357         sslInsert();
1358         sslDelete();
1359     }
1360
1361     @Test
1362     public void testTyperUtilsSpecialMethodsToString () {
1363         Bridge bridge = getClient().createTypedRowWrapper(Bridge.class);
1364         assertNotNull(bridge);
1365         bridge.setName(TEST_BRIDGE_NAME);
1366         bridge.setStatus(ImmutableMap.of("key", "value"));
1367         bridge.setFloodVlans(Sets.newHashSet(34L));
1368         assertNotNull(bridge.toString());
1369
1370         Bridge nullRowBridge = getClient().getTypedRowWrapper(Bridge.class, null);
1371         assertNotNull(nullRowBridge.toString());
1372     }
1373
1374     @Test
1375     public void testTyperUtilsSpecialMethodsEquals () {
1376         Bridge bridge = getClient().createTypedRowWrapper(Bridge.class);
1377         assertNotNull(bridge);
1378         bridge.setName(TEST_BRIDGE_NAME);
1379         bridge.setStatus(ImmutableMap.of("key", "value"));
1380         bridge.setFloodVlans(Sets.newHashSet(34L));
1381
1382         assertTrue("Equals check on same Bridge object", bridge.equals(bridge));
1383
1384         Bridge bridge2 = getClient().createTypedRowWrapper(Bridge.class);
1385         assertNotNull(bridge2);
1386         bridge2.setName(bridge.getName());
1387         bridge2.setStatus(bridge.getStatusColumn().getData());
1388         bridge2.setFloodVlans(bridge.getFloodVlansColumn().getData());
1389
1390         assertTrue("Equals check for different Bridge objects with same content", bridge.equals(bridge2));
1391
1392         bridge2.setStpEnable(true);
1393         assertFalse("Equals check for different Bridge objects with different content", bridge.equals(bridge2));
1394
1395         Port port = getClient().createTypedRowWrapper(Port.class);
1396         port.setName(bridge.getName());
1397         assertFalse("Equals check for a Bridge object and Port Object", bridge.equals(port));
1398         assertFalse("Equals check for a Typed Proxy object and non-proxy object", port.equals("String"));
1399
1400         Bridge nullRowBridge = getClient().getTypedRowWrapper(Bridge.class, null);
1401         assertTrue("Equals check on Bridge object with null Row", nullRowBridge.equals(nullRowBridge));
1402     }
1403
1404     @Test
1405     public void testTyperUtilsSpecialMethodsHashCode () {
1406         Bridge bridge = getClient().createTypedRowWrapper(Bridge.class);
1407
1408         assertNotNull(bridge);
1409         bridge.setName(TEST_BRIDGE_NAME);
1410         bridge.setStatus(ImmutableMap.of("key", "value"));
1411         bridge.setFloodVlans(Sets.newHashSet(34L));
1412
1413         assertNotSame(bridge.hashCode(), 0);
1414         Bridge nullRowBridge = getClient().getTypedRowWrapper(Bridge.class, null);
1415         assertSame(nullRowBridge.hashCode(), 0);
1416     }
1417 }