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 ...@@ -8,4 +8,4 @@ md5sum = 022e4b53e1b2db16c4e518fe76f638fa
[template-nginx] [template-nginx]
filename = instance-nginx.cfg.in filename = instance-nginx.cfg.in
md5sum = 565deec1e9678485cc8e542a54f5d076 md5sum = 198bd472438989397bbf350f8361d316
...@@ -72,5 +72,7 @@ config-url = $${nginx-configuration:base-url}/status ...@@ -72,5 +72,7 @@ config-url = $${nginx-configuration:base-url}/status
[publish-connection-information] [publish-connection-information]
recipe = slapos.cookbook:publish recipe = slapos.cookbook:publish
publisher-url = $${nginx-configuration:base-url}/pub # publisher-url and subscriber-url are URITemplates, with an id
subscriber-url = $${nginx-configuration:base-url}/sub # 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( ...@@ -44,6 +44,7 @@ setup(
'slapos.core', 'slapos.core',
'slapos.libnetworkcache', 'slapos.libnetworkcache',
'requests', 'requests',
'uritemplate',
], ],
zip_safe=True, zip_safe=True,
test_suite='test', test_suite='test',
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
import os import os
import multiprocessing import multiprocessing
import uritemplate
import requests import requests
from slapos.testing.testcase import makeModuleSetUpAndTestCaseClass from slapos.testing.testcase import makeModuleSetUpAndTestCaseClass
...@@ -46,7 +47,9 @@ class TestNginxPushStream(SlapOSInstanceTestCase): ...@@ -46,7 +47,9 @@ class TestNginxPushStream(SlapOSInstanceTestCase):
def process_messages(q): def process_messages(q):
# type:(multiprocessing.Queue[bytes]) -> None # type:(multiprocessing.Queue[bytes]) -> None
req = requests.get( req = requests.get(
self.connection_parameters['subscriber-url'] + '/channel_id', uritemplate.URITemplate(
self.connection_parameters['subscriber-url']).expand(
id='channel_id'),
verify=False, verify=False,
stream=True, stream=True,
) )
...@@ -62,7 +65,9 @@ class TestNginxPushStream(SlapOSInstanceTestCase): ...@@ -62,7 +65,9 @@ class TestNginxPushStream(SlapOSInstanceTestCase):
self.assertEqual(q.get(timeout=30), b'ready') self.assertEqual(q.get(timeout=30), b'ready')
resp = requests.post( resp = requests.post(
self.connection_parameters['publisher-url'] + '?id=channel_id', uritemplate.URITemplate(
self.connection_parameters['publisher-url']).expand(
id='channel_id'),
verify=False, verify=False,
data='Hello', data='Hello',
timeout=2, 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