aboutsummaryrefslogtreecommitdiffstats
path: root/test/resources/libraries
diff options
context:
space:
mode:
Diffstat (limited to 'test/resources/libraries')
-rw-r--r--test/resources/libraries/bash/dut_setup.sh16
-rw-r--r--test/resources/libraries/python/DUTSetup.py40
-rw-r--r--test/resources/libraries/python/SetupFramework.py92
-rw-r--r--test/resources/libraries/python/VatExecutor.py84
-rw-r--r--test/resources/libraries/python/constants.py15
-rw-r--r--test/resources/libraries/python/ssh.py127
-rw-r--r--test/resources/libraries/python/topology.py50
-rw-r--r--test/resources/libraries/robot/default.robot20
-rw-r--r--test/resources/libraries/robot/interfaces.robot20
-rw-r--r--test/resources/libraries/robot/vat/interfaces.robot23
10 files changed, 0 insertions, 487 deletions
diff --git a/test/resources/libraries/bash/dut_setup.sh b/test/resources/libraries/bash/dut_setup.sh
deleted file mode 100644
index 1da8cc919b7..00000000000
--- a/test/resources/libraries/bash/dut_setup.sh
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/bash
-
-echo vpp process
-ps aux | grep vpp
-
-echo Free memory
-free -m
-
-echo List vpp packages
-dpkg -l \*vpp\*
-
-
-echo List /proc/meminfo
-cat /proc/meminfo
-
-
diff --git a/test/resources/libraries/python/DUTSetup.py b/test/resources/libraries/python/DUTSetup.py
deleted file mode 100644
index c09975f29ce..00000000000
--- a/test/resources/libraries/python/DUTSetup.py
+++ /dev/null
@@ -1,40 +0,0 @@
-# Copyright (c) 2015 Cisco and/or its affiliates.
-# 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.
-from robot.api import logger
-from topology import NodeType
-from ssh import SSH
-
-class DUTSetup(object):
-
- def __init__(self):
- pass
-
- def setup_all_duts(self, nodes):
- """Prepare all DUTs in given topology for test execution."""
- for node in nodes.values():
- if node['type'] == NodeType.DUT:
- self.setup_dut(node)
-
- def setup_dut(self, node):
- ssh = SSH()
- ssh.connect(node)
-
- ssh.scp('resources/libraries/bash/dut_setup.sh', '/tmp/dut_setup.sh')
- (ret_code, stdout, stderr) = \
- ssh.exec_command('sudo -Sn bash /tmp/dut_setup.sh')
- logger.trace(stdout)
- if 0 != int(ret_code):
- logger.error('DUT {0} setup script failed: "{1}"'.
- format(node['host'], stdout + stderr))
- raise Exception('DUT test setup script failed at node {}'.
- format(node['host']))
diff --git a/test/resources/libraries/python/SetupFramework.py b/test/resources/libraries/python/SetupFramework.py
deleted file mode 100644
index 8fd712f5388..00000000000
--- a/test/resources/libraries/python/SetupFramework.py
+++ /dev/null
@@ -1,92 +0,0 @@
-# Copyright (c) 2015 Cisco and/or its affiliates.
-# 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.
-import shlex
-from ssh import SSH
-from subprocess import Popen, PIPE, call
-from tempfile import NamedTemporaryFile
-from os.path import basename
-from constants import Constants as con
-from robot.api import logger
-
-__all__ = ["SetupFramework"]
-
-class SetupFramework(object):
- """Setup suite run on topology nodes.
-
- Many VAT/CLI based tests need the scripts at remote hosts before executing
- them. This class packs the whole testing directory and copies it over
- to all nodes in topology under /tmp/
-
- """
-
- def __init__(self):
- pass
-
- def __pack_framework_dir(self):
- """Pack the testing WS into temp file, return its name."""
-
- tmpfile = NamedTemporaryFile(suffix=".tgz", prefix="openvpp-testing-")
- file_name = tmpfile.name
- tmpfile.close()
-
- proc = Popen(shlex.split("tar -zcf {0} .".format(file_name)),
- stdout=PIPE, stderr=PIPE)
- (stdout, stderr) = proc.communicate()
-
- logger.debug(stdout)
- logger.debug(stderr)
-
- return_code = proc.wait()
- if 0 != return_code:
- raise Exception("Could not pack testing framework.")
-
- return file_name
-
- def __copy_tarball_to_node(self, tarball, node):
- logger.console('Copying tarball to {0}'.format(node['host']))
- ssh = SSH()
- ssh.connect(node)
-
- ssh.scp(tarball, "/tmp/")
-
- def __extract_tarball_at_node(self, tarball, node):
- logger.console('Extracting tarball to {0} on {1}'.format(
- con.REMOTE_FW_DIR, node['host']))
- ssh = SSH()
- ssh.connect(node)
-
- cmd = 'rm -rf {1}; mkdir {1} ; sudo -Sn tar -zxf {0} -C {1};'.format(
- tarball, con.REMOTE_FW_DIR)
- (ret_code, stdout, stderr) = ssh.exec_command(cmd, timeout=30)
- if 0 != ret_code:
- logger.error('Unpack error: {0}'.format(stderr))
- raise Exception('Failed to unpack {0} at node {1}'.format(
- tarball, node['host']))
-
- def __delete_local_tarball(self, tarball):
- call(shlex.split('sh -c "rm {0} > /dev/null 2>&1"'.format(tarball)))
-
- def setup_framework(self, nodes):
- """Pack the whole directory and extract in temp on each node."""
-
- tarball = self.__pack_framework_dir()
- logger.console('Framework packed to {0}'.format(tarball))
- remote_tarball = "/tmp/{0}".format(basename(tarball))
-
- for node in nodes.values():
- self.__copy_tarball_to_node(tarball, node)
- self.__extract_tarball_at_node(remote_tarball, node)
-
- logger.trace('Test framework copied to all topology nodes')
- self.__delete_local_tarball(tarball)
-
diff --git a/test/resources/libraries/python/VatExecutor.py b/test/resources/libraries/python/VatExecutor.py
deleted file mode 100644
index f10259b5006..00000000000
--- a/test/resources/libraries/python/VatExecutor.py
+++ /dev/null
@@ -1,84 +0,0 @@
-# Copyright (c) 2015 Cisco and/or its affiliates.
-# 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.
-import os
-from ssh import SSH
-from robot.api import logger
-
-__all__ = []
-
-class VatExecutor(object):
-
- __TMP_DIR = "/tmp/"
- __VAT_BIN = "vpp_api_test"
-
- def __init__(self):
- self._stdout = None
- self._stderr = None
- self._ret_code = None
-
- def execute_script(self, local_path, node, timeout=10, json_out=True):
- """Copy local_path script to node, execute it and return result.
-
- Returns (rc, stdout, stderr tuple).
- """
-
- ssh = SSH()
- ssh.connect(node)
-
- local_basename = os.path.basename(local_path)
- remote_file_path = self.__TMP_DIR + local_basename
- remote_file_out = remote_file_path + ".out"
-
- ssh.scp(local_path, remote_file_path)
-
- cmd = "sudo -S {vat} {json} < {input}".format(vat=self.__VAT_BIN,
- json="json" if json_out == True else "",
- input=remote_file_path)
- (ret_code, stdout, stderr) = ssh.exec_command(cmd, timeout)
- self._ret_code = ret_code
- self._stdout = stdout
- self._stderr = stderr
-
- logger.trace("Command '{0}' returned {1}'".format(cmd, self._ret_code))
- logger.trace("stdout: '{0}'".format(self._stdout))
- logger.trace("stderr: '{0}'".format(self._stderr))
-
- #TODO: download vpp_api_test output file
- self._delete_files(node, remote_file_path, remote_file_out)
-
- def _delete_files(self, node, *files):
- ssh = SSH()
- ssh.connect(node)
- files = " ".join([str(x) for x in files])
- ssh.exec_command("rm {0}".format(files))
-
- def script_should_have_failed(self):
- if self._ret_code is None:
- raise Exception("First execute the script!")
- if self._ret_code == 0:
- raise AssertionError(
- "Script execution passed, but failure was expected")
-
- def script_should_have_passed(self):
- if self._ret_code is None:
- raise Exception("First execute the script!")
- if self._ret_code != 0:
- raise AssertionError(
- "Script execution failed, but success was expected")
-
- def get_script_stdout(self):
- return self._stdout
-
- def get_script_stderr(self):
- return self._stderr
-
diff --git a/test/resources/libraries/python/constants.py b/test/resources/libraries/python/constants.py
deleted file mode 100644
index 8c92993c7cf..00000000000
--- a/test/resources/libraries/python/constants.py
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copyright (c) 2015 Cisco and/or its affiliates.
-# 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.
-class Constants(object):
- #OpenVPP testing directory location at topology nodes
- REMOTE_FW_DIR = '/tmp/openvpp-testing'
diff --git a/test/resources/libraries/python/ssh.py b/test/resources/libraries/python/ssh.py
deleted file mode 100644
index 0887a765ba5..00000000000
--- a/test/resources/libraries/python/ssh.py
+++ /dev/null
@@ -1,127 +0,0 @@
-# Copyright (c) 2015 Cisco and/or its affiliates.
-# 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.
-import paramiko
-from scp import SCPClient
-from time import time
-from robot.api import logger
-
-__all__ = ["exec_cmd"]
-
-# TODO: Attempt to recycle SSH connections
-# TODO: load priv key
-
-class SSH(object):
-
- __MAX_RECV_BUF = 10*1024*1024
- __existing_connections = {}
-
- def __init__(self):
- self._ssh = paramiko.SSHClient()
- self._ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- self._hostname = None
-
- def _node_hash(self, node):
- return hash(frozenset([node['host'], node['port']]))
-
- def connect(self, node):
- """Connect to node prior to running exec_command or scp.
-
- If there already is a connection to the node, this method reuses it.
- """
- self._hostname = node['host']
- node_hash = self._node_hash(node)
- if node_hash in self.__existing_connections:
- self._ssh = self.__existing_connections[node_hash]
- else:
- start = time()
- self._ssh.connect(node['host'], username=node['username'],
- password=node['password'])
- self.__existing_connections[node_hash] = self._ssh
- logger.trace('connect took {} seconds'.format(time() - start))
-
- def exec_command(self, cmd, timeout=10):
- """Execute SSH command on a new channel on the connected Node.
-
- Returns (return_code, stdout, stderr).
- """
- start = time()
- chan = self._ssh.get_transport().open_session()
- if timeout is not None:
- chan.settimeout(int(timeout))
- chan.exec_command(cmd)
- end = time()
- logger.trace('exec_command "{0}" on {1} took {2} seconds'.format(cmd,
- self._hostname, end-start))
-
-
- stdout = ""
- while True:
- buf = chan.recv(self.__MAX_RECV_BUF)
- stdout += buf
- if not buf:
- break
-
- stderr = ""
- while True:
- buf = chan.recv_stderr(self.__MAX_RECV_BUF)
- stderr += buf
- if not buf:
- break
-
- return_code = chan.recv_exit_status()
- logger.trace('chan_recv/_stderr took {} seconds'.format(time()-end))
-
- return (return_code, stdout, stderr)
-
- def scp(self, local_path, remote_path):
- """Copy files from local_path to remote_path.
-
- connect() method has to be called first!
- """
- logger.trace('SCP {0} to {1}:{2}'.format(
- local_path, self._hostname, remote_path))
- # SCPCLient takes a paramiko transport as its only argument
- scp = SCPClient(self._ssh.get_transport())
- start = time()
- scp.put(local_path, remote_path)
- scp.close()
- end = time()
- logger.trace('SCP took {0} seconds'.format(end-start))
-
-def exec_cmd(node, cmd, timeout=None):
- """Convenience function to ssh/exec/return rc & out.
-
- Returns (rc, stdout).
- """
- if node is None:
- raise TypeError('Node parameter is None')
- if cmd is None:
- raise TypeError('Command parameter is None')
- if len(cmd) == 0:
- raise ValueError('Empty command parameter')
-
- ssh = SSH()
- try:
- ssh.connect(node)
- except Exception, e:
- logger.error("Failed to connect to node" + e)
- return None
-
- try:
- (ret_code, stdout, stderr) = ssh.exec_command(cmd, timeout=timeout)
- except Exception, e:
- logger.error(e)
- return None
-
- return (ret_code, stdout, stderr)
-
diff --git a/test/resources/libraries/python/topology.py b/test/resources/libraries/python/topology.py
deleted file mode 100644
index 16b8f317394..00000000000
--- a/test/resources/libraries/python/topology.py
+++ /dev/null
@@ -1,50 +0,0 @@
-# Copyright (c) 2015 Cisco and/or its affiliates.
-# 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.
-
-#Defines nodes and topology structure.
-
-__all__ = ["DICT__nodes"]
-
-
-class NodeType(object):
- DUT = 'DUT'
- TG = 'TG'
-
-MOCK_DATA_FOR_NOW = {
- 'nodes' : {
- 'DUT1' : {
- 'type' : NodeType.DUT,
- 'host' : 'wasa-ucs-14',
- 'port' : 22,
- 'username' : '',
- 'password' : '',
- },
- 'DUT2' : {
- 'type' : NodeType.DUT,
- 'host' : 'wasa-ucs-13',
- 'port' : 22,
- 'username' : '',
- 'password' : '',
- },
- 'TG' : {
- 'type' : NodeType.TG,
- 'host' : 'wasa-ucs-12',
- 'port' : 22,
- 'username' : '',
- 'password' : '',
- },
- }
- }
-
-DICT__nodes = MOCK_DATA_FOR_NOW['nodes']
-
diff --git a/test/resources/libraries/robot/default.robot b/test/resources/libraries/robot/default.robot
deleted file mode 100644
index 4b102f5525a..00000000000
--- a/test/resources/libraries/robot/default.robot
+++ /dev/null
@@ -1,20 +0,0 @@
-# Copyright (c) 2015 Cisco and/or its affiliates.
-# 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.
-*** Settings ***
-| Library | resources/libraries/python/DUTSetup.py
-
-*** Keywords ***
-| Setup all DUTs before test
-| | [Documentation] | Setup all DUTs in topology before test execution
-| | Setup All DUTs | ${nodes}
-
diff --git a/test/resources/libraries/robot/interfaces.robot b/test/resources/libraries/robot/interfaces.robot
deleted file mode 100644
index 924d98f141b..00000000000
--- a/test/resources/libraries/robot/interfaces.robot
+++ /dev/null
@@ -1,20 +0,0 @@
-# Copyright (c) 2015 Cisco and/or its affiliates.
-# 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.
-*** Settings ***
-| Resource | resources/libraries/robot/vat/interfaces.robot
-
-*** Keywords ***
-| VPP reports interfaces on | [Arguments] | ${node}
-| | VPP reports interfaces through VAT on | ${node}
-#| | VPP reports interfaces through ODL on | ${node}
-#| | VPP reports interfaces through DEBUGCLI on | ${node}
diff --git a/test/resources/libraries/robot/vat/interfaces.robot b/test/resources/libraries/robot/vat/interfaces.robot
deleted file mode 100644
index 37c9ffbbbd1..00000000000
--- a/test/resources/libraries/robot/vat/interfaces.robot
+++ /dev/null
@@ -1,23 +0,0 @@
-# Copyright (c) 2015 Cisco and/or its affiliates.
-# 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.
-*** Settings ***
-| Library | resources/libraries/python/VatExecutor.py
-
-*** Variables ***
-| ${VAT_DUMP_INTERFACES} | resources/templates/vat/dump_interfaces.vat
-
-*** Keywords ***
-| VPP reports interfaces through VAT on
-| | [Arguments] | ${node}
-| | Execute Script | ${VAT_DUMP_INTERFACES} | ${node}
-| | Script Should Have Passed