Scenario to test the CLI 'maps' command
This scenario is used as an example in the STC wiki page
Change-Id: Iaef719ee53c8ad9fa2ca467aee5cf23684855968
diff --git a/tools/test/scenarios/bin/onos-find-and-check-map b/tools/test/scenarios/bin/onos-find-and-check-map
new file mode 100755
index 0000000..b419ca1
--- /dev/null
+++ b/tools/test/scenarios/bin/onos-find-and-check-map
@@ -0,0 +1,36 @@
+#!/usr/bin/env python
+
+# -----------------------------------------------------------------------------
+# Invokes the ONOS CLI and looks for a 'maps' entry with the given name
+# -----------------------------------------------------------------------------
+
+import subprocess
+import json
+import sys
+
+if len(sys.argv) != 4:
+ print "usage: onos-find-and-check-map onos-node map-name should-be-zero"
+ sys.exit(1)
+
+node = sys.argv[1]
+mapName = sys.argv[2]
+shouldBeZero = sys.argv[3]
+
+cli = subprocess.Popen(["onos", node, "maps", "-j"], stdout=subprocess.PIPE)
+json = json.loads(cli.communicate()[0])
+
+for map in json:
+ foundMapName = map["name"]
+ foundMapSize = map["size"]
+
+ print foundMapName
+ print foundMapSize
+
+ if foundMapName == mapName:
+ if (shouldBeZero == 'yes' and foundMapSize == 0) or \
+ (shouldBeZero != 'yes' and foundMapSize != 0):
+ sys.exit(0)
+ else:
+ sys.exit(1)
+
+sys.exit(1)
diff --git a/tools/test/scenarios/bin/onos-find-map b/tools/test/scenarios/bin/onos-find-map
new file mode 100755
index 0000000..b84b1a1
--- /dev/null
+++ b/tools/test/scenarios/bin/onos-find-map
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+# -----------------------------------------------------------------------------
+# Invokes the ONOS CLI and looks for a 'maps' entry with the given name
+# -----------------------------------------------------------------------------
+
+NODE=$1
+MAP=$2
+ID=$3
+
+map_text=`( onos ${NODE} onos:maps ) | grep ${MAP}`
+
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+
+map_size=`echo ${map_text} | sed s#^.*size=##`
+echo "@stc ${ID}Size=${map_size}"
diff --git a/tools/test/scenarios/maps-cli.xml b/tools/test/scenarios/maps-cli.xml
new file mode 100644
index 0000000..a76bd1a
--- /dev/null
+++ b/tools/test/scenarios/maps-cli.xml
@@ -0,0 +1,42 @@
+<!--
+ ~ Copyright 2017-present Open Networking Laboratory
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<scenario name="maps-cli"
+ description="maps CLI command test">
+ <group name="Maps-Cli">
+
+ <!-- Shell script based checks -->
+ <!-- Check map known to have 0 entries -->
+ <step name="Maps-Cli.Find-Intent-Mapping-Shell"
+ exec="onos-find-map ${OCI} onos-intent-mapping intentMapping"/>
+ <step name="Maps-Cli.Check-Intent-Mapping-Shell" requires="^"
+ exec="test ${intentMappingSize} -eq 0"/>
+
+ <!-- Check map known to have at least 50 entries -->
+ <step name="Maps-Cli.Find-Intent-Mapping2-Shell"
+ exec="onos-find-map ${OCI} onos-app-ids appIdsMapping"/>
+ <step name="Maps-Cli.Check-App-Ids-Mapping-Shell" requires="^"
+ exec="test ${appIdsMappingSize} -gt 50"/>
+
+ <!-- Python based checks -->
+ <!-- Check map known to have 0 entries -->
+ <step name="Maps-Cli.Find-Intent-Mapping-Python"
+ exec="onos-find-and-check-map ${OCI} onos-intent-mapping yes"/>
+ <!-- Check map known to have more than 0 entries -->
+ <step name="Maps-Cli.Find-App-Id-Mapping"
+ exec="onos-find-and-check-map ${OCI} onos-app-ids no"/>
+
+ </group>
+</scenario>
diff --git a/tools/test/scenarios/smoke.xml b/tools/test/scenarios/smoke.xml
index 8981cd8..9c2a704 100644
--- a/tools/test/scenarios/smoke.xml
+++ b/tools/test/scenarios/smoke.xml
@@ -17,12 +17,14 @@
<import file="${ONOS_SCENARIOS}/prerequisites.xml"/>
<import file="${ONOS_SCENARIOS}/net-prerequisites.xml"/>
<import file="${ONOS_SCENARIOS}/setup.xml"/>
+ <import file="${ONOS_SCENARIOS}/maps-cli.xml"/>
<import file="${ONOS_SCENARIOS}/dist-test.xml"/>
<import file="${ONOS_SCENARIOS}/smoke-internal.xml"/>
<dependency name="Setup" requires="Prerequisites,Net-Prerequisites"/>
<dependency name="Net-Smoke" requires="Setup"/>
<dependency name="Archetypes" requires="Setup"/>
+ <dependency name="Maps-Cli" requires="Setup"/>
<dependency name="Drivers-Test" requires="Setup"/>
<dependency name="Meta-App" requires="Setup"/>
<dependency name="Netcfg" requires="Setup"/>