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:
+1
-1
@@ -20,4 +20,4 @@ checkbin:
|
|||||||
@which kapow >/dev/null || (echo "ERROR: Your kapow binary is not present in PATH" && exit 1)
|
@which kapow >/dev/null || (echo "ERROR: Your kapow binary is not present in PATH" && exit 1)
|
||||||
testpoc: sync
|
testpoc: sync
|
||||||
pipenv run pip install -r ../../testutils/poc/requirements.txt
|
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
|
||||||
|
|||||||
@@ -59,8 +59,8 @@ environment variables:
|
|||||||
* ``KAPOW_BOOT_TIMEOUT``: Timeout in ms for the server to be ready
|
* ``KAPOW_BOOT_TIMEOUT``: Timeout in ms for the server to be ready
|
||||||
* ``KAPOW_SERVER_CMD``: The full command line to start a non-interactive
|
* ``KAPOW_SERVER_CMD``: The full command line to start a non-interactive
|
||||||
listening kapow server. By default: ``kapow server``
|
listening kapow server. By default: ``kapow server``
|
||||||
* ``KAPOW_CONTROLAPI_URL``: URL of the Control API. By default: ``http://localhost:8081``
|
* ``KAPOW_CONTROL_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_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``
|
* ``KAPOW_USER_URL``: URL of the User Server. By default: ``http://localhost:8080``
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -44,10 +44,10 @@ class Env(EnvironConfig):
|
|||||||
KAPOW_SERVER_CMD = StringVar(default="kapow server")
|
KAPOW_SERVER_CMD = StringVar(default="kapow server")
|
||||||
|
|
||||||
#: Where the Control API is
|
#: 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
|
#: 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
|
#: Where the User Interface is
|
||||||
KAPOW_USER_URL = StringVar(default="http://localhost:8080")
|
KAPOW_USER_URL = StringVar(default="http://localhost:8080")
|
||||||
@@ -91,8 +91,8 @@ def run_kapow_server(context):
|
|||||||
assert is_running, "Server is not running!"
|
assert is_running, "Server is not running!"
|
||||||
with suppress(requests.exceptions.ConnectionError):
|
with suppress(requests.exceptions.ConnectionError):
|
||||||
open_ports = (
|
open_ports = (
|
||||||
requests.head(Env.KAPOW_CONTROLAPI_URL, timeout=1).status_code
|
requests.head(Env.KAPOW_CONTROL_URL, timeout=1).status_code
|
||||||
and requests.head(Env.KAPOW_DATAAPI_URL, timeout=1).status_code)
|
and requests.head(Env.KAPOW_DATA_URL, timeout=1).status_code)
|
||||||
if open_ports:
|
if open_ports:
|
||||||
break
|
break
|
||||||
sleep(.01)
|
sleep(.01)
|
||||||
@@ -107,7 +107,7 @@ def step_impl(context):
|
|||||||
|
|
||||||
@when('I request a routes listing')
|
@when('I request a routes listing')
|
||||||
def step_impl(context):
|
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')
|
@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.")
|
raise RuntimeError("A table must be set for this step.")
|
||||||
|
|
||||||
for row in context.table:
|
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})
|
json={h: row[h] for h in row.headings})
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
|
|
||||||
@@ -132,7 +132,7 @@ def step_impl(context):
|
|||||||
|
|
||||||
for row in context.table:
|
for row in context.table:
|
||||||
response = requests.post(
|
response = requests.post(
|
||||||
f"{Env.KAPOW_CONTROLAPI_URL}/routes",
|
f"{Env.KAPOW_CONTROL_URL}/routes",
|
||||||
json={"entrypoint": " ".join(
|
json={"entrypoint": " ".join(
|
||||||
[sys.executable,
|
[sys.executable,
|
||||||
shlex.quote(os.path.join(HERE, "testinghandler.py")),
|
shlex.quote(os.path.join(HERE, "testinghandler.py")),
|
||||||
@@ -170,7 +170,7 @@ def step_impl(context):
|
|||||||
|
|
||||||
@when('I append the route')
|
@when('I append the route')
|
||||||
def step_impl(context):
|
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,
|
data=context.text,
|
||||||
headers={"Content-Type": "application/json"})
|
headers={"Content-Type": "application/json"})
|
||||||
|
|
||||||
@@ -212,12 +212,12 @@ def step_impl(context):
|
|||||||
|
|
||||||
@when('I delete the route with id "{id}"')
|
@when('I delete the route with id "{id}"')
|
||||||
def step_impl(context, 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')
|
@when('I insert the route')
|
||||||
def step_impl(context):
|
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"},
|
headers={"Content-Type": "application/json"},
|
||||||
data=context.text)
|
data=context.text)
|
||||||
|
|
||||||
@@ -225,7 +225,7 @@ def step_impl(context):
|
|||||||
@when('I try to append with this malformed JSON document')
|
@when('I try to append with this malformed JSON document')
|
||||||
def step_impl(context):
|
def step_impl(context):
|
||||||
context.response = requests.post(
|
context.response = requests.post(
|
||||||
f"{Env.KAPOW_CONTROLAPI_URL}/routes",
|
f"{Env.KAPOW_CONTROL_URL}/routes",
|
||||||
headers={"Content-Type": "application/json"},
|
headers={"Content-Type": "application/json"},
|
||||||
data=context.text)
|
data=context.text)
|
||||||
|
|
||||||
@@ -233,29 +233,29 @@ def step_impl(context):
|
|||||||
@when('I delete the {order} route')
|
@when('I delete the {order} route')
|
||||||
def step_impl(context, order):
|
def step_impl(context, order):
|
||||||
idx = WORD2POS.get(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"]
|
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')
|
@when('I try to insert with this JSON document')
|
||||||
def step_impl(context):
|
def step_impl(context):
|
||||||
context.response = requests.put(
|
context.response = requests.put(
|
||||||
f"{Env.KAPOW_CONTROLAPI_URL}/routes",
|
f"{Env.KAPOW_CONTROL_URL}/routes",
|
||||||
headers={"Content-Type": "application/json"},
|
headers={"Content-Type": "application/json"},
|
||||||
data=context.text)
|
data=context.text)
|
||||||
|
|
||||||
@when('I get the route with id "{id}"')
|
@when('I get the route with id "{id}"')
|
||||||
def step_impl(context, 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')
|
@when('I get the {order} route')
|
||||||
def step_impl(context, order):
|
def step_impl(context, order):
|
||||||
idx = WORD2POS.get(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"]
|
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}"')
|
@when('I get the resource "{resource}"')
|
||||||
@@ -265,13 +265,13 @@ def step_impl(context, resource, handler_id=None):
|
|||||||
handler_id = context.testing_handler_id
|
handler_id = context.testing_handler_id
|
||||||
|
|
||||||
context.response = requests.get(
|
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}"')
|
@when('I set the resource "{resource}" with value "{value}"')
|
||||||
def step_impl(context, resource, value):
|
def step_impl(context, resource, value):
|
||||||
context.response = requests.put(
|
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"))
|
data=value.encode("utf-8"))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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
@@ -255,8 +255,8 @@ def handle_route(entrypoint, command):
|
|||||||
shell_task = await asyncio.create_subprocess_shell(
|
shell_task = await asyncio.create_subprocess_shell(
|
||||||
args,
|
args,
|
||||||
env={**os.environ,
|
env={**os.environ,
|
||||||
"KAPOW_DATAAPI_URL": "http://localhost:8081",
|
"KAPOW_DATA_URL": "http://localhost:8081",
|
||||||
"KAPOW_CONTROLAPI_URL": "http://localhost:8081",
|
"KAPOW_CONTROL_URL": "http://localhost:8081",
|
||||||
"KAPOW_HANDLER_ID": id
|
"KAPOW_HANDLER_ID": id
|
||||||
},
|
},
|
||||||
stdin=asyncio.subprocess.DEVNULL)
|
stdin=asyncio.subprocess.DEVNULL)
|
||||||
@@ -426,8 +426,8 @@ async def run_init_script(app, scripts, interactive):
|
|||||||
cmd,
|
cmd,
|
||||||
executable="/bin/bash",
|
executable="/bin/bash",
|
||||||
env={**os.environ,
|
env={**os.environ,
|
||||||
"KAPOW_DATAAPI_URL": "http://localhost:8081",
|
"KAPOW_DATA_URL": "http://localhost:8081",
|
||||||
"KAPOW_CONTROLAPI_URL": "http://localhost:8081"
|
"KAPOW_CONTROL_URL": "http://localhost:8081"
|
||||||
})
|
})
|
||||||
|
|
||||||
await shell_task.wait()
|
await shell_task.wait()
|
||||||
@@ -554,7 +554,7 @@ def route():
|
|||||||
@click.option("-c", "--command", nargs=1)
|
@click.option("-c", "--command", nargs=1)
|
||||||
@click.option("-e", "--entrypoint", default="/bin/sh -c")
|
@click.option("-e", "--entrypoint", default="/bin/sh -c")
|
||||||
@click.option("-X", "--method", default="GET")
|
@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("url_pattern", nargs=1)
|
||||||
@click.argument("command_file", required=False)
|
@click.argument("command_file", required=False)
|
||||||
def route_add(url_pattern, entrypoint, command, method, url, command_file):
|
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")
|
@route.command("remove")
|
||||||
@click.option("--url", envvar='KAPOW_CONTROLAPI_URL')
|
@click.option("--url", envvar='KAPOW_CONTROL_URL')
|
||||||
@click.argument("route-id")
|
@click.argument("route-id")
|
||||||
def route_remove(route_id, url):
|
def route_remove(route_id, url):
|
||||||
response = requests.delete(f"{url}/routes/{route_id}")
|
response = requests.delete(f"{url}/routes/{route_id}")
|
||||||
@@ -590,7 +590,7 @@ def route_remove(route_id, url):
|
|||||||
|
|
||||||
|
|
||||||
@route.command("list")
|
@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)
|
@click.argument("route-id", nargs=1, required=False, default=None)
|
||||||
def route_list(route_id, url):
|
def route_list(route_id, url):
|
||||||
if route_id is None:
|
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")
|
@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.option("--handler-id", envvar='KAPOW_HANDLER_ID')
|
||||||
@click.argument("path", nargs=1)
|
@click.argument("path", nargs=1)
|
||||||
@click.argument("value", required=False)
|
@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")
|
@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.option("--handler-id", envvar='KAPOW_HANDLER_ID')
|
||||||
@click.argument("path", nargs=1)
|
@click.argument("path", nargs=1)
|
||||||
def kapow_get(url, handler_id, path):
|
def kapow_get(url, handler_id, path):
|
||||||
|
|||||||
Reference in New Issue
Block a user