Though bash is a good interactive user shell
and apart portability concerns,
many UN*X systems and GNU+Linux distributions now prefers Almquist
or Kornshell variants for scripting in order to improve the system
performance and maintenability.
https://wiki.ubuntu.com/DashAsBinSh
https://mywiki.wooledge.org/Bashism
https://en.wikipedia.org/wiki/Almquist_shell
Signed-off-by: guillaume.lambert <guillaume.lambert@orange.com>
Change-Id: I32c5490f9eab54e6cac594f3eac1e392edf8b272
18 files changed:
tox -e \
docs,pep8,pylint,yamllint,bashate,bandit,py38,cover
- stage: build functest-core images
tox -e \
docs,pep8,pylint,yamllint,bashate,bandit,py38,cover
- stage: build functest-core images
- script: sudo -E bash build.sh
+ script: sudo -E sh build.sh
env:
- REPO="${DOCKER_USERNAME}"
- amd64_dirs="docker/core"
- arm64_dirs=""
- arm_dirs=""
env:
- REPO="${DOCKER_USERNAME}"
- amd64_dirs="docker/core"
- arm64_dirs=""
- arm_dirs=""
- - script: sudo -E bash build.sh
+ - script: sudo -E sh build.sh
env:
- REPO="${DOCKER_USERNAME}"
- amd64_dirs=""
- arm64_dirs="docker/core"
- arm_dirs=""
env:
- REPO="${DOCKER_USERNAME}"
- amd64_dirs=""
- arm64_dirs="docker/core"
- arm_dirs=""
- - script: sudo -E bash build.sh
+ - script: sudo -E sh build.sh
env:
- REPO="${DOCKER_USERNAME}"
- amd64_dirs=""
env:
- REPO="${DOCKER_USERNAME}"
- amd64_dirs=""
--template ${DOCKER_USERNAME}/functest-core:ARCH-latest \
--target ${DOCKER_USERNAME}/functest-core:latest
- stage: build all functest images
--template ${DOCKER_USERNAME}/functest-core:ARCH-latest \
--target ${DOCKER_USERNAME}/functest-core:latest
- stage: build all functest images
- script: sudo -E bash build.sh
+ script: sudo -E sh build.sh
env:
- REPO="${DOCKER_USERNAME}"
- amd64_dirs="docker/healthcheck"
- arm64_dirs=""
- arm_dirs=""
env:
- REPO="${DOCKER_USERNAME}"
- amd64_dirs="docker/healthcheck"
- arm64_dirs=""
- arm_dirs=""
- - script: sudo -E bash build.sh
+ - script: sudo -E sh build.sh
env:
- REPO="${DOCKER_USERNAME}"
- amd64_dirs=""
- arm64_dirs="docker/healthcheck"
- arm_dirs=""
env:
- REPO="${DOCKER_USERNAME}"
- amd64_dirs=""
- arm64_dirs="docker/healthcheck"
- arm_dirs=""
- - script: sudo -E bash build.sh
+ - script: sudo -E sh build.sh
env:
- REPO="${DOCKER_USERNAME}"
- amd64_dirs=""
- arm64_dirs=""
- arm_dirs="docker/healthcheck"
env:
- REPO="${DOCKER_USERNAME}"
- amd64_dirs=""
- arm64_dirs=""
- arm_dirs="docker/healthcheck"
- - script: sudo -E bash build.sh
+ - script: sudo -E sh build.sh
env:
- REPO="${DOCKER_USERNAME}"
- amd64_dirs="docker/smoke"
- arm64_dirs=""
- arm_dirs=""
env:
- REPO="${DOCKER_USERNAME}"
- amd64_dirs="docker/smoke"
- arm64_dirs=""
- arm_dirs=""
- - script: sudo -E bash build.sh
+ - script: sudo -E sh build.sh
env:
- REPO="${DOCKER_USERNAME}"
- amd64_dirs=""
- arm64_dirs="docker/smoke"
- arm_dirs=""
env:
- REPO="${DOCKER_USERNAME}"
- amd64_dirs=""
- arm64_dirs="docker/smoke"
- arm_dirs=""
- - script: sudo -E bash build.sh
+ - script: sudo -E sh build.sh
env:
- REPO="${DOCKER_USERNAME}"
- amd64_dirs=""
- arm64_dirs=""
- arm_dirs="docker/smoke"
env:
- REPO="${DOCKER_USERNAME}"
- amd64_dirs=""
- arm64_dirs=""
- arm_dirs="docker/smoke"
- - script: sudo -E bash build.sh
+ - script: sudo -E sh build.sh
env:
- REPO="${DOCKER_USERNAME}"
- amd64_dirs="docker/benchmarking"
- arm64_dirs=""
- arm_dirs=""
env:
- REPO="${DOCKER_USERNAME}"
- amd64_dirs="docker/benchmarking"
- arm64_dirs=""
- arm_dirs=""
- - script: sudo -E bash build.sh
+ - script: sudo -E sh build.sh
env:
- REPO="${DOCKER_USERNAME}"
- amd64_dirs=""
- arm64_dirs="docker/benchmarking"
- arm_dirs=""
env:
- REPO="${DOCKER_USERNAME}"
- amd64_dirs=""
- arm64_dirs="docker/benchmarking"
- arm_dirs=""
- - script: sudo -E bash build.sh
+ - script: sudo -E sh build.sh
env:
- REPO="${DOCKER_USERNAME}"
- amd64_dirs=""
- arm64_dirs=""
- arm_dirs="docker/benchmarking"
env:
- REPO="${DOCKER_USERNAME}"
- amd64_dirs=""
- arm64_dirs=""
- arm_dirs="docker/benchmarking"
- - script: sudo -E bash build.sh
+ - script: sudo -E sh build.sh
env:
- REPO="${DOCKER_USERNAME}"
- amd64_dirs="docker/vnf"
- arm64_dirs=""
- arm_dirs=""
env:
- REPO="${DOCKER_USERNAME}"
- amd64_dirs="docker/vnf"
- arm64_dirs=""
- arm_dirs=""
- - script: sudo -E bash build.sh
+ - script: sudo -E sh build.sh
env:
- REPO="${DOCKER_USERNAME}"
- amd64_dirs=""
- arm64_dirs="docker/vnf"
- arm_dirs=""
env:
- REPO="${DOCKER_USERNAME}"
- amd64_dirs=""
- arm64_dirs="docker/vnf"
- arm_dirs=""
- - script: sudo -E bash build.sh
+ - script: sudo -E sh build.sh
env:
- REPO="${DOCKER_USERNAME}"
- amd64_dirs=""
env:
- REPO="${DOCKER_USERNAME}"
- amd64_dirs=""
--template ${DOCKER_USERNAME}/functest-vnf:ARCH-latest \
--target ${DOCKER_USERNAME}/functest-vnf:latest
- stage: build all functest cntt images
--template ${DOCKER_USERNAME}/functest-vnf:ARCH-latest \
--target ${DOCKER_USERNAME}/functest-vnf:latest
- stage: build all functest cntt images
- script: sudo -E bash build.sh
+ script: sudo -E sh build.sh
env:
- REPO="${DOCKER_USERNAME}"
- amd64_dirs="docker/smoke-cntt"
- arm64_dirs=""
- arm_dirs=""
env:
- REPO="${DOCKER_USERNAME}"
- amd64_dirs="docker/smoke-cntt"
- arm64_dirs=""
- arm_dirs=""
- - script: sudo -E bash build.sh
+ - script: sudo -E sh build.sh
env:
- REPO="${DOCKER_USERNAME}"
- amd64_dirs=""
- arm64_dirs="docker/smoke-cntt"
- arm_dirs=""
env:
- REPO="${DOCKER_USERNAME}"
- amd64_dirs=""
- arm64_dirs="docker/smoke-cntt"
- arm_dirs=""
- - script: sudo -E bash build.sh
+ - script: sudo -E sh build.sh
env:
- REPO="${DOCKER_USERNAME}"
- amd64_dirs=""
- arm64_dirs=""
- arm_dirs="docker/smoke-cntt"
env:
- REPO="${DOCKER_USERNAME}"
- amd64_dirs=""
- arm64_dirs=""
- arm_dirs="docker/smoke-cntt"
- - script: sudo -E bash build.sh
+ - script: sudo -E sh build.sh
env:
- REPO="${DOCKER_USERNAME}"
- amd64_dirs="docker/benchmarking-cntt"
- arm64_dirs=""
- arm_dirs=""
env:
- REPO="${DOCKER_USERNAME}"
- amd64_dirs="docker/benchmarking-cntt"
- arm64_dirs=""
- arm_dirs=""
- - script: sudo -E bash build.sh
+ - script: sudo -E sh build.sh
env:
- REPO="${DOCKER_USERNAME}"
- amd64_dirs=""
- arm64_dirs="docker/benchmarking-cntt"
- arm_dirs=""
env:
- REPO="${DOCKER_USERNAME}"
- amd64_dirs=""
- arm64_dirs="docker/benchmarking-cntt"
- arm_dirs=""
- - script: sudo -E bash build.sh
+ - script: sudo -E sh build.sh
env:
- REPO="${DOCKER_USERNAME}"
- amd64_dirs=""
env:
- REPO="${DOCKER_USERNAME}"
- amd64_dirs=""
wget https://downloads.raspberrypi.org/raspbian/images/raspbian-2018-11-15/2018-11-13-raspbian-stretch.zip
unzip 2018-11-13-raspbian-stretch.zip
sudo dd bs=4M if=2018-11-13-raspbian-stretch.img of=/dev/mmcblk0 conv=fsync
wget https://downloads.raspberrypi.org/raspbian/images/raspbian-2018-11-15/2018-11-13-raspbian-stretch.zip
unzip 2018-11-13-raspbian-stretch.zip
sudo dd bs=4M if=2018-11-13-raspbian-stretch.img of=/dev/mmcblk0 conv=fsync
curl -sSL https://get.docker.com | sudo sh
```
curl -sSL https://get.docker.com | sudo sh
```
export OS_REGION_NAME=XXX
```
export OS_REGION_NAME=XXX
```
-mkdir -p images && wget -q -O- https://git.opnfv.org/functest/plain/functest/ci/download_images.sh | bash -s -- images && ls -1 images/*
+mkdir -p images && wget -q -O- https://git.opnfv.org/functest/plain/functest/ci/download_images.sh | sh -s -- images && ls -1 images/*
```
images/cirros-0.5.1-aarch64-disk.img
images/cirros-0.5.1-x86_64-disk.img
```
images/cirros-0.5.1-aarch64-disk.img
images/cirros-0.5.1-x86_64-disk.img
sudo docker run --env-file env \
-v $(pwd)/openstack.creds:/home/opnfv/functest/conf/env_file \
-v $(pwd)/images:/home/opnfv/functest/images \
sudo docker run --env-file env \
-v $(pwd)/openstack.creds:/home/opnfv/functest/conf/env_file \
-v $(pwd)/images:/home/opnfv/functest/images \
sudo docker run --env-file env \
-v $(pwd)/openstack.creds:/home/opnfv/functest/conf/env_file \
-v $(pwd)/images:/home/opnfv/functest/images \
sudo docker run --env-file env \
-v $(pwd)/openstack.creds:/home/opnfv/functest/conf/env_file \
-v $(pwd)/images:/home/opnfv/functest/images \
sudo docker run --env-file env \
-v $(pwd)/openstack.creds:/home/opnfv/functest/conf/env_file \
-v $(pwd)/images:/home/opnfv/functest/images \
sudo docker run --env-file env \
-v $(pwd)/openstack.creds:/home/opnfv/functest/conf/env_file \
-v $(pwd)/images:/home/opnfv/functest/images \
## Run benchmarking suite
## Run benchmarking suite
sudo docker run --env-file env \
-v $(pwd)/openstack.creds:/home/opnfv/functest/conf/env_file \
-v $(pwd)/images:/home/opnfv/functest/images \
sudo docker run --env-file env \
-v $(pwd)/openstack.creds:/home/opnfv/functest/conf/env_file \
-v $(pwd)/images:/home/opnfv/functest/images \
## Run benchmarking CNTT suite
## Run benchmarking CNTT suite
sudo docker run --env-file env \
-v $(pwd)/openstack.creds:/home/opnfv/functest/conf/env_file \
-v $(pwd)/images:/home/opnfv/functest/images \
sudo docker run --env-file env \
-v $(pwd)/openstack.creds:/home/opnfv/functest/conf/env_file \
-v $(pwd)/images:/home/opnfv/functest/images \
sudo docker run --env-file env \
-v $(pwd)/openstack.creds:/home/opnfv/functest/conf/env_file \
-v $(pwd)/images:/home/opnfv/functest/images \
sudo docker run --env-file env \
-v $(pwd)/openstack.creds:/home/opnfv/functest/conf/env_file \
-v $(pwd)/images:/home/opnfv/functest/images \
docker/benchmarking-cntt"}
arm_dirs=${arm_dirs-${amd64_dirs}}
arm64_dirs=${arm64_dirs-${amd64_dirs}}
docker/benchmarking-cntt"}
arm_dirs=${arm_dirs-${amd64_dirs}}
arm64_dirs=${arm64_dirs-${amd64_dirs}}
-build_opts=("--pull=true" --no-cache "--force-rm=true")
+build_opts="--pull=true --no-cache --force-rm=true"
find . -name Dockerfile -exec sed -i \
-e "s|opnfv/functest-core|${repo}/functest-core:amd64-latest|g" {} +
find . -name Dockerfile -exec sed -i \
-e "s|opnfv/functest-core|${repo}/functest-core:amd64-latest|g" {} +
${repo}/functest-benchmarking:amd64-latest|g" {} +
for dir in ${amd64_dirs}; do
(cd "${dir}" &&
${repo}/functest-benchmarking:amd64-latest|g" {} +
for dir in ${amd64_dirs}; do
(cd "${dir}" &&
- docker build "${build_opts[@]}" \
+ docker build $build_opts \
-t "${repo}/functest-${dir##**/}:amd64-latest" .)
docker push "${repo}/functest-${dir##**/}:amd64-latest"
[ "${dir}" != "docker/core" ] &&
-t "${repo}/functest-${dir##**/}:amd64-latest" .)
docker push "${repo}/functest-${dir##**/}:amd64-latest"
[ "${dir}" != "docker/core" ] &&
-e "s|opnfv/functest-benchmarking|\
${repo}/functest-benchmarking:arm64-latest|g" {} +
for dir in ${arm64_dirs}; do
-e "s|opnfv/functest-benchmarking|\
${repo}/functest-benchmarking:arm64-latest|g" {} +
for dir in ${arm64_dirs}; do
- (cd "${dir}" && docker build "${build_opts[@]}" \
+ (cd "${dir}" && docker build $build_opts \
-t "${repo}/functest-${dir##**/}:arm64-latest" .)
docker push "${repo}/functest-${dir##**/}:arm64-latest"
[ "${dir}" != "docker/core" ] &&
-t "${repo}/functest-${dir##**/}:arm64-latest" .)
docker push "${repo}/functest-${dir##**/}:arm64-latest"
[ "${dir}" != "docker/core" ] &&
-e "s|opnfv/functest-benchmarking|\
${repo}/functest-benchmarking:arm-latest|g" {} +
for dir in ${arm_dirs}; do
-e "s|opnfv/functest-benchmarking|\
${repo}/functest-benchmarking:arm-latest|g" {} +
for dir in ${arm_dirs}; do
- (cd "${dir}" && docker build "${build_opts[@]}" \
+ (cd "${dir}" && docker build $build_opts \
-t "${repo}/functest-${dir##**/}:arm-latest" .)
docker push "${repo}/functest-${dir##**/}:arm-latest"
[ "${dir}" != "docker/core" ] &&
-t "${repo}/functest-${dir##**/}:arm-latest" .)
docker push "${repo}/functest-${dir##**/}:arm-latest"
[ "${dir}" != "docker/core" ] &&
from="${DOCKER_REPO%/*}/functest-core:${DOCKER_TAG}"
sed -i "s|^FROM.*$|FROM ${from}|" Dockerfile
from="${DOCKER_REPO%/*}/functest-core:${DOCKER_TAG}"
sed -i "s|^FROM.*$|FROM ${from}|" Dockerfile
mkdir -p /etc/xtesting && \
cp /src/functest/functest/ci/logging.ini /etc/xtesting/ && \
cp /src/functest/functest/ci/logging.debug.ini /etc/xtesting/ && \
mkdir -p /etc/xtesting && \
cp /src/functest/functest/ci/logging.ini /etc/xtesting/ && \
cp /src/functest/functest/ci/logging.debug.ini /etc/xtesting/ && \
- bash -c "mkdir -p /var/lib/xtesting /home/opnfv" && \
+ sh -c "mkdir -p /var/lib/xtesting /home/opnfv" && \
ln -s /var/lib/xtesting /home/opnfv/functest && \
ln -s /var/lib/xtesting /home/opnfv/functest && \
- bash -c "mkdir -p /home/opnfv/functest{/conf,/data,/images,/results} /home/opnfv/repos/vnfs" && \
+ sh -c "mkdir -p /home/opnfv/functest/conf /home/opnfv/functest/conf/data /home/opnfv/functest/conf/images /home/opnfv/functest/conf/results && \
+ mkdir -p /home/opnfv/repos/vnfs" && \
mkdir -p /etc/rally && \
printf "[database]\nconnection = 'sqlite:////var/lib/rally/database/rally.sqlite'\n" > /etc/rally/rally.conf && \
printf "\n[openstack]\nneutron_bind_l2_agent_types = Open vSwitch agent,Linux bridge agent,OVN Controller Gateway agent\n" >> /etc/rally/rally.conf && \
mkdir -p /etc/rally && \
printf "[database]\nconnection = 'sqlite:////var/lib/rally/database/rally.sqlite'\n" > /etc/rally/rally.conf && \
printf "\n[openstack]\nneutron_bind_l2_agent_types = Open vSwitch agent,Linux bridge agent,OVN Controller Gateway agent\n" >> /etc/rally/rally.conf && \
from="${DOCKER_REPO%/*}/functest-tempest:${DOCKER_TAG}"
sed -i "s|^FROM.*$|FROM ${from}|" Dockerfile
from="${DOCKER_REPO%/*}/functest-tempest:${DOCKER_TAG}"
sed -i "s|^FROM.*$|FROM ${from}|" Dockerfile
from="${DOCKER_REPO%/*}/functest-core:${DOCKER_TAG}"
sed -i "s|^FROM.*$|FROM ${from}|" Dockerfile
from="${DOCKER_REPO%/*}/functest-core:${DOCKER_TAG}"
sed -i "s|^FROM.*$|FROM ${from}|" Dockerfile
### 8 Functest containers
### 8 Functest containers
$ sudo docker search opnfv |grep functest-
opnfv/functest-core OPNFV Functest core image
opnfv/functest-restapi OPNFV Functest restapi image
$ sudo docker search opnfv |grep functest-
opnfv/functest-core OPNFV Functest core image
opnfv/functest-restapi OPNFV Functest restapi image
#### Retrieve all the images
```
#### Retrieve all the images
```
-mkdir -p images && wget -q -O- https://git.opnfv.org/functest/plain/functest/ci/download_images.sh | bash -s -- images && ls -1 images/*
+mkdir -p images && wget -q -O- https://git.opnfv.org/functest/plain/functest/ci/download_images.sh | sh -s -- images && ls -1 images/*
images/CentOS-7-aarch64-GenericCloud.qcow2
images/CentOS-7-aarch64-GenericCloud.qcow2.xz
images/CentOS-7-x86_64-GenericCloud.qcow2
images/CentOS-7-aarch64-GenericCloud.qcow2
images/CentOS-7-aarch64-GenericCloud.qcow2.xz
images/CentOS-7-x86_64-GenericCloud.qcow2
full CI/CD toolchains in few minutes** (Jenkins, Minio, TestAPI, MongoDB and
Docker registry)
full CI/CD toolchains in few minutes** (Jenkins, Minio, TestAPI, MongoDB and
Docker registry)
virtualenv xtesting
. xtesting/bin/activate
pip install ansible docker
virtualenv xtesting
. xtesting/bin/activate
pip install ansible docker
Create a directory for the different images (attached as a Docker volume)::
Create a directory for the different images (attached as a Docker volume)::
- mkdir -p images && wget -q -O- https://git.opnfv.org/functest/plain/functest/ci/download_images.sh | bash -s -- images && ls -1 images/*
+ mkdir -p images && wget -q -O- https://git.opnfv.org/functest/plain/functest/ci/download_images.sh | sh -s -- images && ls -1 images/*
images/cirros-0.5.1-aarch64-disk.img
images/cirros-0.5.1-x86_64-disk.img
images/cirros-0.5.1-aarch64-disk.img
images/cirros-0.5.1-x86_64-disk.img
-pushd "${1:-/home/opnfv/functest/images}" > /dev/null
+initdir=$(pwd)
+cd "${1:-/home/opnfv/functest/images}"
http_proxy_host=${http_proxy_host:-proxy}
http_proxy_port=${http_proxy_port:-8080}
http_proxy_host=${http_proxy_host:-proxy}
http_proxy_port=${http_proxy_port:-8080}
fi
guestmount -a "${image}" -i --rw "${tmpdir}"
add_proxy "${tmpdir}/etc/environment"
fi
guestmount -a "${image}" -i --rw "${tmpdir}"
add_proxy "${tmpdir}/etc/environment"
- if [[ ${image} == "ubuntu"* ]]; then
+ if expr "$image" : 'ubuntu' ; then
add_proxy_apt "${tmpdir}/etc/apt/apt.conf"
add_proxy_juju_env "${tmpdir}/etc/juju-proxy.conf"
add_proxy_juju_systemd "${tmpdir}/etc/juju-proxy-systemd.conf"
add_proxy_apt "${tmpdir}/etc/apt/apt.conf"
add_proxy_juju_env "${tmpdir}/etc/juju-proxy.conf"
add_proxy_juju_systemd "${tmpdir}/etc/juju-proxy-systemd.conf"
-pushd "${1:-/home/opnfv/functest/images}"
+initdir=$(pwd)
+
+cd "${1:-/home/opnfv/functest/images}"
for i in *.img *.qcow2; do
qemu-img convert -f qcow2 -O vmdk "$i" "${i%.*}.vmdk"
done
for i in *.img *.qcow2; do
qemu-img convert -f qcow2 -O vmdk "$i" "${i%.*}.vmdk"
done
"""
Returns the post VM creation script to be added into the VM's userdata
:param test_ip: the IP value to substitute into the script
"""
Returns the post VM creation script to be added into the VM's userdata
:param test_ip: the IP value to substitute into the script
- :return: the bash script contents
+ :return: the shell script contents
"""
ip4 = self.vm1.private_v4 or self.vm1.addresses[
self.network.name][0].addr
"""
ip4 = self.vm1.private_v4 or self.vm1.addresses[
self.network.name][0].addr
subscript = f' PROXY={self.bono_ip} ELLIS={self.ellis_ip}'
script = f'{script}{subscript}'
script = f'{script} --trace'
subscript = f' PROXY={self.bono_ip} ELLIS={self.ellis_ip}'
script = f'{script}{subscript}'
script = f'{script} --trace'
- cmd = f"/bin/bash -c '{script}'"
+ cmd = f"/bin/sh -c '{script}'"
self.logger.debug('Live test cmd: %s', cmd)
output_file = os.path.join(self.result_dir, "ims_test_output.txt")
ft_utils.execute_command(cmd,
self.logger.debug('Live test cmd: %s', cmd)
output_file = os.path.join(self.result_dir, "ims_test_output.txt")
ft_utils.execute_command(cmd,
[testenv:perm]
basepython = python3.10
[testenv:perm]
basepython = python3.10
-whitelist_externals = bash
+whitelist_externals = sh
path=. -not -path './.tox/*' -not -path './.git/*' -not -path './docs/com/pres/reveal.js/*'
commands =
path=. -not -path './.tox/*' -not -path './.git/*' -not -path './docs/com/pres/reveal.js/*'
commands =
find {[testenv:perm]path} \( -type f -not -perm 644 -o -type d -not -perm 755 \) \
-exec ls -l \{\} + | grep '.' && exit 1 || exit 0"
find {[testenv:perm]path} \( -type f -not -perm 644 -o -type d -not -perm 755 \) \
-exec ls -l \{\} + | grep '.' && exit 1 || exit 0"
find {[testenv:perm]path} -exec file \{\} + | grep CRLF && exit 1 || exit 0"
find {[testenv:perm]path} -exec file \{\} + | grep CRLF && exit 1 || exit 0"