Skip to content
This repository was archived by the owner on Jun 13, 2024. It is now read-only.

Commit 056b491

Browse files
authored
Use the event repository from new ETOS API. (#13)
1 parent ba4593b commit 056b491

File tree

2 files changed

+20
-21
lines changed

2 files changed

+20
-21
lines changed

src/etos_client/__main__.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ def parse_args(args):
6363
parser = argparse.ArgumentParser(
6464
description="Client for executing test automation suites in ETOS"
6565
)
66+
parser.add_argument(
67+
"cluster",
68+
help="Cluster is the URL to the ETOS API.",
69+
)
6670
parser.add_argument(
6771
"-i",
6872
"--identity",
@@ -124,11 +128,6 @@ def parse_args(args):
124128
),
125129
)
126130

127-
parser.add_argument(
128-
"--cluster",
129-
default=Debug().etos_api,
130-
help="Cluster should be in the form of URL to tester-api.",
131-
)
132131
parser.add_argument(
133132
"--version",
134133
action="version",
@@ -165,7 +164,7 @@ def check_etos_connectivity(url):
165164
:type url: str
166165
"""
167166
try:
168-
response = requests.head(url, timeout=5)
167+
response = requests.get(url, timeout=5)
169168
response.raise_for_status()
170169
except Exception as exception: # pylint:disable=broad-except
171170
raise Exception(
@@ -273,7 +272,6 @@ def main(args):
273272
"""
274273
args = parse_args(args)
275274
etos = ETOS("ETOS Client", os.getenv("HOSTNAME"), "ETOS Client")
276-
os.environ["ETOS_TESTER_API"] = args.cluster
277275

278276
setup_logging(args.loglevel)
279277
info = generate_spinner(args.no_tty)
@@ -285,11 +283,11 @@ def main(args):
285283
etos.config.set("dataset", json.loads(args.dataset))
286284

287285
with info(text="Checking connectivity to ETOS", spinner="dots") as spinner:
288-
spinner.info("Running in cluster: '{}'".format(etos.debug.etos_api))
286+
spinner.info("Running in cluster: '{}'".format(args.cluster))
289287
spinner.info("Configuration:")
290288
spinner.info("{}".format(etos.config.config))
291289
try:
292-
check_etos_connectivity(etos.debug.etos_api)
290+
check_etos_connectivity(f"{args.cluster}/selftest/ping")
293291
except Exception as exception: # pylint:disable=broad-except
294292
spinner.fail(str(exception))
295293
sys.exit(1)
@@ -298,7 +296,7 @@ def main(args):
298296
spinner.succeed("Ready to launch ETOS.")
299297

300298
# Start execution
301-
etos_client = ETOSClient(etos)
299+
etos_client = ETOSClient(etos, args.cluster)
302300
spinner.start("Triggering ETOS.")
303301
success = etos_client.start(spinner)
304302
if not success:
@@ -307,6 +305,8 @@ def main(args):
307305
sys.exit(not success)
308306
spinner.info("Suite ID: {}".format(etos_client.test_suite_id))
309307
etos.config.set("suite_id", etos_client.test_suite_id)
308+
os.environ["ETOS_GRAPHQL_SERVER"] = etos_client.event_repository
309+
spinner.info("Event repository: '{}'".format(etos.debug.graphql_server))
310310

311311
# Wait for test results
312312
test_result_handler = ETOSTestResultHandler(etos)

src/etos_client/client.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,19 @@
2121

2222
class ETOSClient:
2323
"""Client for starting test suites in ETOS."""
24+
event_repository = None
25+
test_suite_id = None
2426

25-
def __init__(self, etos):
27+
def __init__(self, etos, cluster):
2628
"""Initialize ETOS client.
2729
2830
:param etos: ETOS Library instance.
2931
:type etos: :obj:`etos_lib.etos.ETOS`
32+
:param cluster: ETOS cluster to start tests in.
33+
:type cluster: str
3034
"""
3135
self.etos = etos
36+
self.cluster = cluster
3237
self.test_execution = {}
3338

3439
@property
@@ -55,24 +60,18 @@ def start(self, spinner):
5560
"""
5661
spinner.info(str(self.data))
5762
generator = self.etos.http.retry(
58-
"POST", self.etos.debug.etos_api, timeout=30, json=self.data
63+
"POST", f"{self.cluster}/etos", timeout=30, json=self.data
5964
)
6065
response = None
6166
try:
6267
for response in generator:
6368
self.test_execution = response
69+
self.test_suite_id = response.get("tercc")
70+
self.event_repository = response.get("event_repository")
6471
break
6572
except ConnectionError as exception:
66-
spinner.warning(str(exception))
73+
spinner.warn(str(exception))
6774
spinner.fail("Failed to trigger ETOS.")
6875
return False
6976
spinner.succeed("ETOS triggered.")
7077
return True
71-
72-
@property
73-
def test_suite_id(self):
74-
"""Test suite ID on TERCC."""
75-
recipe = self.test_execution.get(
76-
"EiffelTestExecutionRecipeCollectionCreatedEvent"
77-
)
78-
return recipe.get("meta", {}).get("id")

0 commit comments

Comments
 (0)