Skip to content

Commit 558cf96

Browse files
committed
ref(*): mock the k8s API interactions and remove Container model
This change removes the Container model as it is redundant and changes around the MockScheduler to instead mock out actual k8s API calls and responses to get real testing of the scheduler code. Chaos scheduler was ripped temporarily but will be readded in the future (see #412) More logic needs to go into the mock handling to deal with pod transitions Fixes #29, #60
1 parent ca32f94 commit 558cf96

36 files changed

Lines changed: 1258 additions & 1344 deletions

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ test-style:
6767

6868
test-unit:
6969
cd rootfs \
70-
&& coverage run manage.py test --noinput registry api \
70+
&& coverage run manage.py test --settings=deis.testing --noinput registry api \
7171
&& coverage report -m
7272

7373
test-unit-quick:
7474
cd rootfs \
75-
&& ./manage.py test --noinput --parallel ${TEST_PROCS} --noinput registry api
75+
&& ./manage.py test --settings=deis.testing --noinput --parallel ${TEST_PROCS} --noinput registry api
7676

7777
test-functional:
7878
@echo "Implement functional tests in _tests directory"

rootfs/.coveragerc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ omit =
44
*/virtualenv/*
55
*tests*
66
api/__init__.py
7-
scheduler/*
7+
scheduler/mock.py
88
# osx library files when not running in virtualenv
99
/Library/*
1010
/System/*

rootfs/api/admin.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from .models import App
1212
from .models import Build
1313
from .models import Config
14-
from .models import Container
1514
from .models import Domain
1615
from .models import Key
1716
from .models import Release
@@ -47,16 +46,6 @@ class ConfigAdmin(admin.ModelAdmin):
4746
admin.site.register(Config, ConfigAdmin)
4847

4948

50-
class ContainerAdmin(admin.ModelAdmin):
51-
"""Set presentation options for :class:`~api.models.Container` models
52-
in the Django admin.
53-
"""
54-
date_hierarchy = 'created'
55-
list_display = ('short_name', 'owner', 'app', 'state')
56-
list_filter = ('owner', 'app')
57-
admin.site.register(Container, ContainerAdmin)
58-
59-
6049
class DomainAdmin(admin.ModelAdmin):
6150
"""Set presentation options for :class:`~api.models.Domain` models
6251
in the Django admin.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# -*- coding: utf-8 -*-
2+
# Generated by Django 1.9.1 on 2016-02-26 23:35
3+
from __future__ import unicode_literals
4+
5+
from django.db import migrations
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
dependencies = [
11+
('api', '0006_auto_20160114_0313'),
12+
]
13+
14+
operations = [
15+
migrations.RemoveField(
16+
model_name='container',
17+
name='app',
18+
),
19+
migrations.RemoveField(
20+
model_name='container',
21+
name='owner',
22+
),
23+
migrations.RemoveField(
24+
model_name='container',
25+
name='release',
26+
),
27+
migrations.DeleteModel(
28+
name='Container',
29+
),
30+
]

rootfs/api/models/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class Meta:
5454
@property
5555
def _scheduler(self):
5656
mod = importlib.import_module(settings.SCHEDULER_MODULE)
57-
return mod.SchedulerClient(settings.SCHEDULER_URL)
57+
return mod.SchedulerClient()
5858

5959
def _fetch_service_config(self, app):
6060
# Get the service from k8s to attach the domain correctly
@@ -110,7 +110,6 @@ class Meta:
110110

111111

112112
from .app import App, validate_id_is_docker_compatible, validate_reserved_names, validate_app_structure # noqa
113-
from .container import Container # noqa
114113
from .push import Push # noqa
115114
from .key import Key, validate_base64 # noqa
116115
from .certificate import Certificate, validate_certificate # noqa

0 commit comments

Comments
 (0)