Initial stc tests for distributed primitives
Change-Id: I82a2911df9a4852cb851732e220d498f9332e005
Showing
9 changed files
with
604 additions
and
0 deletions
1 | +/* | ||
2 | + * Copyright 2016-present Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.distributedprimitives.cli; | ||
17 | + | ||
18 | +import org.apache.karaf.shell.commands.Argument; | ||
19 | +import org.apache.karaf.shell.commands.Command; | ||
20 | +import org.onosproject.cli.AbstractShellCommand; | ||
21 | +import org.onosproject.store.serializers.KryoNamespaces; | ||
22 | +import org.onosproject.store.service.ConsistentMap; | ||
23 | +import org.onosproject.store.service.Serializer; | ||
24 | +import org.onosproject.store.service.StorageService; | ||
25 | +import org.onosproject.store.service.Versioned; | ||
26 | + | ||
27 | +/** | ||
28 | + * CLI command to manipulate a distributed value. | ||
29 | + */ | ||
30 | +@Command(scope = "onos", name = "map-test", | ||
31 | + description = "Manipulate a consistent map") | ||
32 | +public class ConsistentMapTestCommand extends AbstractShellCommand { | ||
33 | + | ||
34 | + @Argument(index = 0, name = "name", | ||
35 | + description = "map name", | ||
36 | + required = true, multiValued = false) | ||
37 | + String name = null; | ||
38 | + | ||
39 | + @Argument(index = 1, name = "operation", | ||
40 | + description = "operation name", | ||
41 | + required = true, multiValued = false) | ||
42 | + String operation = null; | ||
43 | + | ||
44 | + @Argument(index = 2, name = "key", | ||
45 | + description = "first arg", | ||
46 | + required = false, multiValued = false) | ||
47 | + String arg1 = null; | ||
48 | + | ||
49 | + @Argument(index = 3, name = "value1", | ||
50 | + description = "second arg", | ||
51 | + required = false, multiValued = false) | ||
52 | + String arg2 = null; | ||
53 | + | ||
54 | + @Argument(index = 4, name = "value2", | ||
55 | + description = "third arg", | ||
56 | + required = false, multiValued = false) | ||
57 | + String arg3 = null; | ||
58 | + | ||
59 | + ConsistentMap<String, String> map; | ||
60 | + | ||
61 | + @Override | ||
62 | + protected void execute() { | ||
63 | + StorageService storageService = get(StorageService.class); | ||
64 | + map = storageService.<String, String>consistentMapBuilder() | ||
65 | + .withName(name) | ||
66 | + .withSerializer(Serializer.using(KryoNamespaces.BASIC)) | ||
67 | + .build(); | ||
68 | + if (operation.equals("get")) { | ||
69 | + print(map.get(arg1)); | ||
70 | + } else if (operation.equals("put")) { | ||
71 | + print(map.put(arg1, arg2)); | ||
72 | + } else if (operation.equals("size")) { | ||
73 | + print("%d", map.size()); | ||
74 | + } else if (operation.equals("isEmpty")) { | ||
75 | + print("%b", map.isEmpty()); | ||
76 | + } else if (operation.equals("putIfAbsent")) { | ||
77 | + print(map.putIfAbsent(arg1, arg2)); | ||
78 | + } else if (operation.equals("putAndGet")) { | ||
79 | + print(map.putAndGet(arg1, arg2)); | ||
80 | + } else if (operation.equals("clear")) { | ||
81 | + map.clear(); | ||
82 | + } else if (operation.equals("remove")) { | ||
83 | + if (arg2 == null) { | ||
84 | + print(map.remove(arg1)); | ||
85 | + } else { | ||
86 | + print("%b", map.remove(arg1, arg2)); | ||
87 | + } | ||
88 | + } else if (operation.equals("containsKey")) { | ||
89 | + print("%b", map.containsKey(arg1)); | ||
90 | + } else if (operation.equals("containsValue")) { | ||
91 | + print("%b", map.containsValue(arg1)); | ||
92 | + } else if (operation.equals("replace")) { | ||
93 | + if (arg3 == null) { | ||
94 | + print(map.replace(arg1, arg2)); | ||
95 | + } else { | ||
96 | + print("%b", map.replace(arg1, arg2, arg3)); | ||
97 | + } | ||
98 | + } | ||
99 | + } | ||
100 | + | ||
101 | + void print(Versioned<String> value) { | ||
102 | + if (value == null) { | ||
103 | + print("null"); | ||
104 | + } else { | ||
105 | + print("%s", value.value()); | ||
106 | + } | ||
107 | + } | ||
108 | +} |
1 | +/* | ||
2 | + * Copyright 2016-present Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.distributedprimitives.cli; | ||
17 | + | ||
18 | +import org.apache.karaf.shell.commands.Argument; | ||
19 | +import org.apache.karaf.shell.commands.Command; | ||
20 | +import org.onosproject.cli.AbstractShellCommand; | ||
21 | +import org.onosproject.store.service.AtomicCounter; | ||
22 | +import org.onosproject.store.service.StorageService; | ||
23 | + | ||
24 | +/** | ||
25 | + * CLI command to increment a distributed counter. | ||
26 | + */ | ||
27 | +@Command(scope = "onos", name = "counter-test", | ||
28 | + description = "Manipulate a distributed counter") | ||
29 | +public class CounterTestCommand extends AbstractShellCommand { | ||
30 | + | ||
31 | + @Argument(index = 0, name = "counter", | ||
32 | + description = "Counter name", | ||
33 | + required = true, multiValued = false) | ||
34 | + String counter = null; | ||
35 | + | ||
36 | + @Argument(index = 1, name = "operation", | ||
37 | + description = "operation name", | ||
38 | + required = true, multiValued = false) | ||
39 | + String operation = null; | ||
40 | + | ||
41 | + @Argument(index = 2, name = "value1", | ||
42 | + description = "first arg", | ||
43 | + required = false, multiValued = false) | ||
44 | + Long value1 = null; | ||
45 | + | ||
46 | + @Argument(index = 3, name = "value2", | ||
47 | + description = "second arg", | ||
48 | + required = false, multiValued = false) | ||
49 | + Long value2 = null; | ||
50 | + | ||
51 | + AtomicCounter atomicCounter; | ||
52 | + | ||
53 | + @Override | ||
54 | + protected void execute() { | ||
55 | + StorageService storageService = get(StorageService.class); | ||
56 | + atomicCounter = storageService.getAsyncAtomicCounter(counter).asAtomicCounter(); | ||
57 | + if (operation.equals("get")) { | ||
58 | + print("%d", atomicCounter.get()); | ||
59 | + } else if (operation.equals("set")) { | ||
60 | + atomicCounter.set(value1); | ||
61 | + } else if (operation.equals("incrementAndGet")) { | ||
62 | + print("%d", atomicCounter.incrementAndGet()); | ||
63 | + } else if (operation.equals("getAndIncrement")) { | ||
64 | + print("%d", atomicCounter.getAndIncrement()); | ||
65 | + } else if (operation.equals("getAndAdd")) { | ||
66 | + print("%d", atomicCounter.getAndAdd(value1)); | ||
67 | + } else if (operation.equals("addAndGet")) { | ||
68 | + print("%d", atomicCounter.addAndGet(value1)); | ||
69 | + } else if (operation.equals("compareAndSet")) { | ||
70 | + print("%b", atomicCounter.compareAndSet(value1, value2)); | ||
71 | + } else if (operation.equals("destroy")) { | ||
72 | + atomicCounter.destroy(); | ||
73 | + } | ||
74 | + } | ||
75 | +} |
1 | +package org.onosproject.distributedprimitives.cli; | ||
2 | + | ||
3 | +import org.apache.karaf.shell.commands.Argument; | ||
4 | +import org.apache.karaf.shell.commands.Command; | ||
5 | +import org.onosproject.cli.AbstractShellCommand; | ||
6 | +import org.onosproject.cluster.ClusterService; | ||
7 | +import org.onosproject.cluster.Leadership; | ||
8 | +import org.onosproject.cluster.NodeId; | ||
9 | +import org.onosproject.store.service.LeaderElector; | ||
10 | +import org.onosproject.store.service.StorageService; | ||
11 | + | ||
12 | +import com.google.common.base.Joiner; | ||
13 | + | ||
14 | +@Command(scope = "onos", name = "leader-test", | ||
15 | +description = "LeaderElector test cli fixture") | ||
16 | +public class LeaderElectorTestCommand extends AbstractShellCommand { | ||
17 | + @Argument(index = 0, name = "name", | ||
18 | + description = "leader elector name", | ||
19 | + required = true, multiValued = false) | ||
20 | + String name = null; | ||
21 | + | ||
22 | + @Argument(index = 1, name = "operation", | ||
23 | + description = "operation", | ||
24 | + required = true, multiValued = false) | ||
25 | + String operation = null; | ||
26 | + | ||
27 | + | ||
28 | + @Argument(index = 2, name = "topic", | ||
29 | + description = "topic name", | ||
30 | + required = false, multiValued = false) | ||
31 | + String topic = null; | ||
32 | + | ||
33 | + LeaderElector leaderElector; | ||
34 | + | ||
35 | + @Override | ||
36 | + protected void execute() { | ||
37 | + StorageService storageService = get(StorageService.class); | ||
38 | + ClusterService clusterService = get(ClusterService.class); | ||
39 | + NodeId localNodeId = clusterService.getLocalNode().id(); | ||
40 | + leaderElector = storageService.leaderElectorBuilder() | ||
41 | + .withName(name) | ||
42 | + .build() | ||
43 | + .asLeaderElector(); | ||
44 | + if (operation.equals("run")) { | ||
45 | + print(leaderElector.run(topic, localNodeId)); | ||
46 | + } else if (operation.equals("withdraw")) { | ||
47 | + leaderElector.withdraw(topic); | ||
48 | + } else if (operation.equals("show")) { | ||
49 | + print(leaderElector.getLeadership(topic)); | ||
50 | + } | ||
51 | + } | ||
52 | + | ||
53 | + private void print(Leadership leadership) { | ||
54 | + if (leadership.leader() != null) { | ||
55 | + print("leader=%s#term=%d#candidates=%s", | ||
56 | + leadership.leaderNodeId(), | ||
57 | + leadership.leader().term(), | ||
58 | + leadership.candidates().isEmpty() ? "none" : Joiner.on(",").join(leadership.candidates())); | ||
59 | + } else { | ||
60 | + print("leader=none#candidates=%s", | ||
61 | + leadership.candidates().isEmpty() ? "none" : Joiner.on(",").join(leadership.candidates())); | ||
62 | + } | ||
63 | + } | ||
64 | +} |
1 | +/* | ||
2 | + * Copyright 2016-present Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.distributedprimitives.cli; | ||
17 | + | ||
18 | +import org.apache.karaf.shell.commands.Argument; | ||
19 | +import org.apache.karaf.shell.commands.Command; | ||
20 | +import org.onosproject.cli.AbstractShellCommand; | ||
21 | +import org.onosproject.store.serializers.KryoNamespaces; | ||
22 | +import org.onosproject.store.service.AtomicValue; | ||
23 | +import org.onosproject.store.service.Serializer; | ||
24 | +import org.onosproject.store.service.StorageService; | ||
25 | + | ||
26 | +/** | ||
27 | + * CLI command to manipulate a distributed value. | ||
28 | + */ | ||
29 | +@Command(scope = "onos", name = "value-test", | ||
30 | + description = "Manipulate a distributed value") | ||
31 | +public class ValueTestCommand extends AbstractShellCommand { | ||
32 | + | ||
33 | + @Argument(index = 0, name = "value", | ||
34 | + description = "Value name", | ||
35 | + required = true, multiValued = false) | ||
36 | + String value = null; | ||
37 | + | ||
38 | + @Argument(index = 1, name = "operation", | ||
39 | + description = "operation name", | ||
40 | + required = true, multiValued = false) | ||
41 | + String operation = null; | ||
42 | + | ||
43 | + @Argument(index = 2, name = "value1", | ||
44 | + description = "first arg", | ||
45 | + required = false, multiValued = false) | ||
46 | + String value1 = null; | ||
47 | + | ||
48 | + @Argument(index = 3, name = "value2", | ||
49 | + description = "second arg", | ||
50 | + required = false, multiValued = false) | ||
51 | + String value2 = null; | ||
52 | + | ||
53 | + AtomicValue<String> atomicValue; | ||
54 | + | ||
55 | + @Override | ||
56 | + protected void execute() { | ||
57 | + StorageService storageService = get(StorageService.class); | ||
58 | + atomicValue = storageService.<String>atomicValueBuilder() | ||
59 | + .withName(value) | ||
60 | + .withSerializer(Serializer.using(KryoNamespaces.BASIC)) | ||
61 | + .build() | ||
62 | + .asAtomicValue(); | ||
63 | + if (operation.equals("get")) { | ||
64 | + print("%s", atomicValue.get()); | ||
65 | + } else if (operation.equals("set")) { | ||
66 | + atomicValue.set(value1); | ||
67 | + } else if (operation.equals("compareAndSet")) { | ||
68 | + print("%b", atomicValue.compareAndSet(value1, value2)); | ||
69 | + } else if (operation.equals("destroy")) { | ||
70 | + atomicValue.destroy(); | ||
71 | + } | ||
72 | + } | ||
73 | +} |
... | @@ -34,6 +34,18 @@ | ... | @@ -34,6 +34,18 @@ |
34 | <command> | 34 | <command> |
35 | <action class="org.onosproject.distributedprimitives.cli.TransactionalMapTestPutCommand"/> | 35 | <action class="org.onosproject.distributedprimitives.cli.TransactionalMapTestPutCommand"/> |
36 | </command> | 36 | </command> |
37 | + <command> | ||
38 | + <action class="org.onosproject.distributedprimitives.cli.CounterTestCommand"/> | ||
39 | + </command> | ||
40 | + <command> | ||
41 | + <action class="org.onosproject.distributedprimitives.cli.ConsistentMapTestCommand"/> | ||
42 | + </command> | ||
43 | + <command> | ||
44 | + <action class="org.onosproject.distributedprimitives.cli.ValueTestCommand"/> | ||
45 | + </command> | ||
46 | + <command> | ||
47 | + <action class="org.onosproject.distributedprimitives.cli.LeaderElectorTestCommand"/> | ||
48 | + </command> | ||
37 | </command-bundle> | 49 | </command-bundle> |
38 | 50 | ||
39 | </blueprint> | 51 | </blueprint> | ... | ... |
tools/test/scenarios/dist-counter.xml
0 → 100644
1 | +<!-- | ||
2 | + ~ Copyright 2016-present Open Networking Laboratory | ||
3 | + ~ | ||
4 | + ~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + ~ you may not use this file except in compliance with the License. | ||
6 | + ~ You may obtain a copy of the License at | ||
7 | + ~ | ||
8 | + ~ http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + ~ | ||
10 | + ~ Unless required by applicable law or agreed to in writing, software | ||
11 | + ~ distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + ~ See the License for the specific language governing permissions and | ||
14 | + ~ limitations under the License. | ||
15 | +--> | ||
16 | + | ||
17 | +<scenario name="distributed counter test" | ||
18 | + description="ONOS AtomicCounter distributed primitive Test"> | ||
19 | + <group name="Distributed-Primitive-Counter"> | ||
20 | + | ||
21 | + <!--<import file="${ONOS_SCENARIOS}/setup.xml"/> | ||
22 | + <dependency name="Setup" requires="Prerequisites"/>--> | ||
23 | + | ||
24 | + <step name="Activate-Distributed-Primitives-App" | ||
25 | + exec="onos ${OCI} app activate org.onosproject.distributedprimitives"/> | ||
26 | + | ||
27 | + <step name="Test-Counter-Initial-Value" requires="^" | ||
28 | + exec="onos-execute-expect ${OCI} counter-test test-counter get --expect 0"/> | ||
29 | + | ||
30 | + <step name="Test-Counter-Set" requires="^" | ||
31 | + exec="onos ${OCI} counter-test test-counter set 1"/> | ||
32 | + | ||
33 | + <step name="Test-Counter-Get" requires="^" | ||
34 | + exec="onos-execute-expect ${OCI} counter-test test-counter get --expect 1"/> | ||
35 | + | ||
36 | + <step name="Test-Counter-IncrementAndGet" requires="^" | ||
37 | + exec="onos-execute-expect ${OCI} counter-test test-counter incrementAndGet --expect 2"/> | ||
38 | + | ||
39 | + <step name="Test-Counter-GetAndIncrement" requires="^" | ||
40 | + exec="onos-execute-expect ${OCI} counter-test test-counter getAndIncrement --expect 2"/> | ||
41 | + | ||
42 | + <step name="Test-Counter-Incremented" requires="^" | ||
43 | + exec="onos-execute-expect ${OCI} counter-test test-counter get --expect 3"/> | ||
44 | + | ||
45 | + <step name="Test-Counter-AddAndGet" requires="^" | ||
46 | + exec="onos-execute-expect ${OCI} counter-test test-counter addAndGet 10 --expect 13"/> | ||
47 | + | ||
48 | + <step name="Test-Counter-GetAndAdd" requires="^" | ||
49 | + exec="onos-execute-expect ${OCI} counter-test test-counter getAndAdd 10 --expect 13"/> | ||
50 | + | ||
51 | + <step name="Test-Counter-Updated-After-GetAndAdd" requires="^" | ||
52 | + exec="onos-execute-expect ${OCI} counter-test test-counter get --expect 23"/> | ||
53 | + | ||
54 | + <step name="Test-Counter-CompareAndSet-False" requires="^" | ||
55 | + exec="onos-execute-expect ${OCI} counter-test test-counter compareAndSet 1 2 --expect false"/> | ||
56 | + | ||
57 | + <step name="Test-Counter-Not-Updated-After-CAS" requires="^" | ||
58 | + exec="onos-execute-expect ${OCI} counter-test test-counter get --expect 23"/> | ||
59 | + | ||
60 | + <step name="Test-Counter-CompareAndSet-True" requires="^" | ||
61 | + exec="onos-execute-expect ${OCI} counter-test test-counter compareAndSet 23 25 --expect true"/> | ||
62 | + | ||
63 | + <step name="Test-Counter-Updated-After-CAS" requires="^" | ||
64 | + exec="onos-execute-expect ${OCI} counter-test test-counter get --expect 25"/> | ||
65 | + | ||
66 | + <!--Check with check logs--> | ||
67 | + <step name="Check-Log-Exceptions" requires="^" | ||
68 | + exec="onos-check-logs ${OCI}"/> | ||
69 | + | ||
70 | + <step name="Teardown-Distributed-Primitives-Test-App" requires="^" | ||
71 | + exec="onos ${OCI} app deactivate org.onosproject.distributedprimitives"/> | ||
72 | + </group> | ||
73 | +</scenario> | ||
74 | + |
tools/test/scenarios/dist-leader.xml
0 → 100644
1 | +<!-- | ||
2 | + ~ Copyright 2016-present Open Networking Laboratory | ||
3 | + ~ | ||
4 | + ~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + ~ you may not use this file except in compliance with the License. | ||
6 | + ~ You may obtain a copy of the License at | ||
7 | + ~ | ||
8 | + ~ http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + ~ | ||
10 | + ~ Unless required by applicable law or agreed to in writing, software | ||
11 | + ~ distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + ~ See the License for the specific language governing permissions and | ||
14 | + ~ limitations under the License. | ||
15 | +--> | ||
16 | + | ||
17 | +<scenario name="distributed leader elector test" | ||
18 | + description="ONOS LeaderElector distributed primitive Test"> | ||
19 | + <group name="Distributed-Primitive-Value"> | ||
20 | + | ||
21 | + <!--<import file="${ONOS_SCENARIOS}/setup.xml"/> | ||
22 | + <dependency name="Setup" requires="Prerequisites"/>--> | ||
23 | + | ||
24 | + <step name="Activate-Distributed-Primitives-App" | ||
25 | + exec="onos ${OCI} app activate org.onosproject.distributedprimitives"/> | ||
26 | + | ||
27 | + <step name="Test-Initial-No-Leader" requires="^" | ||
28 | + exec="onos-execute-expect ${OCI} leader-test test-elector show foo --expect leader=none#candidates=none"/> | ||
29 | + | ||
30 | + <step name="Test-Leader-Run" requires="^" | ||
31 | + exec="onos-execute-expect ${OCI} leader-test test-elector run foo --expect leader=${OCI}#term=1#candidates=${OCI}"/> | ||
32 | + | ||
33 | + <step name="Test-Leader-Withdraw" requires="^" | ||
34 | + exec="onos ${OCI} leader-test test-elector withdraw foo"/> | ||
35 | + | ||
36 | + <step name="Test-No-Leader-After-Withdraw" requires="^" | ||
37 | + exec="onos-execute-expect ${OCI} leader-test test-elector show foo --expect leader=none#candidates=none"/> | ||
38 | + | ||
39 | + <!--Check with check logs--> | ||
40 | + <step name="Check-Log-Exceptions" requires="^" | ||
41 | + exec="onos-check-logs ${OCI}"/> | ||
42 | + | ||
43 | + <step name="Teardown-Distributed-Primitives-Test-App" requires="^" | ||
44 | + exec="onos ${OCI} app deactivate org.onosproject.distributedprimitives"/> | ||
45 | + </group> | ||
46 | +</scenario> | ||
47 | + |
tools/test/scenarios/dist-map.xml
0 → 100644
1 | +<!-- | ||
2 | + ~ Copyright 2016-present Open Networking Laboratory | ||
3 | + ~ | ||
4 | + ~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + ~ you may not use this file except in compliance with the License. | ||
6 | + ~ You may obtain a copy of the License at | ||
7 | + ~ | ||
8 | + ~ http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + ~ | ||
10 | + ~ Unless required by applicable law or agreed to in writing, software | ||
11 | + ~ distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + ~ See the License for the specific language governing permissions and | ||
14 | + ~ limitations under the License. | ||
15 | +--> | ||
16 | + | ||
17 | +<scenario name="Distributed consistent map test" | ||
18 | + description="ONOS ConsistentMap distributed primitive Test"> | ||
19 | + <group name="Distributed-Primitive-Map"> | ||
20 | + | ||
21 | + <!--<import file="${ONOS_SCENARIOS}/setup.xml"/> | ||
22 | + <dependency name="Setup" requires="Prerequisites"/>--> | ||
23 | + | ||
24 | + <step name="Activate-Distributed-Primitives-App" | ||
25 | + exec="onos ${OCI} app activate org.onosproject.distributedprimitives"/> | ||
26 | + | ||
27 | + <step name="Test-Map-Get" requires="^" | ||
28 | + exec="onos-execute-expect ${OCI} map-test foo get a --expect null"/> | ||
29 | + | ||
30 | + <step name="Test-Map-Put" requires="^" | ||
31 | + exec="onos-execute-expect ${OCI} map-test foo put a b --expect null"/> | ||
32 | + | ||
33 | + <step name="Test-Map-Updated-After-Put" requires="^" | ||
34 | + exec="onos-execute-expect ${OCI} map-test foo get a --expect b"/> | ||
35 | + | ||
36 | + <step name="Test-Map-PutIfAbsent-When-Key-Present" requires="^" | ||
37 | + exec="onos-execute-expect ${OCI} map-test foo putIfAbsent a c --expect b"/> | ||
38 | + | ||
39 | + <step name="Test-Map-PutIfAbsent-When-Key-Absent" requires="^" | ||
40 | + exec="onos-execute-expect ${OCI} map-test foo putIfAbsent b c --expect null"/> | ||
41 | + | ||
42 | + <step name="Test-Map-Updated-After-PutIfAbsent" requires="^" | ||
43 | + exec="onos-execute-expect ${OCI} map-test foo get b --expect c"/> | ||
44 | + | ||
45 | + <step name="Test-Map-Updated-After-PutAndGet" requires="^" | ||
46 | + exec="onos-execute-expect ${OCI} map-test foo putAndGet b d --expect d"/> | ||
47 | + | ||
48 | + <step name="Test-Map-Replace-When-Key-Absent" requires="^" | ||
49 | + exec="onos-execute-expect ${OCI} map-test foo replace c e --expect null"/> | ||
50 | + | ||
51 | + <step name="Test-Map-Replace-When-Key-Present" requires="^" | ||
52 | + exec="onos-execute-expect ${OCI} map-test foo replace b e --expect d"/> | ||
53 | + | ||
54 | + <step name="Test-Map-Replace-When-Value-Does-Not-Match" requires="^" | ||
55 | + exec="onos-execute-expect ${OCI} map-test foo replace b x f --expect false"/> | ||
56 | + | ||
57 | + <step name="Test-Map-Replace-When-Value-Does-Match" requires="^" | ||
58 | + exec="onos-execute-expect ${OCI} map-test foo replace b e f --expect true"/> | ||
59 | + | ||
60 | + <step name="Test-Map-ContainsValue-False-Case" requires="^" | ||
61 | + exec="onos-execute-expect ${OCI} map-test foo containsValue x --expect false"/> | ||
62 | + | ||
63 | + <step name="Test-Map-ContainsValue-True-Case" requires="^" | ||
64 | + exec="onos-execute-expect ${OCI} map-test foo containsValue f --expect true"/> | ||
65 | + | ||
66 | + <step name="Test-Map-Size" requires="^" | ||
67 | + exec="onos-execute-expect ${OCI} map-test foo size --expect 2"/> | ||
68 | + | ||
69 | + <step name="Test-Map-IsEmpty" requires="^" | ||
70 | + exec="onos-execute-expect ${OCI} map-test foo isEmpty --expect false"/> | ||
71 | + | ||
72 | + <step name="Test-Map-Remove" requires="^" | ||
73 | + exec="onos-execute-expect ${OCI} map-test foo remove b --expect f"/> | ||
74 | + | ||
75 | + <step name="Test-Map-Remove-Key-Value-Does-Not-Match" requires="^" | ||
76 | + exec="onos-execute-expect ${OCI} map-test foo remove a c --expect false"/> | ||
77 | + | ||
78 | + <step name="Test-Map-Remove-Key-Value-Does-Match" requires="^" | ||
79 | + exec="onos-execute-expect ${OCI} map-test foo remove a b --expect true"/> | ||
80 | + | ||
81 | + <step name="Test-Map-Clear" requires="^" | ||
82 | + exec="onos ${OCI} map-test foo clear"/> | ||
83 | + | ||
84 | + <step name="Test-Map-Cleared" requires="^" | ||
85 | + exec="onos-execute-expect ${OCI} map-test foo isEmpty --expect true"/> | ||
86 | + | ||
87 | + <!--Check with check logs--> | ||
88 | + <step name="Check-Log-Exceptions" requires="^" | ||
89 | + exec="onos-check-logs ${OCI}"/> | ||
90 | + | ||
91 | + <step name="Teardown-Distributed-Primitives-Test-App" requires="^" | ||
92 | + exec="onos ${OCI} app deactivate org.onosproject.distributedprimitives"/> | ||
93 | + </group> | ||
94 | +</scenario> | ||
95 | + |
tools/test/scenarios/dist-value.xml
0 → 100644
1 | +<!-- | ||
2 | + ~ Copyright 2016-present Open Networking Laboratory | ||
3 | + ~ | ||
4 | + ~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + ~ you may not use this file except in compliance with the License. | ||
6 | + ~ You may obtain a copy of the License at | ||
7 | + ~ | ||
8 | + ~ http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + ~ | ||
10 | + ~ Unless required by applicable law or agreed to in writing, software | ||
11 | + ~ distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + ~ See the License for the specific language governing permissions and | ||
14 | + ~ limitations under the License. | ||
15 | +--> | ||
16 | + | ||
17 | +<scenario name="distributed value test" | ||
18 | + description="ONOS AtomicValue distributed primitive Test"> | ||
19 | + <group name="Distributed-Primitive-Value"> | ||
20 | + | ||
21 | + <!--<import file="${ONOS_SCENARIOS}/setup.xml"/> | ||
22 | + <dependency name="Setup" requires="Prerequisites"/>--> | ||
23 | + | ||
24 | + <step name="Activate-Distributed-Primitives-App" | ||
25 | + exec="onos ${OCI} app activate org.onosproject.distributedprimitives"/> | ||
26 | + | ||
27 | + <step name="Test-Value-Initial-Value" requires="^" | ||
28 | + exec="onos-execute-expect ${OCI} value-test test-value get --expect null"/> | ||
29 | + | ||
30 | + <step name="Test-Value-Set" requires="^" | ||
31 | + exec="onos ${OCI} value-test test-value set v0"/> | ||
32 | + | ||
33 | + <step name="Test-Value-Get" requires="^" | ||
34 | + exec="onos-execute-expect ${OCI} value-test test-value get --expect v0"/> | ||
35 | + | ||
36 | + <step name="Test-Value-CompareAndSet-False" requires="^" | ||
37 | + exec="onos-execute-expect ${OCI} value-test test-value compareAndSet v1 v2 --expect false"/> | ||
38 | + | ||
39 | + <step name="Test-Value-Not-Updated-After-CAS" requires="^" | ||
40 | + exec="onos-execute-expect ${OCI} value-test test-value get --expect v0"/> | ||
41 | + | ||
42 | + <step name="Test-Value-CompareAndSet-True" requires="^" | ||
43 | + exec="onos-execute-expect ${OCI} value-test test-value compareAndSet v0 v1 --expect true"/> | ||
44 | + | ||
45 | + <step name="Test-Value-Updated-After-CAS" requires="^" | ||
46 | + exec="onos-execute-expect ${OCI} value-test test-value get --expect v1"/> | ||
47 | + | ||
48 | + <!--Check with check logs--> | ||
49 | + <step name="Check-Log-Exceptions" requires="^" | ||
50 | + exec="onos-check-logs ${OCI}"/> | ||
51 | + | ||
52 | + <step name="Teardown-Distributed-Primitives-Test-App" requires="^" | ||
53 | + exec="onos ${OCI} app deactivate org.onosproject.distributedprimitives"/> | ||
54 | + </group> | ||
55 | +</scenario> | ||
56 | + |
-
Please register or login to post a comment