1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
import os
import string
from util import *
from py2neo import Graph, Node, Relationship
from bundle import Bundle
class Neo4JDatabase(object):
def __init__(self, endpoint):
self.endpoint = endpoint
def store_bundle(self, bundle):
if not isinstance(bundle, Bundle):
raise Exception("argument is not a Bundle")
graph = Graph(self.endpoint)
print "creating graph for bundle"
# axis:
# find (or create) the OS version + distro node
os_version = bundle.metadata["lava_job_attributes"]["os-version"]
os_distro = bundle.metadata["lava_job_attributes"]["os-distro"]
os_name = "%s/%s" % (os_distro, os_version)
OS_node = graph.find_one("OS", "name", os_name)
if not OS_node:
OS_node = Node("OS", name=os_name, distro=os_distro, version=os_version)
graph.create(OS_node)
# axis:
# find (or create) the devstack branch node
devstack_branch = bundle.metadata["lava_job_attributes"]["devstack-branch"]
Branch_node = graph.find_one("Branch", "name", devstack_branch)
if not Branch_node:
Branch_node = Node("Branch", name=devstack_branch)
graph.create(Branch_node)
# create the main tempest run node and associate with the OS and Branch
TempestRun_node = Node("Run", "Tempest", \
date = bundle.metadata["date_uploaded"], \
epoch_time = bundle.metadata["timestamp_uploaded"], \
lava_job = bundle.metadata["lava_job_id"], \
sha1 = bundle.metadata["bundle_sha1"])
if bundle.all_tests:
TempestRun_node.properties["all_tests"] = len(bundle.all_tests)
if bundle.tests_run:
TempestRun_node.properties["tests_run"] = len(bundle.tests_run)
if bundle.failing_tests:
TempestRun_node.properties["failing_tests"] = len(bundle.failing_tests)
if bundle.skipped_tests:
TempestRun_node.properties["skipped_tests"] = len(bundle.skipped_tests)
if bundle.passing_tests:
TempestRun_node.properties["passing_tests"] = len(bundle.passing_tests)
OS_relationship = Relationship(TempestRun_node, "ON", OS_node)
Branch_relationship = Relationship(TempestRun_node, "USING", Branch_node)
graph.create(TempestRun_node, OS_relationship, Branch_relationship)
# create all of the tests and relate them back to the tempest node
for test_set in [bundle.failing_tests, bundle.passing_tests, bundle.skipped_tests]:
if test_set:
print "adding tests"
for test in test_set:
Test_node = Node("Test", test["status"], \
name=test["test"], \
status=test["status"], \
start_time=test["start_time"], \
stop_time=test["stop_time"], \
test_class=test["class"])
Test_relationship = Relationship(TempestRun_node, \
"HAS_TEST", Test_node, status=test["status"])
graph.create(Test_node, Test_relationship)
|