diff options
-rw-r--r-- | docker/Dockerfile | 23 | ||||
-rw-r--r-- | docker/Dockerfile.aarch64 | 23 | ||||
-rw-r--r-- | docker/thirdparty-requirements.txt | 2 | ||||
-rwxr-xr-x | functest/ci/check_os.sh | 24 | ||||
-rwxr-xr-x | functest/ci/prepare_env.py | 2 | ||||
-rw-r--r-- | functest/core/feature.py | 18 | ||||
-rw-r--r-- | functest/tests/unit/ci/test_prepare_env.py | 8 | ||||
-rw-r--r-- | functest/tests/unit/core/test_feature.py | 23 | ||||
-rw-r--r-- | functest/utils/openstack_utils.py | 12 | ||||
-rw-r--r-- | tox.ini | 3 |
10 files changed, 71 insertions, 67 deletions
diff --git a/docker/Dockerfile b/docker/Dockerfile index 0421e6150..4c03a697d 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -17,7 +17,6 @@ ARG RALLY_TAG=0.8.1 ARG TEMPEST_TAG=15.0.0 ARG REFSTACK_TAG=15.0.0 ARG ODL_TAG=release/beryllium-sr4 -ARG OPENSTACK_TAG=stable/mitaka ARG KINGBIRD_TAG=1.1.0 ARG VIMS_TAG=stable ARG VROUTER_TAG=stable @@ -30,14 +29,13 @@ ARG FUNCTEST_RESULTS_DIR=${FUNCTEST_BASE_DIR}/results ARG FUNCTEST_REPO_DIR=${REPOS_DIR}/functest ARG FUNCTEST_TEST_DIR=${FUNCTEST_REPO_DIR}/functest/opnfv_tests ARG REPOS_VNFS_DIR=${REPOS_DIR}/vnfs +ARG PIP_OPTS=-chttps://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?stable/ocata # Environment variables ENV HOME /home/opnfv ENV CONFIG_FUNCTEST_YAML ${FUNCTEST_REPO_DIR}/functest/ci/config_functest.yaml ENV REPOS_DIR ${HOME}/repos ENV creds ${FUNCTEST_CONF_DIR}/openstack.creds -ENV TERM xterm -ENV COLORTERM gnome-terminal WORKDIR ${HOME} @@ -80,7 +78,7 @@ RUN mkdir -p ${FUNCTEST_REPO_DIR} \ RUN git config --global http.sslVerify false COPY thirdparty-requirements.txt thirdparty-requirements.txt -RUN pip install \ +RUN pip install ${PIP_OPTS} \ git+https://gerrit.opnfv.org/gerrit/functest@$BRANCH#egg=functest \ git+https://gerrit.opnfv.org/gerrit/releng@$BRANCH#egg=opnfv\&subdirectory=modules \ git+https://gerrit.opnfv.org/gerrit/snaps@$BRANCH#egg=snaps \ @@ -92,7 +90,6 @@ RUN ln -s /usr/local/lib/python2.7/dist-packages/functest ${FUNCTEST_REPO_DIR}/f # OPNFV repositories RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/copper ${REPOS_DIR}/copper -RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/sdnvpn ${REPOS_DIR}/sdnvpn RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/domino ${REPOS_DIR}/domino RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/parser ${REPOS_DIR}/parser RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/doctor ${REPOS_DIR}/doctor @@ -101,7 +98,6 @@ RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/netready ${RE RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/fds ${REPOS_DIR}/fds RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/sfc ${REPOS_DIR}/sfc RUN git clone --depth 1 https://gerrit.opnfv.org/gerrit/securityscanning ${REPOS_DIR}/securityscanning -RUN git clone --depth 1 https://gerrit.opnfv.org/gerrit/opera ${REPOS_DIR}/opera # other repositories RUN git clone --depth 1 -b $TEMPEST_TAG https://github.com/openstack/tempest.git ${REPOS_DIR}/tempest @@ -110,8 +106,6 @@ RUN git clone --depth 1 -b $VIMS_TAG https://github.com/boucherv-orange/clearwat RUN git clone --depth 1 -b $VROUTER_TAG https://github.com/oolorg/opnfv-functest-vrouter.git ${REPOS_VNFS_DIR}/vrouter RUN git clone --depth 1 https://github.com/wuwenbin2/OnosSystemTest.git ${REPOS_DIR}/onos -RUN pip install ${REPOS_DIR}/opera - RUN find -L ${FUNCTEST_REPO_DIR} -name "*.py" \ -not -path "*tests/unit*" \ -not -path "*functest_venv*" \ @@ -139,10 +133,7 @@ RUN curl -L https://get.rvm.io | bash -s stable # SFC integration RUN /bin/bash -c ". ${REPOS_DIR}/sfc/sfc/tests/functest/setup_scripts/tacker_client_install.sh" -RUN cd ${REPOS_DIR}/sfc && pip install -e . - -# SDNVPN integration -RUN cd ${REPOS_DIR}/sdnvpn && pip install -e . +RUN cd ${REPOS_DIR}/sfc && pip install ${PIP_OPTS} -e . # refstack-client integration RUN wget -q https://raw.githubusercontent.com/openstack/refstack-client/master/setup_env \ @@ -166,10 +157,4 @@ RUN sh -c 'curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -' \ && cd ${REPOS_DIR}/promise && sudo npm -g install npm@latest \ && cd ${REPOS_DIR}/promise/source && npm install -RUN echo "set nocompatible \n\ -set backspace=2" \ ->> ${HOME}/.vimrc -RUN echo set nocompatible >> ${HOME}/.exrc -RUN echo "alias ll='ls -lh' \n\ -. ${FUNCTEST_REPO_DIR}/functest/cli/functest-complete.sh" \ ->> ${HOME}/.bashrc +RUN echo ". ${FUNCTEST_REPO_DIR}/functest/cli/functest-complete.sh" >> ${HOME}/.bashrc diff --git a/docker/Dockerfile.aarch64 b/docker/Dockerfile.aarch64 index 89f45ba05..1d47aa426 100644 --- a/docker/Dockerfile.aarch64 +++ b/docker/Dockerfile.aarch64 @@ -17,7 +17,6 @@ ARG RALLY_TAG=0.8.1 ARG TEMPEST_TAG=15.0.0 ARG REFSTACK_TAG=15.0.0 ARG ODL_TAG=release/beryllium-sr4 -ARG OPENSTACK_TAG=stable/mitaka ARG KINGBIRD_TAG=0.2.2 ARG VIMS_TAG=stable ARG REPOS_DIR=/home/opnfv/repos @@ -29,14 +28,13 @@ ARG FUNCTEST_RESULTS_DIR=${FUNCTEST_BASE_DIR}/results ARG FUNCTEST_REPO_DIR=${REPOS_DIR}/functest ARG FUNCTEST_TEST_DIR=${FUNCTEST_REPO_DIR}/functest/opnfv_tests ARG REPOS_VNFS_DIR=${REPOS_DIR}/vnfs +ARG PIP_OPTS=-chttps://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?stable/ocata # Environment variables ENV HOME /home/opnfv ENV CONFIG_FUNCTEST_YAML ${FUNCTEST_REPO_DIR}/functest/ci/config_functest.yaml ENV REPOS_DIR ${HOME}/repos ENV creds ${FUNCTEST_CONF_DIR}/openstack.creds -ENV TERM xterm -ENV COLORTERM gnome-terminal WORKDIR ${HOME} @@ -79,7 +77,7 @@ RUN mkdir -p ${FUNCTEST_REPO_DIR} \ RUN git config --global http.sslVerify false COPY thirdparty-requirements.txt thirdparty-requirements.txt -RUN pip install \ +RUN pip install ${PIP_OPTS} \ git+https://gerrit.opnfv.org/gerrit/functest@$BRANCH#egg=functest \ git+https://gerrit.opnfv.org/gerrit/releng@$BRANCH#egg=opnfv\&subdirectory=modules \ git+https://gerrit.opnfv.org/gerrit/snaps@$BRANCH#egg=snaps \ @@ -87,14 +85,12 @@ RUN pip install \ # OPNFV repositories RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/copper ${REPOS_DIR}/copper -RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/sdnvpn ${REPOS_DIR}/sdnvpn RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/domino ${REPOS_DIR}/domino RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/parser ${REPOS_DIR}/parser RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/doctor ${REPOS_DIR}/doctor RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/promise ${REPOS_DIR}/promise RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/sfc ${REPOS_DIR}/sfc RUN git clone --depth 1 https://gerrit.opnfv.org/gerrit/securityscanning ${REPOS_DIR}/securityscanning -RUN git clone --depth 1 https://gerrit.opnfv.org/gerrit/opera ${REPOS_DIR}/opera # other repositories RUN git clone --depth 1 -b $TEMPEST_TAG https://github.com/openstack/tempest.git ${REPOS_DIR}/tempest @@ -127,14 +123,9 @@ RUN add_images.sh RUN gpg --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 RUN curl -L https://get.rvm.io | bash -s stable -RUN pip install ${REPOS_DIR}/opera - # SFC integration RUN /bin/bash -c ". ${REPOS_DIR}/sfc/sfc/tests/functest/setup_scripts/tacker_client_install.sh" -RUN cd ${REPOS_DIR}/sfc && pip install -e . - -# SDNVPN integration -RUN cd ${REPOS_DIR}/sdnvpn && pip install -e . +RUN cd ${REPOS_DIR}/sfc && pip install ${PIP_OPTS} -e . # refstack-client integration RUN wget -q https://raw.githubusercontent.com/openstack/refstack-client/master/setup_env \ @@ -160,10 +151,4 @@ RUN sh -c 'wget -qO- https://nodejs.org/dist/v4.7.2/node-v4.7.2-linux-arm64.tar. && cd ${REPOS_DIR}/promise && sudo npm -g install npm@latest \ && cd ${REPOS_DIR}/promise/source && npm install -RUN echo "set nocompatible \n\ -set backspace=2" \ ->> ${HOME}/.vimrc -RUN echo set nocompatible >> ${HOME}/.exrc -RUN echo "alias ll='ls -lh' \n\ -. ${FUNCTEST_REPO_DIR}/functest/cli/functest-complete.sh" \ ->> ${HOME}/.bashrc +RUN echo ". ${FUNCTEST_REPO_DIR}/functest/cli/functest-complete.sh" >> ${HOME}/.bashrc diff --git a/docker/thirdparty-requirements.txt b/docker/thirdparty-requirements.txt index 064b51850..d59332556 100644 --- a/docker/thirdparty-requirements.txt +++ b/docker/thirdparty-requirements.txt @@ -1,4 +1,6 @@ git+https://gerrit.opnfv.org/gerrit/barometer#egg=baro_tests +git+https://gerrit.opnfv.org/gerrit/sdnvpn#egg=sdnvpn +git+https://gerrit.opnfv.org/gerrit/opera#egg=opera networking-bgpvpn kingbird rally diff --git a/functest/ci/check_os.sh b/functest/ci/check_os.sh index ce0bc20c6..7b66f3da6 100755 --- a/functest/ci/check_os.sh +++ b/functest/ci/check_os.sh @@ -6,12 +6,18 @@ # jose.lausuch@ericsson.com # +if [[ ${OS_INSECURE,,} == "true" ]]; then + options='--insecure' +else + options='' +fi + declare -A service_cmd_array -service_cmd_array['nova']='openstack server list' -service_cmd_array['neutron']='openstack network list' -service_cmd_array['keystone']='openstack endpoint list' -service_cmd_array['cinder']='openstack volume list' -service_cmd_array['glance']='openstack image list' +service_cmd_array['nova']="openstack $options server list" +service_cmd_array['neutron']="openstack $options network list" +service_cmd_array['keystone']="openstack $options endpoint list" +service_cmd_array['cinder']="openstack $options volume list" +service_cmd_array['glance']="openstack $options image list" MANDATORY_SERVICES='nova neutron keystone glance' OPTIONAL_SERVICES='cinder' @@ -41,7 +47,7 @@ check_service() { required=$2 fi echo ">>Checking ${service} service..." - if ! openstack service list | grep -i ${service} > /dev/null; then + if ! openstack $options service list | grep -i ${service} > /dev/null; then if [ "$required" == 'false' ]; then echo "WARN: Optional Service ${service} is not enabled!" return @@ -67,7 +73,7 @@ fi echo "Checking OpenStack endpoints:" -publicURL=$(openstack catalog show identity |awk '/public/ {print $4}') +publicURL=$(openstack $options catalog show identity |awk '/public/ {print $4}') publicIP=$(echo $publicURL|sed 's/^.*http.*\:\/\///'|sed 's/.[^:]*$//') publicPort=$(echo $publicURL|grep -Po '(?<=:)\d+') https_enabled=$(echo $publicURL | grep 'https') @@ -99,11 +105,11 @@ for service in $OPTIONAL_SERVICES; do done echo "Checking External network..." -networks=($(neutron net-list -F id | tail -n +4 | head -n -1 | awk '{print $2}')) +networks=($(neutron $options net-list -F id | tail -n +4 | head -n -1 | awk '{print $2}')) is_external=False for net in "${networks[@]}" do - is_external=$(neutron net-show $net|grep "router:external"|awk '{print $4}') + is_external=$(neutron $options net-show $net|grep "router:external"|awk '{print $4}') if [ $is_external == "True" ]; then echo "External network found: $net" break diff --git a/functest/ci/prepare_env.py b/functest/ci/prepare_env.py index 5326c50b8..64fcc9256 100755 --- a/functest/ci/prepare_env.py +++ b/functest/ci/prepare_env.py @@ -366,7 +366,6 @@ def main(**kwargs): elif kwargs['action'] == "start": logger.info("######### Preparing Functest environment #########\n") check_env_variables() - get_deployment_handler() create_directories() source_rc_file() update_config_file() @@ -377,7 +376,6 @@ def main(**kwargs): with open(CONST.__getattribute__('env_active'), "w") as env_file: env_file.write("1") check_environment() - print_deployment_info() elif kwargs['action'] == "check": check_environment() except Exception as e: diff --git a/functest/core/feature.py b/functest/core/feature.py index d53eb7d0e..010ff4bc9 100644 --- a/functest/core/feature.py +++ b/functest/core/feature.py @@ -33,6 +33,24 @@ class Feature(base.TestCase): super(Feature, self).__init__(**kwargs) self.result_file = "{}/{}.log".format( CONST.__getattribute__('dir_results'), self.case_name) + try: + module = kwargs['run']['module'] + self.logger = logging.getLogger(module) + except KeyError: + self.__logger.warning( + "Cannot get module name %s. Using %s as fallback", + kwargs, self.case_name) + self.logger = logging.getLogger(self.case_name) + handler = logging.StreamHandler() + handler.setLevel(logging.WARN) + self.logger.addHandler(handler) + handler = logging.FileHandler(self.result_file) + handler.setLevel(logging.DEBUG) + self.logger.addHandler(handler) + formatter = logging.Formatter( + '%(asctime)s - %(name)s - %(levelname)s - %(message)s') + handler.setFormatter(formatter) + self.logger.addHandler(handler) def execute(self, **kwargs): """Execute the Python method. diff --git a/functest/tests/unit/ci/test_prepare_env.py b/functest/tests/unit/ci/test_prepare_env.py index f3e15a013..69abd6433 100644 --- a/functest/tests/unit/ci/test_prepare_env.py +++ b/functest/tests/unit/ci/test_prepare_env.py @@ -424,7 +424,6 @@ class PrepareEnvTesting(unittest.TestCase): mock_logger_info.assert_any_call("Functest environment" " is installed.") - @mock.patch('functest.ci.prepare_env.print_deployment_info') @mock.patch('functest.ci.prepare_env.check_environment') @mock.patch('functest.ci.prepare_env.create_flavor') @mock.patch('functest.ci.prepare_env.install_tempest') @@ -433,21 +432,19 @@ class PrepareEnvTesting(unittest.TestCase): @mock.patch('functest.ci.prepare_env.update_config_file') @mock.patch('functest.ci.prepare_env.source_rc_file') @mock.patch('functest.ci.prepare_env.create_directories') - @mock.patch('functest.ci.prepare_env.get_deployment_handler') @mock.patch('functest.ci.prepare_env.check_env_variables') @mock.patch('functest.ci.prepare_env.logger.info') - def test_main_start(self, mock_logger_info, mock_env_var, mock_dep_handler, + def test_main_start(self, mock_logger_info, mock_env_var, mock_create_dir, mock_source_rc, mock_update_config, mock_verify_depl, mock_install_rally, mock_install_temp, mock_create_flavor, - mock_check_env, mock_print_info): + mock_check_env): with mock.patch("__builtin__.open", mock.mock_open()) as m: args = {'action': 'start'} self.assertEqual(prepare_env.main(**args), 0) mock_logger_info.assert_any_call("######### Preparing Functest " "environment #########\n") self.assertTrue(mock_env_var.called) - self.assertTrue(mock_dep_handler.called) self.assertTrue(mock_create_dir.called) self.assertTrue(mock_source_rc.called) self.assertTrue(mock_update_config.called) @@ -458,7 +455,6 @@ class PrepareEnvTesting(unittest.TestCase): m.assert_called_once_with( CONST.__getattribute__('env_active'), "w") self.assertTrue(mock_check_env.called) - self.assertTrue(mock_print_info.called) @mock.patch('functest.ci.prepare_env.check_environment') def test_main_check(self, mock_check_env): diff --git a/functest/tests/unit/core/test_feature.py b/functest/tests/unit/core/test_feature.py index 0160c8e16..988981eff 100644 --- a/functest/tests/unit/core/test_feature.py +++ b/functest/tests/unit/core/test_feature.py @@ -38,12 +38,26 @@ class FeatureTestingBase(unittest.TestCase): self.assertEqual(self.feature.start_time, 1) self.assertEqual(self.feature.stop_time, 2) + def test_logger_module_ko(self): + with mock.patch('six.moves.builtins.open'): + self.feature = feature.Feature( + project_name=self._project_name, case_name=self._case_name) + self.assertEqual(self.feature.logger.name, self._case_name) + + def test_logger_module(self): + with mock.patch('six.moves.builtins.open'): + self.feature = feature.Feature( + project_name=self._project_name, case_name=self._case_name, + run={'module': 'bar'}) + self.assertEqual(self.feature.logger.name, 'bar') + class FeatureTesting(FeatureTestingBase): def setUp(self): - self.feature = feature.Feature( - project_name=self._project_name, case_name=self._case_name) + with mock.patch('six.moves.builtins.open'): + self.feature = feature.Feature( + project_name=self._project_name, case_name=self._case_name) def test_run_exc(self): # pylint: disable=bad-continuation @@ -60,8 +74,9 @@ class FeatureTesting(FeatureTestingBase): class BashFeatureTesting(FeatureTestingBase): def setUp(self): - self.feature = feature.BashFeature( - project_name=self._project_name, case_name=self._case_name) + with mock.patch('six.moves.builtins.open'): + self.feature = feature.BashFeature( + project_name=self._project_name, case_name=self._case_name) @mock.patch("functest.utils.functest_utils.execute_command") def test_run_no_cmd(self, mock_method=None): diff --git a/functest/utils/openstack_utils.py b/functest/utils/openstack_utils.py index f155449d5..a89662648 100644 --- a/functest/utils/openstack_utils.py +++ b/functest/utils/openstack_utils.py @@ -181,14 +181,10 @@ def get_endpoint(service_type, endpoint_type='publicURL'): def get_session(other_creds={}): auth = get_session_auth(other_creds) - cacert = os.getenv('OS_CACERT') - if cacert is not None: - if not os.path.isfile(cacert): - raise Exception("The 'OS_CACERT' environment" - "variable is set to %s but the file" - "does not exist.", cacert) - - return session.Session(auth=auth, verify=cacert) + https_cacert = os.getenv('OS_CACERT', '') + https_insecure = os.getenv('OS_INSECURE', '').lower() == 'true' + return session.Session(auth=auth, + verify=(https_cacert or not https_insecure)) # ********************************************* @@ -8,6 +8,9 @@ deps = -r{toxinidir}/test-requirements.txt git+https://gerrit.opnfv.org/gerrit/releng#egg=opnfv&subdirectory=modules git+https://gerrit.opnfv.org/gerrit/snaps#egg=snaps +install_command = pip install \ + -chttps://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?stable/ocata \ + {opts} {packages} commands = nosetests --with-xunit \ --with-coverage \ --cover-tests \ |