Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature.integrationtestsh improvements #157

Merged
merged 7 commits into from
Feb 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions docker/api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ COPY config/*.yml /etc/cnaas-nms/

# Setup script
COPY cnaas-setup.sh /opt/cnaas/
RUN /opt/cnaas/cnaas-setup.sh $BUILDBRANCH
COPY cnaas-setup-branch.sh /opt/cnaas/
RUN /opt/cnaas/cnaas-setup.sh

# Prepare for supervisord, uwsgi, ngninx
COPY nosetests.sh /opt/cnaas/
Expand All @@ -24,10 +25,6 @@ COPY config/nginx_app.conf /etc/nginx/sites-available/
COPY config/nginx.conf /etc/nginx/
COPY cert/* /etc/nginx/conf.d/

# Websocket test client
RUN mkdir /opt/cnaas/static/
COPY client.html /opt/cnaas/static/

# Give nginx some special treatment
RUN unlink /etc/nginx/sites-enabled/default
RUN ln -s /etc/nginx/sites-available/nginx_app.conf /etc/nginx/sites-enabled/default
Expand All @@ -50,6 +47,10 @@ RUN chown root:www-data /opt/cnaas/*.sh && \
chmod g+rx /opt/cnaas/*.sh
RUN chown -R www-data:www-data /opt/cnaas/venv/cnaas-nms/src/

# Branch specific, don't cache
ADD "https://api.github.com/repos/SUNET/cnaas-nms/git/refs/heads/" latest_commit
RUN /opt/cnaas/cnaas-setup-branch.sh $BUILDBRANCH


# Expose HTTPS
EXPOSE 1443
Expand Down
17 changes: 0 additions & 17 deletions docker/api/client.html

This file was deleted.

11 changes: 11 additions & 0 deletions docker/api/cnaas-setup-branch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

set -e
set -x

# Temporary for testing new branch
if [ "$1" != "develop" ] ; then
cd /opt/cnaas/venv/cnaas-nms/
git checkout --track origin/$1
python3 -m pip install -r requirements.txt
fi
7 changes: 0 additions & 7 deletions docker/api/cnaas-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,6 @@ cd cnaas-nms/
git checkout develop
python3 -m pip install -r requirements.txt

# Temporary for testing new branch
if [ "$1" != "develop" ] ; then
cd /opt/cnaas/venv/cnaas-nms/
git checkout --track origin/$1
python3 -m pip install -r requirements.txt
fi

chown -R www-data:www-data /opt/cnaas/settings
chown -R www-data:www-data /opt/cnaas/templates
#rm -rf /var/lib/apt/lists/*
Expand Down
7 changes: 5 additions & 2 deletions test/integrationtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,10 @@ def test_04_syncto_access(self):
verify=TLS_VERIFY
)
self.assertEqual(r.status_code, 200, "Failed to do sync_to access")
self.check_jobid(r.json()['job_id'])
auto_job1 = self.check_jobid(r.json()['job_id'])
self.assertEqual(type(auto_job1['next_job_id']), int, "No auto-push commit job found")
self.check_jobid(auto_job1['next_job_id'])


def test_05_syncto_dist(self):
r = requests.post(
Expand Down Expand Up @@ -247,7 +250,7 @@ def test_08_firmware(self):
verify=TLS_VERIFY
)
# TODO: not working
#self.assertEqual(r.status_code, 200, "Failed to list firmware")
self.assertEqual(r.status_code, 200, "Failed to list firmware")

def test_09_sysversion(self):
r = requests.get(
Expand Down
29 changes: 27 additions & 2 deletions test/integrationtests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@ export PASSWORD_MANAGED="abc123abc123"
export COVERAGE=1
export JWT_AUTH_TOKEN="eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NiJ9.eyJpYXQiOjE1NzEwNTk2MTgsIm5iZiI6MTU3MTA1OTYxOCwianRpIjoiNTQ2MDk2YTUtZTNmOS00NzFlLWE2NTctZWFlYTZkNzA4NmVhIiwic3ViIjoiYWRtaW4iLCJmcmVzaCI6ZmFsc2UsInR5cGUiOiJhY2Nlc3MifQ.Sfffg9oZg_Kmoq7Oe8IoTcbuagpP6nuUXOQzqJpgDfqDq_GM_4zGzt7XxByD4G0q8g4gZGHQnV14TpDer2hJXw"

docker-compose down

if docker volume ls | egrep -q "cnaas-postgres-data$"
then
if [ -z "$AUTOTEST" ]
then
read -p "Do you want to continue and reset existing SQL database? [y/N]" ans
case $ans in
[Yy]* ) docker volume rm cnaas-postgres-data;;
* ) exit 1;;
esac
else
docker volume rm cnaas-postgres-data
fi
fi

docker volume create cnaas-templates
docker volume create cnaas-settings
docker volume create cnaas-postgres-data
Expand All @@ -28,8 +44,17 @@ docker volume create cnaas-cacert
docker-compose up -d

docker cp ./jwt-cert/public.pem docker_cnaas_api_1:/opt/cnaas/jwtcert/public.pem
docker-compose exec cnaas_api /bin/chown -R www-data:www-data /opt/cnaas/jwtcert/
docker-compose exec cnaas_api /opt/cnaas/createca.sh
docker-compose exec -T cnaas_api /bin/chown -R www-data:www-data /opt/cnaas/jwtcert/
docker-compose exec -T cnaas_api /opt/cnaas/createca.sh

if [ ! -z "$PRE_TEST_SCRIPT" ]
then
if [ -x "$PRE_TEST_SCRIPT" ]
then
echo "Running PRE_TEST_SCRIPT..."
bash -c $PRE_TEST_SCRIPT
fi
fi

# go back to test dir
popd
Expand Down