Skip to content
Snippets Groups Projects
Commit c48c46ca authored by Nikolay Stanchev's avatar Nikolay Stanchev
Browse files

Updated tests and install script for the clmc service

parent 00e90b39
Branches
Tags
No related merge requests found
...@@ -11,6 +11,25 @@ INFLUX_URL=$1 ...@@ -11,6 +11,25 @@ INFLUX_URL=$1
DATABASE_NAME=$2 DATABASE_NAME=$2
REPORT_PERIOD=$3 REPORT_PERIOD=$3
apt-get update
# Create the database for the WHOAMI API
apt-get install -y postgresql postgresql-contrib
sudo -u postgres bash -c "psql -c \"CREATE USER clmc WITH PASSWORD 'clmc_service';\""
sudo -u postgres bash -c "psql -c \"ALTER USER clmc CREATEDB;\""
sudo -u postgres createdb whoamidb
sudo -u postgres bash -c "psql -c \"GRANT ALL PRIVILEGES ON DATABASE \"whoamidb\" to clmc;\""
# install virtualenvwrapper to manage python environments - and check
echo "----> Installing Python3 and Pip3"
apt-get install -y python3 python3-pip wget curl
update-alternatives --install /usr/bin/python python /usr/bin/python3 10
echo "----> Installing virtualenv and wrapper"
apt-get install -y python3-virtualenv virtualenvwrapper
pip3 install virtualenv
pip3 install virtualenvwrapper
## CLMC-SERVICE ## CLMC-SERVICE
## ---------------------------------------------------------------------------------- ## ----------------------------------------------------------------------------------
echo "----> Configuring virtualenvwrapper" echo "----> Configuring virtualenvwrapper"
...@@ -50,10 +69,10 @@ if [ $? -ne 0 ] ; then ...@@ -50,10 +69,10 @@ if [ $? -ne 0 ] ; then
fi fi
# navigate to the clmc-webservice - and check # navigate to the clmc-webservice - and check
echo "----> Moving to CLMC webservice" echo "----> Moving to CLMC service"
cd ${REPO_ROOT}/src/service cd ${REPO_ROOT}/src/service
if [ $? -ne 0 ] ; then if [ $? -ne 0 ] ; then
echo "Failed: could not find clmc-webservice" echo "Failed: could not find clmc-service"
exit 1 exit 1
fi fi
...@@ -80,6 +99,14 @@ fi ...@@ -80,6 +99,14 @@ fi
echo "----> Creating CLMC web service log directory" echo "----> Creating CLMC web service log directory"
mkdir -p /var/log/flame/clmc mkdir -p /var/log/flame/clmc
# initialise the CLMC service database with the model tables
echo "----> Initialising CLMC database"
initialize_clmcservice_db production.ini
if [ $? -ne 0 ] ; then
echo "Failed: switching to CLMC python environment"
exit 1
fi
# Install minioclmc as systemctl service # Install minioclmc as systemctl service
# ----------------------------------------------------------------------- # -----------------------------------------------------------------------
mkdir -p /opt/flame/clmc mkdir -p /opt/flame/clmc
......
...@@ -11,17 +11,6 @@ KAPACITOR_CHECKSUM=eea9b215f241906570eafe3857e1d4c5 ...@@ -11,17 +11,6 @@ KAPACITOR_CHECKSUM=eea9b215f241906570eafe3857e1d4c5
CHRONOGRAF_VERSION=1.4.4.2 CHRONOGRAF_VERSION=1.4.4.2
CHRONOGRAF_CHECKSUM=eea6915aa6db8f134fcd3b095e863b773bfb3a16a26e346dd65904a07df97963 CHRONOGRAF_CHECKSUM=eea6915aa6db8f134fcd3b095e863b773bfb3a16a26e346dd65904a07df97963
# install virtualenvwrapper to manage python environments - and check
apt-get update
echo "----> Installing Python3 and Pip3"
apt-get install -y python3 python3-pip wget curl
update-alternatives --install /usr/bin/python python /usr/bin/python3 10
echo "----> Installing virtualenv and wrapper"
apt-get install -y python3-virtualenv virtualenvwrapper
pip3 install virtualenv
pip3 install virtualenvwrapper
# install influx # install influx
echo "----> Installing InfluxDB" echo "----> Installing InfluxDB"
wget https://dl.influxdata.com/influxdb/releases/influxdb_${INFLUX_VERSION}_amd64.deb 2> /dev/null wget https://dl.influxdata.com/influxdb/releases/influxdb_${INFLUX_VERSION}_amd64.deb 2> /dev/null
......
...@@ -204,7 +204,38 @@ class TestWhoamiAPI(object): ...@@ -204,7 +204,38 @@ class TestWhoamiAPI(object):
WhoamiAPI(request).put() WhoamiAPI(request).put()
except HTTPConflict: except HTTPConflict:
error_raised = True error_raised = True
assert error_raised, "PUT request validates unique constraint" assert error_raised, "PUT request breaks unique constraint"
@pytest.mark.parametrize("body, valid", [
('{"location": "DC1", "sfc": "sfc1", "sfc_i": "sfc_i1", "sf": "sf1", "sf_i": "sf_i1", "sf_endpoint": "sf_endpoint1", "sr": "sr1"}', True),
('{"location": "DC2", "sfc": "sfc2", "sfc_i": "sfc_i2", "sf": "sf2", "sf_i": "sf_i2", "sf_endpoint": "sf_endpoint2", "sr": "sr2"}', True),
('{}', False),
('{"location": "DC1", "sfc": "sfc1", "sfc_i": "sfc_i1", "sf": "sf1", "sf_i": "sf_i1"}', False),
('{"place": "DC2", "sfc": "sfc2", "sfc_i": "sfc_i2", "sf": "sf2", "sf_i": "sf_i2", "sf_endpoint": "sf_endpoint2", "sr": "sr2"}', False),
('{invalid json}', False),
])
def test_put_body_validation(self, body, valid):
"""
Tests the PUT request validation of the body content.
:param body: The request body to be validated
:param valid: True if body is valid, False otherwise
"""
sf_e = ServiceFunctionEndpoint(location="DC1", sfc="sfc1", sfc_i="sfc_i1", sf="sf1", sf_i="sf_i1", sf_endpoint="sf_endpoint1", sr="sr1")
ServiceFunctionEndpoint.add(sf_e) # adds the new instance of the model to the database
request = testing.DummyRequest()
request.params["sf_endpoint"] = "sf_endpoint1"
request.params["sf_i"] = "sf_i1"
request.params["sr"] = "sr1"
request.body = body.encode(request.charset)
error_raised = False
try:
WhoamiAPI(request).put()
except HTTPBadRequest:
error_raised = True
assert error_raised == (not valid), "An error must be raised in case of an invalid request body"
def test_delete(self): def test_delete(self):
""" """
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment