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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
# Run with something like
#
# env GN2_PROFILE=/home/wrk/opt/gn-latest ./bin/genenetwork2 ./gn2/default_settings.py -c ../test/requests/test-website.py http://localhost:5003
#
# Mostly to pick up the Guix GN2_PROFILE and python modules
import argparse
from link_checker import check_links
from link_checker import check_packaged_js_files
from mapping_tests import check_mapping
from navigation_tests import check_navigation
from correlation_tests import check_correlations, check_correlations_correctness
from main_web_functionality import check_main_web_functionality
import link_checker
import sys
# Imports for integration tests
from unittest import TestSuite, TextTestRunner, TestLoader
print("Mechanical Rob firing up...")
def host_is_online(host):
import time
import requests
for count in range(1, 5):
try:
time.sleep(count)
requests.get(host, verify=False)
return True
except Exception as cre:
print(f"Retrying in {count + 1} seconds ...")
print(f"Error: {cre}")
return False
def run_all(args_obj, parser):
print("")
print("Running all tests.")
print(args_obj)
assert host_is_online(args_obj.host), f"Could not connect to {args_obj.host}"
link_checker.DO_FAIL = args_obj.fail
check_main_web_functionality(args_obj, parser)
check_links(args_obj, parser)
check_packaged_js_files(args_obj, parser)
check_mapping(args_obj, parser)
check_correlations(args_obj, parser)
# check_correlations_correctness(args_obj, parser)
# TODO: Add other functions as they are created.
def print_help(args_obj, parser):
print(parser.format_help())
def dummy(args_obj, parser):
print("Not implemented yet.")
def initTest(klass, gn2_url, es_url):
loader = TestLoader()
methodNames = loader.getTestCaseNames(klass)
return [klass(mname, gn2_url, es_url) for mname in methodNames]
desc = """
This is Mechanical-Rob - an automated web server tester for
Genenetwork.org
"""
parser = argparse.ArgumentParser(description=desc)
parser.add_argument("--fail", help="Fail and stop on any error", action="store_true")
parser.add_argument(
"-d",
"--database",
metavar="DB",
type=str,
default="db_webqtl_s",
help="Use database (default db_webqtl_s)",
)
parser.add_argument(
"host",
metavar="HOST",
type=str,
default="http://localhost:5003",
help="The url to the web server",
)
parser.add_argument(
"-a",
"--all",
dest="accumulate",
action="store_const",
const=run_all,
default=print_help,
help="Runs all tests.",
)
parser.add_argument(
"-l",
"--link-checker",
dest="accumulate",
action="store_const",
const=check_links,
default=print_help,
help="Checks for dead links.",
)
parser.add_argument(
"-f",
"--main-functionality",
dest="accumulate",
action="store_const",
const=check_main_web_functionality,
default=print_help,
help="Checks for main web functionality.",
)
parser.add_argument(
"-m",
"--mapping",
dest="accumulate",
action="store_const",
const=check_mapping,
default=print_help,
help="Checks for mapping.",
)
parser.add_argument(
"-c",
"--correlations",
dest="accumulate",
action="store_const",
const=check_correlations,
default=print_help,
help="Checks that correlations run correctly.",
)
parser.add_argument(
"-e",
"--correlations-correctness",
dest="accumulate",
action="store_const",
const=check_correlations_correctness,
default=print_help,
help="Check that the correlation results are correct"
)
args = parser.parse_args()
args.accumulate(args, parser)
|