|
@@ -7,13 +7,26 @@ precondition this machine does not meet - reported as a skip, never as a pass.
|
|
|
"""
|
|
"""
|
|
|
import base64
|
|
import base64
|
|
|
import json
|
|
import json
|
|
|
|
|
+import os
|
|
|
import sys
|
|
import sys
|
|
|
import time
|
|
import time
|
|
|
import urllib.error
|
|
import urllib.error
|
|
|
import urllib.parse
|
|
import urllib.parse
|
|
|
import urllib.request
|
|
import urllib.request
|
|
|
|
|
|
|
|
-BASE = "http://localhost:8090/api/v1"
|
|
|
|
|
|
|
+# Where the API is. Overridable because the harness does not have to run on the
|
|
|
|
|
+# webserver's host - and, more importantly, because a few cases ask a NODE to
|
|
|
|
|
+# fetch a URL, and the node runs wherever the runner is. Those cases used to
|
|
|
|
|
+# hardcode http://localhost:8090; the day the runner moved to a different
|
|
|
|
|
+# machine from the webserver they failed with "Could not connect to server",
|
|
|
|
|
+# which looks like a broken http-request node rather than a test that assumed
|
|
|
|
|
+# the two were co-located.
|
|
|
|
|
+API_ROOT = os.environ.get("SMARTBOTIC_API", "http://localhost:8090").rstrip("/")
|
|
|
|
|
+BASE = API_ROOT + "/api/v1"
|
|
|
|
|
+
|
|
|
|
|
+# What a node should use to reach the API. Same thing by default; set it when
|
|
|
|
|
+# the runner reaches the webserver by a different name than the harness does.
|
|
|
|
|
+RUNNER_API_ROOT = os.environ.get("SMARTBOTIC_RUNNER_API", API_ROOT).rstrip("/")
|
|
|
|
|
|
|
|
|
|
|
|
|
def call(method, path, token=None, body=None):
|
|
def call(method, path, token=None, body=None):
|
|
@@ -203,7 +216,10 @@ def precondition_unmet(case):
|
|
|
def main():
|
|
def main():
|
|
|
if len(sys.argv) != 2:
|
|
if len(sys.argv) != 2:
|
|
|
raise SystemExit("usage: verify-node.py <case.json>")
|
|
raise SystemExit("usage: verify-node.py <case.json>")
|
|
|
- case = json.load(open(sys.argv[1]))
|
|
|
|
|
|
|
+ raw_case = open(sys.argv[1]).read()
|
|
|
|
|
+ # {{API}} is what a case writes when it needs a URL the RUNNER can fetch.
|
|
|
|
|
+ raw_case = raw_case.replace("{{API}}", RUNNER_API_ROOT)
|
|
|
|
|
+ case = json.loads(raw_case)
|
|
|
|
|
|
|
|
unmet = precondition_unmet(case)
|
|
unmet = precondition_unmet(case)
|
|
|
if unmet:
|
|
if unmet:
|