Commit 42b421c2 authored by Jérome Perrin's avatar Jérome Perrin

software/nginx-push-stream: publish URITemplates instead of simple URL

URITemplate is more suitable because it also describe how we expect the clients
to pass parameters
parent b51f5582
......@@ -8,4 +8,4 @@ md5sum = 022e4b53e1b2db16c4e518fe76f638fa
[template-nginx]
filename = instance-nginx.cfg.in
md5sum = 565deec1e9678485cc8e542a54f5d076
md5sum = 198bd472438989397bbf350f8361d316
......@@ -72,5 +72,7 @@ config-url = $${nginx-configuration:base-url}/status
[publish-connection-information]
recipe = slapos.cookbook:publish
publisher-url = $${nginx-configuration:base-url}/pub
subscriber-url = $${nginx-configuration:base-url}/sub
# publisher-url and subscriber-url are URITemplates, with an id
# parameter which is the ID of the channel.
publisher-url = $${nginx-configuration:base-url}/pub{?id}
subscriber-url = $${nginx-configuration:base-url}/sub{/id}
......@@ -44,6 +44,7 @@ setup(
'slapos.core',
'slapos.libnetworkcache',
'requests',
'uritemplate',
],
zip_safe=True,
test_suite='test',
......
......@@ -28,6 +28,7 @@
import os
import multiprocessing
import uritemplate
import requests
from slapos.testing.testcase import makeModuleSetUpAndTestCaseClass
......@@ -46,7 +47,9 @@ class TestNginxPushStream(SlapOSInstanceTestCase):
def process_messages(q):
# type:(multiprocessing.Queue[bytes]) -> None
req = requests.get(
self.connection_parameters['subscriber-url'] + '/channel_id',
uritemplate.URITemplate(
self.connection_parameters['subscriber-url']).expand(
id='channel_id'),
verify=False,
stream=True,
)
......@@ -62,7 +65,9 @@ class TestNginxPushStream(SlapOSInstanceTestCase):
self.assertEqual(q.get(timeout=30), b'ready')
resp = requests.post(
self.connection_parameters['publisher-url'] + '?id=channel_id',
uritemplate.URITemplate(
self.connection_parameters['publisher-url']).expand(
id='channel_id'),
verify=False,
data='Hello',
timeout=2,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment