Commit b293c320 authored by Nicolas Wavrant's avatar Nicolas Wavrant

runner: tests adapted to the use of supervisord

parent 504c884b
...@@ -17,6 +17,7 @@ import hashlib ...@@ -17,6 +17,7 @@ import hashlib
import json import json
import os import os
import shutil import shutil
import sup_process
import time import time
import unittest import unittest
...@@ -137,9 +138,9 @@ class SlaprunnerTestCase(unittest.TestCase): ...@@ -137,9 +138,9 @@ class SlaprunnerTestCase(unittest.TestCase):
if os.path.exists(self.app.config['software_link']): if os.path.exists(self.app.config['software_link']):
shutil.rmtree(self.app.config['software_link']) shutil.rmtree(self.app.config['software_link'])
#Stop process #Stop process
killRunningProcess('slapproxy', recursive=True) sup_process.killRunningProcess(self.app.config, 'slapproxy')
killRunningProcess('slapgrid-cp', recursive=True) sup_process.killRunningProcess(self.app.config, 'slapgrid-cp')
killRunningProcess('slapgrid-sr', recursive=True) sup_process.killRunningProcess(self.app.config, 'slapgrid-sr')
def updateConfigParameter(self, parameter, value): def updateConfigParameter(self, parameter, value):
config_parser = ConfigParser.SafeConfigParser() config_parser = ConfigParser.SafeConfigParser()
...@@ -186,10 +187,10 @@ class SlaprunnerTestCase(unittest.TestCase): ...@@ -186,10 +187,10 @@ class SlaprunnerTestCase(unittest.TestCase):
def proxyStatus(self, status=True, sleep_time=0): def proxyStatus(self, status=True, sleep_time=0):
"""Helper for testslapproxy status""" """Helper for testslapproxy status"""
proxy = isRunning('slapproxy') proxy = sup_process.isRunning(self.app.config, 'slapproxy')
if proxy != status and sleep_time != 0: if proxy != status and sleep_time != 0:
time.sleep(sleep_time) time.sleep(sleep_time)
proxy = isRunning('slapproxy') proxy = sup_process.isRunning(self.app.config, 'slapproxy')
self.assertEqual(proxy, status) self.assertEqual(proxy, status)
def setupProjectFolder(self, withSoftware=False): def setupProjectFolder(self, withSoftware=False):
...@@ -232,7 +233,7 @@ class SlaprunnerTestCase(unittest.TestCase): ...@@ -232,7 +233,7 @@ class SlaprunnerTestCase(unittest.TestCase):
def stopSlapproxy(self): def stopSlapproxy(self):
"""Kill slapproxy process""" """Kill slapproxy process"""
killRunningProcess('slapproxy', recursive=True) pass
def test_configAccount(self): def test_configAccount(self):
"""For the first lauch of slaprunner user need do create first account""" """For the first lauch of slaprunner user need do create first account"""
...@@ -256,12 +257,8 @@ class SlaprunnerTestCase(unittest.TestCase): ...@@ -256,12 +257,8 @@ class SlaprunnerTestCase(unittest.TestCase):
def test_startStopProxy(self): def test_startStopProxy(self):
"""Test slapproxy""" """Test slapproxy"""
self.stopSlapproxy()
self.proxyStatus(False)
startProxy(self.app.config) startProxy(self.app.config)
self.proxyStatus(True) self.proxyStatus(True)
self.stopSlapproxy()
self.proxyStatus(False, sleep_time=1)
def test_cloneProject(self): def test_cloneProject(self):
"""Start scenario 1 for deploying SR: Clone a project from git repository""" """Start scenario 1 for deploying SR: Clone a project from git repository"""
...@@ -408,7 +405,6 @@ class SlaprunnerTestCase(unittest.TestCase): ...@@ -408,7 +405,6 @@ class SlaprunnerTestCase(unittest.TestCase):
def test_requestInstance(self): def test_requestInstance(self):
"""Scenarion 6: request software instance""" """Scenarion 6: request software instance"""
self.test_updateInstanceParameter() self.test_updateInstanceParameter()
self.proxyStatus(False, sleep_time=1)
#run Software profile #run Software profile
response = loadJson(self.app.post('/runSoftwareProfile', response = loadJson(self.app.post('/runSoftwareProfile',
data=dict(), data=dict(),
...@@ -459,7 +455,7 @@ class SlaprunnerTestCase(unittest.TestCase): ...@@ -459,7 +455,7 @@ class SlaprunnerTestCase(unittest.TestCase):
self.assertEqual(response, "2") self.assertEqual(response, "2")
# Test that the new call to isSoftwareReleaseReady # Test that the new call to isSoftwareReleaseReady
# doesn't overwrite the previous installed one # doesn't overwrite the previous installed one
killRunningProcess('slapgrid-sr') sup_process.killRunningProcess(self.app.config, 'slapgrid-sr')
completed_path = os.path.join(self.app.config['runner_workdir'], completed_path = os.path.join(self.app.config['runner_workdir'],
'softwareLink', 'slaprunner-test', '.completed') 'softwareLink', 'slaprunner-test', '.completed')
completed_text = ".completed file: test" completed_text = ".completed file: test"
...@@ -538,7 +534,7 @@ class SlaprunnerTestCase(unittest.TestCase): ...@@ -538,7 +534,7 @@ class SlaprunnerTestCase(unittest.TestCase):
only by changing the value of slapos.cfg config file. This can happen when only by changing the value of slapos.cfg config file. This can happen when
slapgrid processes the webrunner's partition. slapgrid processes the webrunner's partition.
""" """
config_file = os.path.join(self.app.config['etc_dir'], 'slapos.cfg') config_file = os.path.join(self.app.config['etc_dir'], 'slapos-test.cfg')
runner_config_old = os.environ['RUNNER_CONFIG'] runner_config_old = os.environ['RUNNER_CONFIG']
os.environ['RUNNER_CONFIG'] = config_file os.environ['RUNNER_CONFIG'] = config_file
open(config_file, 'w').write("[section]\nvar=value") open(config_file, 'w').write("[section]\nvar=value")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment