зеркало из https://github.com/mozilla/treeherder.git
first attemp of a end2end test
This commit is contained in:
Родитель
44992b68b5
Коммит
ec40464ee5
|
@ -0,0 +1,99 @@
|
|||
from django.core.urlresolvers import reverse
|
||||
import pytest
|
||||
from webtest.app import TestApp
|
||||
import simplejson as json
|
||||
from treeherder.webapp.wsgi import application
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def datasource_created():
|
||||
"""creates a new datasource for testing"""
|
||||
from django.conf import settings
|
||||
from treeherder.model.models import Datasource
|
||||
prefix = getattr(settings, "TEST_DB_PREFIX", "")
|
||||
for contenttype in ("objectstore","jobs"):
|
||||
Datasource.objects.create(
|
||||
project="mozilla-inbound",
|
||||
contenttype=contenttype,
|
||||
dataset=1,
|
||||
host='localhost',
|
||||
name="{}test_mozilla_inbound_{}_1".format(
|
||||
prefix,
|
||||
contenttype
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pending_jobs():
|
||||
"""returns a list of buildapi pending jobs"""
|
||||
return json.loads(open(
|
||||
os.path.join(os.path.dirname(__file__),"pending.json")
|
||||
).read())
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def running_jobs():
|
||||
"""returns a list of buildapi running jobs"""
|
||||
return json.loads(open(
|
||||
os.path.join(os.path.dirname(__file__),"running.json")
|
||||
).read())
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def completed_jobs(sample_data):
|
||||
"""returns a list of pulse completed jobs"""
|
||||
return json.loads(open(
|
||||
os.path.join(os.path.dirname(__file__),"finished.json")
|
||||
).read())
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pending_jobs_stored(pending_jobs):
|
||||
"""
|
||||
stores a list of buildapi pending jobs into the objectstore
|
||||
using BuildApiTreeHerderAdapter
|
||||
"""
|
||||
project = pending_jobs['sources'][0]['repository']
|
||||
url = reverse('objectstore-list', kwargs={"project": project})
|
||||
TestApp(application).post_json(url, params=pending_jobs)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def running_jobs_stored(running_jobs):
|
||||
"""
|
||||
stores a list of buildapi running jobs into the objectstore
|
||||
using BuildApiTreeHerderAdapter
|
||||
"""
|
||||
project = running_jobs['sources'][0]['repository']
|
||||
url = reverse('objectstore-list', kwargs={"project": project})
|
||||
TestApp(application).post_json(url, params=running_jobs)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def completed_jobs_stored(completed_jobs):
|
||||
project = completed_jobs['sources'][0]['repository']
|
||||
url = reverse('objectstore-list', kwargs={"project": project})
|
||||
TestApp(application).post_json(url, params=completed_jobs)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def jobs_model():
|
||||
from treeherder.model.derived import JobsModel
|
||||
return JobsModel('mozilla-inbound')
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pending_jobs_loaded(pending_jobs_stored, jobs_model):
|
||||
jobs_model.process_objects(1)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def running_jobs_loaded(running_jobs_stored, jobs_model):
|
||||
jobs_model.process_objects(1)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def completed_jobs_loaded(completed_jobs_stored, jobs_model):
|
||||
jobs_model.process_objects(1)
|
|
@ -0,0 +1,43 @@
|
|||
{"sources": [
|
||||
{
|
||||
"commit_timestamp": 1370459461,
|
||||
"push_timestamp": 1370459461,
|
||||
"comments": "Backed out changeset fe9dcdf48551 (bug 879374) for mochitest-3 crashes.",
|
||||
"repository": "mozilla-inbound",
|
||||
"revision": "a54df4462572"
|
||||
}
|
||||
], "job": {
|
||||
"submit_timestamp": 1370459521,
|
||||
"option_collection": {
|
||||
"opt": true
|
||||
},
|
||||
"who": "sendchange-unittest",
|
||||
"artifact": {},
|
||||
"machine_platform": {
|
||||
"platform": "2.2",
|
||||
"os_name": "android",
|
||||
"architecture": "ARMv7",
|
||||
"vm": false
|
||||
},
|
||||
"reason": "scheduler",
|
||||
"result": 0,
|
||||
"job_guid": "808f4f1372895eda5ecd65f2371ebe67a2a9af9b",
|
||||
"end_timestamp": "1370461182",
|
||||
"build_platform": {
|
||||
"platform": "2.2",
|
||||
"os_name": "android",
|
||||
"architecture": "ARMv7",
|
||||
"vm": false
|
||||
},
|
||||
"start_timestamp": 1370484722.0,
|
||||
"name": "xpcshell",
|
||||
"log_references": [
|
||||
{
|
||||
"url": "http://ftp.mozilla.org/pub/mozilla.org/mobile/tinderbox-builds/mozilla-inbound-android/1370454517/mozilla-inbound_tegra_android_test-xpcshell-bm22-tests1-tegra-build690.txt.gz",
|
||||
"name": "unittest"
|
||||
}
|
||||
],
|
||||
"machine": "tegra-132",
|
||||
"state": "TODO",
|
||||
"product_name": "mobile"
|
||||
}, "revision_hash": "0686a4d3fa477cb0415c9ca590177e4b03919b64"}
|
|
@ -0,0 +1,32 @@
|
|||
{"sources": [
|
||||
{
|
||||
"repository": "mozilla-inbound",
|
||||
"revision": "a54df4462572"
|
||||
}
|
||||
], "job": {
|
||||
"build_platform": {
|
||||
"platform": "2.2",
|
||||
"os_name": "android",
|
||||
"architecture": "ARMv7",
|
||||
"vm": false
|
||||
},
|
||||
"submit_timestamp": 1370459521,
|
||||
"state": "pending",
|
||||
"name": "xpcshell",
|
||||
"option_collection": {
|
||||
"opt": true
|
||||
},
|
||||
"log_references": [
|
||||
{
|
||||
"url": null,
|
||||
"name": "unittest"
|
||||
}
|
||||
],
|
||||
"job_guid": "808f4f1372895eda5ecd65f2371ebe67a2a9af9b",
|
||||
"machine_platform": {
|
||||
"platform": "2.2",
|
||||
"os_name": "android",
|
||||
"architecture": "ARMv7",
|
||||
"vm": false
|
||||
}
|
||||
}, "revision_hash": "0686a4d3fa477cb0415c9ca590177e4b03919b64"}
|
|
@ -0,0 +1,32 @@
|
|||
{"sources": [
|
||||
{
|
||||
"repository": "mozilla-inbound",
|
||||
"revision": "a54df4462572"
|
||||
}
|
||||
], "job": {
|
||||
"build_platform": {
|
||||
"platform": "2.2",
|
||||
"os_name": "android",
|
||||
"architecture": "ARMv7",
|
||||
"vm": false
|
||||
},
|
||||
"submit_timestamp": 1370459521,
|
||||
"state": "running",
|
||||
"name": "xpcshell",
|
||||
"option_collection": {
|
||||
"opt": true
|
||||
},
|
||||
"log_references": [
|
||||
{
|
||||
"url": null,
|
||||
"name": "unittest"
|
||||
}
|
||||
],
|
||||
"job_guid": "808f4f1372895eda5ecd65f2371ebe67a2a9af9b",
|
||||
"machine_platform": {
|
||||
"platform": "2.2",
|
||||
"os_name": "android",
|
||||
"architecture": "ARMv7",
|
||||
"vm": false
|
||||
}
|
||||
}, "revision_hash": "0686a4d3fa477cb0415c9ca590177e4b03919b64"}
|
|
@ -0,0 +1,49 @@
|
|||
from django.core.urlresolvers import reverse
|
||||
from webtest import TestApp
|
||||
from treeherder.webapp.wsgi import application
|
||||
|
||||
import logging
|
||||
logging.basicConfig(filename="test.log", level=logging.DEBUG)
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
def test_pending_job_available(datasource_created, pending_jobs_loaded):
|
||||
webapp = TestApp(application)
|
||||
resp = webapp.get(
|
||||
reverse("jobs-list", kwargs={"project": "mozilla-inbound"})
|
||||
)
|
||||
jobs = resp.json
|
||||
|
||||
print jobs
|
||||
|
||||
assert len(jobs) ==1
|
||||
|
||||
assert jobs[0]['status'] == 'pending'
|
||||
|
||||
|
||||
def test_running_job_available(datasource_created, running_jobs_loaded):
|
||||
webapp = TestApp(application)
|
||||
resp = webapp.get(
|
||||
reverse("jobs-list", kwargs={"project": "mozilla-inbound"})
|
||||
)
|
||||
jobs = resp.json
|
||||
|
||||
print jobs
|
||||
|
||||
assert len(jobs) ==1
|
||||
|
||||
assert jobs[0]['status'] == 'running'
|
||||
|
||||
|
||||
def test_completed_job_available(datasource_created, completed_jobs_loaded):
|
||||
webapp = TestApp(application)
|
||||
resp = webapp.get(
|
||||
reverse("jobs-list", kwargs={"project": "mozilla-inbound"})
|
||||
)
|
||||
jobs = resp.json
|
||||
|
||||
print jobs
|
||||
|
||||
assert len(jobs) ==1
|
||||
|
||||
assert jobs[0]['status'] == 'finished'
|
|
@ -260,6 +260,11 @@ class Datasource(models.Model):
|
|||
self.contenttype,
|
||||
self.dataset
|
||||
)
|
||||
|
||||
# a database name cannot contain the dash character
|
||||
if '-' in self.name:
|
||||
self.name = self.name.replace('-','_')
|
||||
|
||||
if not self.type:
|
||||
self.type = "mysql"
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче