Committed by
Gerrit Code Review
Vnet STC (setup tenant and vnet* and subsequent teardown)
Change-Id: I65287aa840dfb910b9919c30449e69d195d2306d
Showing
4 changed files
with
206 additions
and
0 deletions
tools/test/bin/onos-check-vnet
0 → 100755
| 1 | +#!/bin/bash | ||
| 2 | +# ----------------------------------------------------------------------------- | ||
| 3 | +# Checks vnet related entities (tenantId, networkId). | ||
| 4 | +# ----------------------------------------------------------------------------- | ||
| 5 | + | ||
| 6 | +[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 | ||
| 7 | +. $ONOS_ROOT/tools/build/envDefaults | ||
| 8 | + | ||
| 9 | +aux=/tmp/stc-$$.log | ||
| 10 | +trap "rm -f $aux 2>/dev/null" EXIT | ||
| 11 | +target=${1:-$OCI} | ||
| 12 | +command_name=`basename $0` | ||
| 13 | + | ||
| 14 | +# Prints usage help | ||
| 15 | +function usage { | ||
| 16 | + echo "usage: $command_name <node-ip> checkTenant <tenantId>" >&2 | ||
| 17 | + echo " $command_name <node-ip> getNetworkId <tenantId>" >&2 | ||
| 18 | +} | ||
| 19 | + | ||
| 20 | +# Extracts networkId | ||
| 21 | +function extractAndPublishNetworkId() { | ||
| 22 | + for token in $aString | ||
| 23 | + do | ||
| 24 | + if [[ $token =~ "networkId=" ]] | ||
| 25 | + then | ||
| 26 | + echo "@stc $token" | ||
| 27 | + exit 0 | ||
| 28 | + fi | ||
| 29 | + done | ||
| 30 | + return 1 | ||
| 31 | +} | ||
| 32 | + | ||
| 33 | +echo $command_name: $* | ||
| 34 | +[ $# -lt 3 ] || [ "$1" = "-h" ] && usage && exit 0 | ||
| 35 | + | ||
| 36 | +case "$2" in | ||
| 37 | + "checkTenant") | ||
| 38 | + onos $target "vnet-tenants" | tee $aux | ||
| 39 | + grep -w $3 $aux && exit 0 | ||
| 40 | + ;; | ||
| 41 | + "getNetworkId") | ||
| 42 | + onos $target "vnets" | tee $aux | ||
| 43 | + aString=`grep "tenantId=$3," $aux | tail -1` #get last row | ||
| 44 | + extractAndPublishNetworkId && exit 0 | ||
| 45 | + ;; | ||
| 46 | + *) | ||
| 47 | + usage | ||
| 48 | + ;; | ||
| 49 | +esac | ||
| 50 | + | ||
| 51 | +cat $aux | ||
| 52 | +exit 1 | ||
| 53 | + |
tools/test/scenarios/net-setup-vnets.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 | +<scenario name="net-setup-vnets" description="Network (vnets) setup steps"> | ||
| 17 | + <group name="Net-Setup-Vnets"> | ||
| 18 | + | ||
| 19 | + <step name="Disable-FwdApp" if="echo $ONOS_APPS | grep -w fwd" | ||
| 20 | + exec="onos ${OCI} onos:app deactivate org.onosproject.fwd"/> | ||
| 21 | + | ||
| 22 | + <step name="Get-TenantId" requires="^" unless="${tenantId}" | ||
| 23 | + exec="echo @stc tenantId=TestTenant"/> | ||
| 24 | + | ||
| 25 | + <step name="Create-Tenant" requires="^" | ||
| 26 | + exec="onos ${OCI} vnet-add-tenant ${tenantId}"/> | ||
| 27 | + | ||
| 28 | + <step name="Query-Tenant" requires="^" | ||
| 29 | + exec="onos-check-vnet ${OCI} checkTenant ${tenantId}"/> | ||
| 30 | + | ||
| 31 | + <step name="Create-Vnet" requires="^" | ||
| 32 | + exec="onos ${OCI} vnet-create ${tenantId}"/> | ||
| 33 | + | ||
| 34 | + <step name="Query-Vnet" requires="^" | ||
| 35 | + exec="onos-check-vnet ${OCI} getNetworkId ${tenantId}"/> | ||
| 36 | + | ||
| 37 | + <step name="Create-Device-1" requires="^" | ||
| 38 | + exec="onos ${OCI} vnet-create-device ${networkId} device1"/> | ||
| 39 | + | ||
| 40 | + <step name="Create-Device-2" requires="^" | ||
| 41 | + exec="onos ${OCI} vnet-create-device ${networkId} device2"/> | ||
| 42 | + | ||
| 43 | + <step name="Create-Port-1" requires="^" | ||
| 44 | + exec="onos ${OCI} vnet-create-port ${networkId} device1 1 of:0000000000000004 1"/> | ||
| 45 | + | ||
| 46 | + <step name="Create-Port-2" requires="^" | ||
| 47 | + exec="onos ${OCI} vnet-create-port ${networkId} device2 2 of:0000000000000009 1"/> | ||
| 48 | + | ||
| 49 | + <step name="Create-Link-1" requires="^" | ||
| 50 | + exec="onos ${OCI} vnet-create-link ${networkId} device1 1 device2 2"/> | ||
| 51 | + | ||
| 52 | + <step name="Create-Link-2" requires="^" | ||
| 53 | + exec="onos ${OCI} vnet-create-link ${networkId} device2 2 device1 1"/> | ||
| 54 | + | ||
| 55 | + <step name="Check-intents-installed" requires="^" env="~" | ||
| 56 | + exec="onos-check-intent ${OCI} networkId=${networkId} INSTALLED"/> | ||
| 57 | + <!-- TODO: ignore return code once intent is working --> | ||
| 58 | + | ||
| 59 | + <step name="Ping-hosts-1" requires="^" env="~" | ||
| 60 | + exec="onos-mininet sendAndExpect h4 ping -c1 h9 --expect \ 0% packet loss"/> | ||
| 61 | + <!-- TODO: ignore return code once intent is working --> | ||
| 62 | + | ||
| 63 | + </group> | ||
| 64 | +</scenario> |
tools/test/scenarios/net-teardown-vnets.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 | +<scenario name="net-teardown-vnets" description="Network (vnets) teardown steps"> | ||
| 17 | + <group name="Net-Teardown-Vnets"> | ||
| 18 | + | ||
| 19 | + <step name="Check-NetworkId-Variable-Exists" | ||
| 20 | + exec="test '${networkId}' != ''"/> | ||
| 21 | + | ||
| 22 | + <step name="Check-Vnet-Link" requires="^" | ||
| 23 | + exec="onos ${OCI} vnet-links ${networkId}"/> | ||
| 24 | + | ||
| 25 | + <step name="Remove-Link-1" requires="^" | ||
| 26 | + exec="onos ${OCI} vnet-remove-link ${networkId} device1 1 device2 2"/> | ||
| 27 | + | ||
| 28 | + <step name="Remove-Link-2" requires="^" | ||
| 29 | + exec="onos ${OCI} vnet-remove-link ${networkId} device2 2 device1 1"/> | ||
| 30 | + | ||
| 31 | + <step name="Ping-hosts-2" requires="^" | ||
| 32 | + exec="onos-mininet sendAndExpect h4 ping -c1 h9 --expect \ 100% packet loss"/> | ||
| 33 | + | ||
| 34 | + <step name="Remove-Port-2" requires="^" | ||
| 35 | + exec="onos ${OCI} vnet-remove-port ${networkId} device2 2"/> | ||
| 36 | + | ||
| 37 | + <step name="Remove-Port-1" requires="^" | ||
| 38 | + exec="onos ${OCI} vnet-remove-port ${networkId} device1 1"/> | ||
| 39 | + | ||
| 40 | + <step name="Remove-Device-2" requires="^" | ||
| 41 | + exec="onos ${OCI} vnet-remove-device ${networkId} device2"/> | ||
| 42 | + | ||
| 43 | + <step name="Remove-Device-1" requires="^" | ||
| 44 | + exec="onos ${OCI} vnet-remove-device ${networkId} device1"/> | ||
| 45 | + | ||
| 46 | + <step name="Remove-Vnet" requires="^" | ||
| 47 | + exec="onos ${OCI} vnet-remove ${networkId}"/> | ||
| 48 | + | ||
| 49 | + <step name="Check-TenantId-Variable-Exists" requires="^" | ||
| 50 | + exec="test '${tenantId}' != ''"/> | ||
| 51 | + | ||
| 52 | + <step name="Remove-Tenant" requires="Check-TenantId-Variable-Exists" | ||
| 53 | + exec="onos ${OCI} vnet-remove-tenant ${tenantId}"/> | ||
| 54 | + | ||
| 55 | + <step name="Enable-FwdApp" requires="^" if="echo $ONOS_APPS | grep -w fwd" | ||
| 56 | + exec="onos ${OCI} onos:app activate org.onosproject.fwd"/> | ||
| 57 | + | ||
| 58 | + </group> | ||
| 59 | +</scenario> |
tools/test/scenarios/vnets.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 | +<scenario name="vnets" description="ONOS vnets test"> | ||
| 17 | + | ||
| 18 | + <import file="${ONOS_SCENARIOS}/net-setup.xml"/> | ||
| 19 | + | ||
| 20 | + <import file="${ONOS_SCENARIOS}/net-setup-vnets.xml"/> | ||
| 21 | + <dependency name="Net-Setup-Vnets" requires="Net-Setup"/> | ||
| 22 | + | ||
| 23 | + <import file="${ONOS_SCENARIOS}/net-teardown-vnets.xml"/> | ||
| 24 | + <dependency name="Net-Teardown-Vnets" requires="Net-Setup-Vnets"/> | ||
| 25 | + | ||
| 26 | + <import file="${ONOS_SCENARIOS}/net-teardown.xml"/> | ||
| 27 | + <dependency name="Net-Teardown" requires="Net-Teardown-Vnets"/> | ||
| 28 | + | ||
| 29 | +</scenario> | ||
| 30 | + |
-
Please register or login to post a comment