test: Update kapow env vars to the new ones.

Co-authored-by: César Gallego <cesar.gallego.next@bbva.com>
This commit is contained in:
Roberto Abdelkader Martínez Pérez
2020-11-17 17:07:16 +01:00
parent 7c952faf11
commit 310d319ea3
5 changed files with 34 additions and 31 deletions
+1 -1
View File
@@ -20,4 +20,4 @@ checkbin:
@which kapow >/dev/null || (echo "ERROR: Your kapow binary is not present in PATH" && exit 1)
testpoc: sync
pipenv run pip install -r ../../testutils/poc/requirements.txt
PATH=../../testutils/poc:$$PATH KAPOW_CONTROLAPI_URL=http://localhost:8081 KAPOW_DATAAPI_URL=http://localhost:8081 pipenv run behave --no-capture --tags=~@skip
PATH=../../testutils/poc:$$PATH KAPOW_CONTROL_URL=http://localhost:8081 KAPOW_DATA_URL=http://localhost:8081 pipenv run behave --no-capture --tags=~@skip
+2 -2
View File
@@ -59,8 +59,8 @@ environment variables:
* ``KAPOW_BOOT_TIMEOUT``: Timeout in ms for the server to be ready
* ``KAPOW_SERVER_CMD``: The full command line to start a non-interactive
listening kapow server. By default: ``kapow server``
* ``KAPOW_CONTROLAPI_URL``: URL of the Control API. By default: ``http://localhost:8081``
* ``KAPOW_DATAAPI_URL``: URL of the Data API. By default: ``http://localhost:8082``
* ``KAPOW_CONTROL_URL``: URL of the Control API. By default: ``http://localhost:8081``
* ``KAPOW_DATA_URL``: URL of the Data API. By default: ``http://localhost:8082``
* ``KAPOW_USER_URL``: URL of the User Server. By default: ``http://localhost:8080``
+19 -19
View File
@@ -44,10 +44,10 @@ class Env(EnvironConfig):
KAPOW_SERVER_CMD = StringVar(default="kapow server")
#: Where the Control API is
KAPOW_CONTROLAPI_URL = StringVar(default="http://localhost:8081")
KAPOW_CONTROL_URL = StringVar(default="http://localhost:8081")
#: Where the Data API is
KAPOW_DATAAPI_URL = StringVar(default="http://localhost:8082")
KAPOW_DATA_URL = StringVar(default="http://localhost:8082")
#: Where the User Interface is
KAPOW_USER_URL = StringVar(default="http://localhost:8080")
@@ -91,8 +91,8 @@ def run_kapow_server(context):
assert is_running, "Server is not running!"
with suppress(requests.exceptions.ConnectionError):
open_ports = (
requests.head(Env.KAPOW_CONTROLAPI_URL, timeout=1).status_code
and requests.head(Env.KAPOW_DATAAPI_URL, timeout=1).status_code)
requests.head(Env.KAPOW_CONTROL_URL, timeout=1).status_code
and requests.head(Env.KAPOW_DATA_URL, timeout=1).status_code)
if open_ports:
break
sleep(.01)
@@ -107,7 +107,7 @@ def step_impl(context):
@when('I request a routes listing')
def step_impl(context):
context.response = requests.get(f"{Env.KAPOW_CONTROLAPI_URL}/routes")
context.response = requests.get(f"{Env.KAPOW_CONTROL_URL}/routes")
@given('I have a Kapow! server with the following routes')
@@ -118,7 +118,7 @@ def step_impl(context):
raise RuntimeError("A table must be set for this step.")
for row in context.table:
response = requests.post(f"{Env.KAPOW_CONTROLAPI_URL}/routes",
response = requests.post(f"{Env.KAPOW_CONTROL_URL}/routes",
json={h: row[h] for h in row.headings})
response.raise_for_status()
@@ -132,7 +132,7 @@ def step_impl(context):
for row in context.table:
response = requests.post(
f"{Env.KAPOW_CONTROLAPI_URL}/routes",
f"{Env.KAPOW_CONTROL_URL}/routes",
json={"entrypoint": " ".join(
[sys.executable,
shlex.quote(os.path.join(HERE, "testinghandler.py")),
@@ -170,7 +170,7 @@ def step_impl(context):
@when('I append the route')
def step_impl(context):
context.response = requests.post(f"{Env.KAPOW_CONTROLAPI_URL}/routes",
context.response = requests.post(f"{Env.KAPOW_CONTROL_URL}/routes",
data=context.text,
headers={"Content-Type": "application/json"})
@@ -212,12 +212,12 @@ def step_impl(context):
@when('I delete the route with id "{id}"')
def step_impl(context, id):
context.response = requests.delete(f"{Env.KAPOW_CONTROLAPI_URL}/routes/{id}")
context.response = requests.delete(f"{Env.KAPOW_CONTROL_URL}/routes/{id}")
@when('I insert the route')
def step_impl(context):
context.response = requests.put(f"{Env.KAPOW_CONTROLAPI_URL}/routes",
context.response = requests.put(f"{Env.KAPOW_CONTROL_URL}/routes",
headers={"Content-Type": "application/json"},
data=context.text)
@@ -225,7 +225,7 @@ def step_impl(context):
@when('I try to append with this malformed JSON document')
def step_impl(context):
context.response = requests.post(
f"{Env.KAPOW_CONTROLAPI_URL}/routes",
f"{Env.KAPOW_CONTROL_URL}/routes",
headers={"Content-Type": "application/json"},
data=context.text)
@@ -233,29 +233,29 @@ def step_impl(context):
@when('I delete the {order} route')
def step_impl(context, order):
idx = WORD2POS.get(order)
routes = requests.get(f"{Env.KAPOW_CONTROLAPI_URL}/routes")
routes = requests.get(f"{Env.KAPOW_CONTROL_URL}/routes")
id = routes.json()[idx]["id"]
context.response = requests.delete(f"{Env.KAPOW_CONTROLAPI_URL}/routes/{id}")
context.response = requests.delete(f"{Env.KAPOW_CONTROL_URL}/routes/{id}")
@when('I try to insert with this JSON document')
def step_impl(context):
context.response = requests.put(
f"{Env.KAPOW_CONTROLAPI_URL}/routes",
f"{Env.KAPOW_CONTROL_URL}/routes",
headers={"Content-Type": "application/json"},
data=context.text)
@when('I get the route with id "{id}"')
def step_impl(context, id):
context.response = requests.get(f"{Env.KAPOW_CONTROLAPI_URL}/routes/{id}")
context.response = requests.get(f"{Env.KAPOW_CONTROL_URL}/routes/{id}")
@when('I get the {order} route')
def step_impl(context, order):
idx = WORD2POS.get(order)
routes = requests.get(f"{Env.KAPOW_CONTROLAPI_URL}/routes")
routes = requests.get(f"{Env.KAPOW_CONTROL_URL}/routes")
id = routes.json()[idx]["id"]
context.response = requests.get(f"{Env.KAPOW_CONTROLAPI_URL}/routes/{id}")
context.response = requests.get(f"{Env.KAPOW_CONTROL_URL}/routes/{id}")
@when('I get the resource "{resource}"')
@@ -265,13 +265,13 @@ def step_impl(context, resource, handler_id=None):
handler_id = context.testing_handler_id
context.response = requests.get(
f"{Env.KAPOW_DATAAPI_URL}/handlers/{handler_id}{resource}")
f"{Env.KAPOW_DATA_URL}/handlers/{handler_id}{resource}")
@when('I set the resource "{resource}" with value "{value}"')
def step_impl(context, resource, value):
context.response = requests.put(
f"{Env.KAPOW_DATAAPI_URL}/handlers/{context.testing_handler_id}{resource}",
f"{Env.KAPOW_DATA_URL}/handlers/{context.testing_handler_id}{resource}",
data=value.encode("utf-8"))
+3
View File
@@ -0,0 +1,3 @@
FROM kapow-spec-test
ADD https://github.com/BBVA/kapow/releases/download/v0.5.4/kapow_0.5.4_linux_amd64 /usr/bin/kapow
RUN chmod 755 /usr/bin/kapow
+9 -9
View File
@@ -255,8 +255,8 @@ def handle_route(entrypoint, command):
shell_task = await asyncio.create_subprocess_shell(
args,
env={**os.environ,
"KAPOW_DATAAPI_URL": "http://localhost:8081",
"KAPOW_CONTROLAPI_URL": "http://localhost:8081",
"KAPOW_DATA_URL": "http://localhost:8081",
"KAPOW_CONTROL_URL": "http://localhost:8081",
"KAPOW_HANDLER_ID": id
},
stdin=asyncio.subprocess.DEVNULL)
@@ -426,8 +426,8 @@ async def run_init_script(app, scripts, interactive):
cmd,
executable="/bin/bash",
env={**os.environ,
"KAPOW_DATAAPI_URL": "http://localhost:8081",
"KAPOW_CONTROLAPI_URL": "http://localhost:8081"
"KAPOW_DATA_URL": "http://localhost:8081",
"KAPOW_CONTROL_URL": "http://localhost:8081"
})
await shell_task.wait()
@@ -554,7 +554,7 @@ def route():
@click.option("-c", "--command", nargs=1)
@click.option("-e", "--entrypoint", default="/bin/sh -c")
@click.option("-X", "--method", default="GET")
@click.option("--url", envvar='KAPOW_CONTROLAPI_URL')
@click.option("--url", envvar='KAPOW_CONTROL_URL')
@click.argument("url_pattern", nargs=1)
@click.argument("command_file", required=False)
def route_add(url_pattern, entrypoint, command, method, url, command_file):
@@ -582,7 +582,7 @@ def route_add(url_pattern, entrypoint, command, method, url, command_file):
@route.command("remove")
@click.option("--url", envvar='KAPOW_CONTROLAPI_URL')
@click.option("--url", envvar='KAPOW_CONTROL_URL')
@click.argument("route-id")
def route_remove(route_id, url):
response = requests.delete(f"{url}/routes/{route_id}")
@@ -590,7 +590,7 @@ def route_remove(route_id, url):
@route.command("list")
@click.option("--url", envvar='KAPOW_CONTROLAPI_URL')
@click.option("--url", envvar='KAPOW_CONTROL_URL')
@click.argument("route-id", nargs=1, required=False, default=None)
def route_list(route_id, url):
if route_id is None:
@@ -602,7 +602,7 @@ def route_list(route_id, url):
@kapow.command("set", help="Set data from the current context")
@click.option("--url", envvar='KAPOW_DATAAPI_URL')
@click.option("--url", envvar='KAPOW_DATA_URL')
@click.option("--handler-id", envvar='KAPOW_HANDLER_ID')
@click.argument("path", nargs=1)
@click.argument("value", required=False)
@@ -622,7 +622,7 @@ def kapow_set(url, handler_id, path, value):
@kapow.command("get", help="Get data from the current context")
@click.option("--url", envvar='KAPOW_DATAAPI_URL')
@click.option("--url", envvar='KAPOW_DATA_URL')
@click.option("--handler-id", envvar='KAPOW_HANDLER_ID')
@click.argument("path", nargs=1)
def kapow_get(url, handler_id, path):