Skip to content
Snippets Groups Projects
Commit 82f40e73 authored by Philip ABBET's avatar Philip ABBET
Browse files

[unittest] Ensures everything pass

parent 2eb9bdea
No related branches found
No related tags found
No related merge requests found
......@@ -42,7 +42,7 @@ import socket
CORES = psutil.cpu_count()
RAM = psutil.virtual_memory().total/(1024*1024)
ENVIRONMENT = {'name': 'Python 2.7', 'version': '1.1.0'}
ENVIRONMENT = {'name': 'Python 2.7', 'version': '1.2.0'}
CXX_ENVIRONMENT = {'name': 'Cxx backend', 'version': '1.0.0'}
ENVKEY = '%(name)s (%(version)s)' % ENVIRONMENT
CXX_ENVKEY = '%(name)s (%(version)s)' % CXX_ENVIRONMENT
......
......@@ -62,7 +62,7 @@ ONE_QUEUE_TWO_WORKERS = {
"cores-per-slot": 1,
"max-slots-per-user": 2,
"environments": [
'Python 2.7 (1.1.0)'
'Python 2.7 (1.2.0)'
],
"slots": {
'node1': {
......@@ -90,9 +90,9 @@ ONE_QUEUE_TWO_WORKERS = {
}
},
"environments": {
"Python 2.7 (1.1.0)": {
"Python 2.7 (1.2.0)": {
"name": 'Python 2.7',
"version": '1.1.0',
"version": '1.2.0',
"short_description": "Test",
"description": "Test environment",
"languages": "python",
......@@ -136,6 +136,9 @@ class BackendUtilitiesMixin(object):
install.install_contributions(prefix, 'system', template_data)
install.install_contributions(prefix, 'test', template_data)
if not os.path.exists(settings.CACHE_ROOT):
os.mkdir(settings.CACHE_ROOT)
def clean_cache(self):
for p, dirs, files in os.walk(settings.CACHE_ROOT, topdown=False):
......
......@@ -32,7 +32,6 @@ from time import sleep
from django.conf import settings
from django.test import TransactionTestCase
from .common import BaseBackendTestCase
from .common import BackendUtilitiesMixin
from .common import ONE_QUEUE_TWO_WORKERS
......@@ -62,8 +61,14 @@ class TestSchedulerBase(TransactionTestCase, BackendUtilitiesMixin):
self.worker_threads = {}
@classmethod
def setUpTestData(cls):
cls.setup_test_data()
def setUp(self):
self.tearDown()
self.shutdown_everything()
self.clean_cache()
TestSchedulerBase.setup_test_data()
setup_backend(ONE_QUEUE_TWO_WORKERS)
......@@ -71,6 +76,11 @@ class TestSchedulerBase(TransactionTestCase, BackendUtilitiesMixin):
def tearDown(self):
self.shutdown_everything()
self.clean_cache()
def shutdown_everything(self):
for name in list(self.worker_threads.keys()):
self.stop_worker(name)
......@@ -109,7 +119,9 @@ class TestSchedulerBase(TransactionTestCase, BackendUtilitiesMixin):
def check_worker_status(self, name, active):
start = time()
while Worker.objects.filter(name=name, active=active).count() == 0:
self.assertTrue(time() - start < 10) # Fail after 10 seconds
if time() - start > 10: # Fail after 10 seconds
self.shutdown_everything()
self.assertTrue(False)
#----------------------------------------------------------
......
......@@ -52,7 +52,7 @@ QUEUES_WITHOUT_PRIORITY = {
"time-limit": 180, #3 hours
"cores-per-slot": 1,
"max-slots-per-user": 4,
"environments": ['Python 2.7 (1.1.0)'],
"environments": ['Python 2.7 (1.2.0)'],
"groups": [
"Default",
],
......@@ -69,7 +69,7 @@ QUEUES_WITHOUT_PRIORITY = {
"time-limit": 360, #6 hours
"cores-per-slot": 2,
"max-slots-per-user": 2,
"environments": ['Python 2.7 (1.1.0)'],
"environments": ['Python 2.7 (1.2.0)'],
"groups": [
"Default",
],
......@@ -86,7 +86,7 @@ QUEUES_WITHOUT_PRIORITY = {
"time-limit": 720, #12 hours
"cores-per-slot": 4,
"max-slots-per-user": 1,
"environments": ['Python 2.7 (1.1.0)'],
"environments": ['Python 2.7 (1.2.0)'],
"groups": [
"Default",
],
......@@ -106,9 +106,9 @@ QUEUES_WITHOUT_PRIORITY = {
}
},
"environments": {
'Python 2.7 (1.1.0)': {
'Python 2.7 (1.2.0)': {
"name": 'Python 2.7',
"version": '1.1.0',
"version": '1.2.0',
"short_description": "Test",
"description": "Test environment",
"languages": "python",
......@@ -124,7 +124,7 @@ PRIORITY_QUEUES = {
"time-limit": 180, #3 hours
"cores-per-slot": 1,
"max-slots-per-user": 2,
"environments": ['Python 2.7 (1.1.0)'],
"environments": ['Python 2.7 (1.2.0)'],
"groups": [
"Default",
],
......@@ -145,7 +145,7 @@ PRIORITY_QUEUES = {
"time-limit": 360, #6 hours
"cores-per-slot": 2,
"max-slots-per-user": 1,
"environments": ['Python 2.7 (1.1.0)'],
"environments": ['Python 2.7 (1.2.0)'],
"groups": [
"Default",
],
......@@ -166,7 +166,7 @@ PRIORITY_QUEUES = {
"time-limit": 180, #3 hours
"cores-per-slot": 1,
"max-slots-per-user": 8,
"environments": ['Python 2.7 (1.1.0)'],
"environments": ['Python 2.7 (1.2.0)'],
"groups": [
"Default",
],
......@@ -196,9 +196,9 @@ PRIORITY_QUEUES = {
)
]),
"environments": {
'Python 2.7 (1.1.0)': {
'Python 2.7 (1.2.0)': {
"name": 'Python 2.7',
"version": '1.1.0',
"version": '1.2.0',
"short_description": "Test",
"description": "Test environment",
"languages": "python",
......@@ -284,7 +284,7 @@ class BackendSetup(BaseBackendTestCase):
env = q1.environments.first()
self.assertEqual(env.name, 'Python 2.7')
self.assertEqual(env.version, '1.1.0')
self.assertEqual(env.version, '1.2.0')
self.assertEqual(q1.slots.count(), 1)
self.assertEqual(q2.slots.count(), 1)
......@@ -393,7 +393,7 @@ class BackendSetup(BaseBackendTestCase):
env = q1.environments.first()
self.assertEqual(env.name, 'Python 2.7')
self.assertEqual(env.version, '1.1.0')
self.assertEqual(env.version, '1.2.0')
self.assertEqual(q1.slots.count(), 2)
self.assertEqual(q1_special.slots.count(), 2)
......
......@@ -47,7 +47,6 @@ from ..experiments.models import Experiment
from .models import Environment, Worker, Queue
from . import state
from . import utils
from . import schedule
#------------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment