2 * Copyright (C) 2014 Red Hat, Inc.
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
10 package org.opendaylight.ovsdb.schema.openvswitch;
12 import com.google.common.collect.ImmutableMap;
13 import com.google.common.collect.Sets;
14 import com.google.common.util.concurrent.ListenableFuture;
15 import junit.framework.Assert;
16 import org.junit.Before;
17 import org.junit.Test;
19 import org.opendaylight.ovsdb.lib.message.UpdateNotification;
20 import org.opendaylight.ovsdb.lib.notation.Mutator;
21 import org.opendaylight.ovsdb.lib.notation.UUID;
22 import org.opendaylight.ovsdb.lib.operations.OperationResult;
23 import org.opendaylight.ovsdb.lib.operations.TransactionBuilder;
25 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory;
28 import java.io.IOException;
29 import java.util.List;
30 import java.util.concurrent.ExecutionException;
31 import java.util.concurrent.TimeoutException;
33 import static org.opendaylight.ovsdb.lib.operations.Operations.op;
36 public class ManagerTestCases extends OpenVswitchSchemaTestBase {
37 Logger logger = LoggerFactory.getLogger(ManagerTestCases.class);
40 public void setUp() throws ExecutionException, InterruptedException, TimeoutException, IOException {
45 public void testCreateTypedManagerTable() throws InterruptedException, ExecutionException, IllegalArgumentException {
47 String mgrUuidStr = "sslUuidName";
48 ImmutableMap<String, String> externalIds = ImmutableMap.of("slaveof", "themaster");
50 UUID openVSwitchRowUuid = this.getOpenVSwitchTableUuid(ovs, OpenVswitchSchemaSuiteIT.getTableCache());
51 OpenVSwitch openVSwitch = ovs.getTypedRowWrapper(OpenVSwitch.class, null);
53 Manager manager = ovs.createTypedRowWrapper(Manager.class);
54 manager.setInactivityProbe(Sets.newHashSet(8192L));
55 manager.setMaxBackoff(Sets.newHashSet(4094L));
56 manager.setTarget(Sets.newHashSet("172.16.50.50:6640"));
57 manager.setExternalIds(externalIds);
59 int insertSslOperationIndex = 0;
60 TransactionBuilder transactionBuilder = ovs.transactBuilder(OpenVswitchSchemaSuiteIT.dbSchema)
61 .add(op.insert(manager.getSchema())
63 .value(manager.getTargetColumn())
64 .value(manager.getInactivityProbeColumn())
65 .value(manager.getMaxBackoffColumn())
66 .value(manager.getExternalIdsColumn()))
67 .add(op.comment("Inserting Slave Manager"))
68 .add(op.mutate(openVSwitch.getSchema())
69 .addMutation(openVSwitch.getManagerOptionsColumn().getSchema(), Mutator.INSERT,
70 Sets.newHashSet(new UUID(mgrUuidStr)))
71 .where(openVSwitch.getUuidColumn().getSchema().opEqual(openVSwitchRowUuid))
74 ListenableFuture<List<OperationResult>> results = transactionBuilder.execute();
75 List<OperationResult> operationResults = results.get();
76 Assert.assertFalse(operationResults.isEmpty());
77 for (OperationResult result : operationResults) {
78 Assert.assertNull(result.getError());
80 // Store the returned SSL row UUID to be used in the TearDown deletion transaction
81 OpenVswitchSchemaSuiteIT.setTestManagerUuid(operationResults.get(insertSslOperationIndex).getUuid());
82 // Check if Results matches the number of operations in transaction
83 Assert.assertEquals(transactionBuilder.getOperations().size(), operationResults.size());
84 logger.info("Mutate operation results for Manager = {} ", operationResults);
89 public void update(Object context, UpdateNotification upadateNotification) {
94 public void locked(Object context, List<String> ids) {
99 public void stolen(Object context, List<String> ids) {