From: Deepak Kataria Date: Mon, 2 Sep 2019 20:40:30 +0000 (+0000) Subject: Merge "Create docker layer container for Docker Bench" X-Git-Tag: 2.0.0~46 X-Git-Url: https://gerrit.akraino.org/r/gitweb?p=validation.git;a=commitdiff_plain;h=c0badaca56ee45b12bfc08113e46d75b3b6ad67b;hp=3d693bf57ea1a831f90a655929b8fe4502de50a8 Merge "Create docker layer container for Docker Bench" --- diff --git a/bluval/README.md b/bluval/README.md deleted file mode 100644 index 0ccd6c5..0000000 --- a/bluval/README.md +++ /dev/null @@ -1,10 +0,0 @@ -# BluVal - -## Installation - -Minimum required python verson is python3.5 - -``` -python3 -m pip install -r requirements.txt -``` - diff --git a/bluval/README.rst b/bluval/README.rst new file mode 100644 index 0000000..56d1282 --- /dev/null +++ b/bluval/README.rst @@ -0,0 +1,68 @@ +.. ############################################################################ +.. Copyright (c) 2019 AT&T, ENEA AB, Nokia and others # +.. # +.. Licensed under the Apache License, Version 2.0 (the "License"); # +.. you maynot 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. # +.. ############################################################################ + + +Overview +======== +BluVal is a diagnostic toolset framework to validate different layers in the +Akraino infrastructure developed and used in Akraino edge stack. BluVal +integrates different test cases, its development employs a declarative approach +that is version controlled in LF Gerrit. They are integrated in CI/CD tool +chain where peer Jenkins jobs can run the test cases and the results are +reported in LF Repo (Nexus). The test cases cover all blueprint layers in the +cluster. + +Installation and execution +========================== +Bluval tool can be ran directly from the repo, or can be called from a container. + + +When ran directly, minimum requirements are python verson 3.5. To setup the +environment follow the commands below. + +.. code-block:: console + + ns156u@aknode82:~$ git clone https://gerrit.akraino.org/r/validation.git + ns156u@aknode82:~$ cd validation + ns156u@aknode82:~/validation$ python -m venv .py35 + ns156u@aknode82:~/validation$ source .py35/bin/activate + (.py35) ns156u@aknode82:~/validation$ pip install -r bluval/requirements.txt + +To run the tests for a certain blueprint, follow the commands below. Optionally +the layer of testing can be specified too. + +.. code-block:: console + (.py35) ns156u@aknode82:~/validation$ python bluval/bluval.py -l \ + hardware dummy # this will run hardware test cases of dummy blue print + (.py35) ns156u@aknode82:~/validation$ deactivate + + +When ran from a container, docker needs to be installed on the machine. +To run the tests for a certain blueprint, follow the steps below. Optionally +the layer of testing can be specified too. + +Note that before issuing the blucon command, you need to fill in the volumes +that will be mounted in the container. These are locations of the config files +or access files (ssh keys or clients configs) that will be used to connect to +the cluster. Also custom volumes can be added here. + +.. code-block:: console + + ns156u@aknode82:~$ git clone https://gerrit.akraino.org/r/validation.git + ns156u@aknode82:~$ cd validation + ns156u@aknode82:~$ vi bluval/volumes.yaml # fill in the volumes to be \ + mounted in the container + ns156u@aknode82:~$ python3 bluval/blucon.py dummy -l hardware diff --git a/bluval/blucon.py b/bluval/blucon.py index 5d7406b..7f72048 100644 --- a/bluval/blucon.py +++ b/bluval/blucon.py @@ -29,22 +29,44 @@ import yaml from bluutil import BluvalError from bluutil import ShowStopperError +_OPTIONAL_ALSO = False + +def get_volumes(layer): + """Create a list with volumes to mount in the container for given layer + """ + mypath = Path(__file__).absolute() + volume_yaml = yaml.safe_load(mypath.parents[0].joinpath("volumes.yaml").open()) + + if layer not in volume_yaml['layers']: + return '' + if volume_yaml['layers'][layer] is None: + return '' + + volume_list = '' + for vol in volume_yaml['layers'][layer]: + if volume_yaml['volumes'][vol]['local'] == '': + continue + volume_list = (volume_list + ' -v ' + + volume_yaml['volumes'][vol]['local'] + ':' + + volume_yaml['volumes'][vol]['target']) + return volume_list + + def invoke_docker(bluprint, layer): """Start docker container for given layer """ - cmd = ("docker run" - " -v $HOME/.ssh:/root/.ssh" - " -v $HOME/.kube/config:/root/.kube/config" - " -v $VALIDATION_HOME/tests/variables.yaml:" - "/opt/akraino/validation/tests/variables.yaml" - " -v $AKRAINO_HOME/results:/opt/akraino/results" + + volume_list = get_volumes('common') + get_volumes(layer) + cmd = ("docker run" + volume_list + " akraino/validation:{0}-latest" - " bin/sh -c" + " /bin/sh -c" " 'cd /opt/akraino/validation " - "&& python bluval/bluval.py -l {0} {1}'").format(layer, bluprint) + "&& python bluval/bluval.py -l {0} {1} {2}'" + .format(layer, ("-o" if _OPTIONAL_ALSO else ""), bluprint)) + args = [cmd] try: - print('Invoking {}'.format(args)) + print('\nInvoking {}'.format(args)) subprocess.call(args, shell=True) except OSError: #print('Error while executing {}'.format(args)) @@ -67,14 +89,19 @@ def invoke_dockers(yaml_loc, layer, blueprint_name): @click.command() @click.argument('blueprint') @click.option('--layer', '-l') -def main(blueprint, layer): +@click.option('--optional_also', '-o', is_flag=True) +def main(blueprint, layer, optional_also): """Takes blueprint name and optional layer. Validates inputs and derives yaml location from blueprint name. Invokes validate on blue print. """ + global _OPTIONAL_ALSO # pylint: disable=global-statement mypath = Path(__file__).absolute() yaml_loc = mypath.parents[0].joinpath('bluval-{}.yaml'.format(blueprint)) if layer is not None: layer = layer.lower() + if optional_also: + _OPTIONAL_ALSO = True + print("_OPTIONAL_ALSO {}".format(_OPTIONAL_ALSO)) try: invoke_dockers(yaml_loc, layer, blueprint) except ShowStopperError as err: diff --git a/bluval/bluval.py b/bluval/bluval.py index bcdc856..feefa5e 100644 --- a/bluval/bluval.py +++ b/bluval/bluval.py @@ -96,6 +96,20 @@ def validate_blueprint(yaml_loc, layer): validate_layer(blueprint, layer) +def write_test_info(layer): + """writes testing info to test_info.yaml + """ + data = dict( + test_info=dict( + layer=layer, + optional=_OPTIONAL_ALSO, + ) + ) + + with open('/opt/akraino/results/test_info.yaml', 'w') as outfile: + yaml.dump(data, outfile, default_flow_style=False) + + @click.command() @click.argument('blueprint') @click.option('--layer', '-l') @@ -114,6 +128,7 @@ def main(blueprint, layer, optional_also): print("_OPTIONAL_ALSO {}".format(_OPTIONAL_ALSO)) try: + write_test_info(layer) validate_blueprint(yaml_loc, layer) except ShowStopperError as err: print('ShowStopperError:', err) diff --git a/bluval/volumes.yaml b/bluval/volumes.yaml new file mode 100644 index 0000000..0e062ea --- /dev/null +++ b/bluval/volumes.yaml @@ -0,0 +1,67 @@ +############################################################################## +# Copyright (c) 2019 AT&T, ENEA AB, Nokia and others # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you maynot 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. # +############################################################################## + +# Full list of volumes that can be mounted to the containers when running the tests. +# When adding volumes, add file or dir at the end of the keyword to ease identifying +# the type of the volume +# +# When running the tests, fill in the 'local' sections only for the volumes that are +# applicable to your setup + +volumes: + # location of the ssh key to access the cluster + ssh_key_file: + local: '' + target: '/root/.ssh' + # location of the k8s access files (config file, certificates, keys) + kube_config_dir: + local: '' + target: '/root/.kube/' + # location of the customized variables.yaml + custom_variables_file: + local: '' + target: '/opt/akraino/validation/tests/variables.yaml' + # location of the bluval-.yaml file + blueprint_dir: + local: '' + target: '/opt/akraino/validation/bluval' + # location on where to store the results on the local jumpserver + results_dir: + local: '' + target: '/opt/akraino/results' + +# parameters that will be passed to the container at each layer +layers: + # volumes mounted at all layers; volumes specific for a different layer are below + common: + - custom_variables_file + - blueprint_dir + - results_dir + hardware: + - ssh_key_file + os: + - ssh_key_file + networking: + - ssh_key_file + k8s: + - ssh_key_file + - kube_config_dir + k8s_networking: + - ssh_key_File + - kube_config_dir + sds: + sdn: + vim: diff --git a/docker/README.rst b/docker/README.rst index 4694cde..7179bee 100644 --- a/docker/README.rst +++ b/docker/README.rst @@ -274,3 +274,38 @@ want to enter the container, add */bin/sh* at the end of the command above. Normally, this conainer is not used directly, but instead leveraged via sonobuoy. + +The helm container +================== + +Building and pushing the container +---------------------------------- + +To build just the helm container, use the command: + +.. code-block:: console + + make helm-build [ REGISTRY= NAME=] + +To both build and push the container, use the command: + +.. code-block:: console + + make helm [ REGISTRY= NAME=] + +Using the container +------------------- + +Container needs to be started with the SSH key file mounted. Users +credentials can be provided via a mounted variables.yaml file. + +The results folder can be mounted as well; this way the logs are +stored on the local server. + +.. code-block:: console + + docker run -ti -v /home/jenkins/openrc:/root/openrc \ + -v /home/foobar/.ssh/id_rsa:/root/.ssh/id_rsa \ + -v /home/foobar/variables.yaml:/opt/akraino/validation/tests/variables.yaml \ + -v /home/foobar/helm_results:/opt/akraino/results/ \ + akraino/validation:helm-latest diff --git a/docker/helm/Dockerfile b/docker/helm/Dockerfile new file mode 100644 index 0000000..841d261 --- /dev/null +++ b/docker/helm/Dockerfile @@ -0,0 +1,48 @@ +############################################################################## +# Copyright (c) 2019 AT&T, ENEA AB, Nokia and others # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you maynot 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. # +############################################################################## + +# ref: https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#use-multi-stage-builds +FROM python:3.6-alpine3.9 as build + +# Install dependencies +COPY pip-requirements.txt /wheels/requirements/pip-requirements.txt +RUN apk --no-cache add --update \ + gcc \ + git \ + libc-dev \ + libffi \ + libffi-dev \ + make \ + openssl-dev + +# Build binaries +WORKDIR /wheels +RUN pip3 install wheel +RUN pip3 wheel -r /wheels/requirements/pip-requirements.txt +RUN git clone https://gerrit.akraino.org/r/validation /opt/akraino/validation + +# Copy binaries in the final container and install requirements +FROM python:3.6-alpine3.9 +COPY --from=build /wheels /wheels +COPY --from=build /opt/akraino/validation /opt/akraino/validation + +RUN pip3 install -r /wheels/requirements/pip-requirements.txt \ + -f /wheels && \ + rm -rf /wheels && \ + rm -rf /root/.cache/pip/* + +# Install blueval dependencies +RUN pip install -r /opt/akraino/validation/bluval/requirements.txt diff --git a/docker/helm/Makefile b/docker/helm/Makefile new file mode 100644 index 0000000..a5b4099 --- /dev/null +++ b/docker/helm/Makefile @@ -0,0 +1,23 @@ +############################################################################## +# Copyright (c) 2019 AT&T, ENEA AB, Nokia and others # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you maynot 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. # +############################################################################## + +.PHONY: all +all: .push_image .push_manifest + +.PHONY: build +build: .build + +include ../build.mk diff --git a/docker/helm/pip-requirements.txt b/docker/helm/pip-requirements.txt new file mode 100644 index 0000000..af1d9bf --- /dev/null +++ b/docker/helm/pip-requirements.txt @@ -0,0 +1,2 @@ +robotframework +robotframework-sshlibrary diff --git a/tests/helm/helm_chart.resource b/tests/helm/helm_chart.resource new file mode 100644 index 0000000..4657ba6 --- /dev/null +++ b/tests/helm/helm_chart.resource @@ -0,0 +1,71 @@ +############################################################################## +# Copyright (c) 2019 AT&T Intellectual Property. # +# Copyright (c) 2019 Nokia. # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you maynot 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 SSHLibrary +Library String + + +*** Variables *** +${REPORTDIR} ${LOG_PATH}${/}${SUITE_NAME.replace(' ','_')} +${CHARTDIR} /tmp/helm-chart +${SERVECMD} helm serve --repo-path /home/${USERNAME}/.helm/repository/local + + +*** Keywords *** +Open Connection And Log In + Open Connection ${HOST} + Login With Public Key ${USERNAME} ${SSH_KEYFILE} + +Start Local Chart Repository Server + Stop Local Chart Repository Server + Start Command ${SERVECMD} + ${rc}= Execute Command pgrep -xf "${SERVECMD}" + ... return_stdout=False + ... return_rc=True + Should Be Equal As Integers ${rc} 0 + +Stop Local Chart Repository Server + Execute Command pkill -xf "${SERVECMD}" + +List Charts In Repositories + ${stdout}= Execute Command helm search --regexp . | tail -n +2 | cut -f1 + @{CHARTS}= Split String ${stdout} + Set Suite Variable @{CHARTS} + +Fetch Charts + Execute Command rm -r ${CHARTDIR} + Execute Command mkdir -p ${CHARTDIR} + :FOR ${chart} IN @{CHARTS} + \ ${rc}= Execute Command helm fetch ${chart} -d ${CHARTDIR} + ... return_stdout=False + ... return_rc=True + \ Should Be Equal As Integers ${rc} 0 + +Lint Charts + @{files}= List Files In Directory ${CHARTDIR} + :FOR ${file} IN @{files} + \ ${stdout}= Execute Command helm lint ${CHARTDIR}/${file} + \ Should Contain ${stdout} 1 chart(s) linted, no failures + +Simulate Install + :FOR ${chart} IN @{CHARTS} + \ ${rc}= Execute Command helm install --dry-run ${chart} + ... return_stdout=False + ... return_rc=True + \ Should Be Equal As Integers ${rc} 0 diff --git a/tests/helm/helm_chart.robot b/tests/helm/helm_chart.robot new file mode 100644 index 0000000..516d44a --- /dev/null +++ b/tests/helm/helm_chart.robot @@ -0,0 +1,36 @@ +############################################################################## +# Copyright (c) 2019 AT&T Intellectual Property. # +# Copyright (c) 2019 Nokia. # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you maynot 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 *** +Documentation Tests to validate Helm charts available in chart +... repositories. +Resource helm_chart.resource +Suite Setup Run Keywords Open Connection And Log In + ... List Charts In Repositories + ... Start Local Chart Repository Server +Suite Teardown Run Keywords Stop Local Chart Repository Server + ... Close All Connections + + +*** Test Cases *** +Validate Formatting + Fetch Charts + Lint Charts + +Validate Rendering + Simulate Install diff --git a/tests/os/ltp/ltp.robot b/tests/os/ltp/ltp.robot new file mode 100644 index 0000000..8418bc8 --- /dev/null +++ b/tests/os/ltp/ltp.robot @@ -0,0 +1,58 @@ +############################################################################## +# Copyright (c) 2019 AT&T Intellectual Property. # +# Copyright (c) 2019 Nokia. # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you maynot 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 *** +Documentation Validation, robustness and stability of Linux +Library SSHLibrary +Library OperatingSystem +Library BuiltIn +Library Process +Resource variables.resource +Suite Setup Open Connection And Log In +Suite Teardown Close All Connections + +*** Variables *** +${LOG} ${LOG_PATH}${/}${SUITE_NAME.replace(' ','_')}.log + + +*** Test Cases *** +#Run whole ltp test suite +# [Documentation] Wait ~5hrs to complete 2536 tests +# ${result}= Run Process ./runltp shell=yes cwd=/opt/ltp stdout=${LOG} +# Append To File ${LOG} ${result}${\n} +# Sleep 2s +# Should Contain ${result.stdout} failed 0 + +#Run ltp syscalls test suite +# [Documentation] Wait ~45m for syscalls to complete +# ${result}= Run Process ./runltp -f syscalls shell=yes cwd=/opt/ltp stdout=${LOG} +# Append To File ${LOG} ${result}${\n} +# Sleep 2s +# Should Contain ${result.stdout} failed 0 + +Run ltp syscalls madvise + [Documentation] Wait ~1m for madvise01-10 to complete + ${result}= Run Process ./runltp -f syscalls -s madvise shell=yes cwd=/opt/ltp stdout=${LOG} + Append To File ${LOG} ${result}${\n} + Sleep 2s + Should Contain ${result.stdout} failed 0 + +*** Keywords *** +Open Connection And Log In + Open Connection ${HOST} + Login ${ROOTUSER} ${ROOTPSWD} + diff --git a/tests/os/ltp/variables.resource b/tests/os/ltp/variables.resource new file mode 100644 index 0000000..6f46166 --- /dev/null +++ b/tests/os/ltp/variables.resource @@ -0,0 +1,23 @@ +############################################################################## +# Copyright (c) 2019 AT&T Intellectual Property. # +# Copyright (c) 2019 Nokia. # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you maynot 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. # +############################################################################## + +*** Variables *** +# Manual test: robot ltp.robot + +${HOST} aknode109 # cluster's master node address +${ROOTUSER} root # Required root user to log in to the host +${ROOTPSWD} root_passwd # Required root password to log in to the host diff --git a/ui/CHANGELOG.md b/ui/CHANGELOG.md index ac72112..6f41f59 100644 --- a/ui/CHANGELOG.md +++ b/ui/CHANGELOG.md @@ -116,3 +116,11 @@ All notable changes to this project will be documented in this file. ### Removed - Deletion of submissions + +## [0.1.0-SNAPSHOT] - 23 August 2019 +### Added + +### Changed + +### Removed +- Unused credentials in music.properties file diff --git a/ui/src/main/resources/music.properties b/ui/src/main/resources/music.properties index fa89354..f5c824a 100644 --- a/ui/src/main/resources/music.properties +++ b/ui/src/main/resources/music.properties @@ -18,14 +18,3 @@ zookeeper.host=135.197.226.103, 135.197.226.108, 135.197.226.119 cassandra.user=cassandra cassandra.password=cassandra -#Music API -#music.endpoint = http://vm-ep-dev4.research.att.com/MUSIC/rest/ -#music.version = v2 -#music.keyspace = keyspaces -#music.x.minor.version = 3 -#music.x.patch.version = 0 -#music.ns = com.att.ecomp.portal.demeter -#music.user.id = m00468@portal.ecomp.att.com -#music.password = friedG33nS- -#music.consistency.info = type -#music.consistency.info.value = eventual \ No newline at end of file