Skip to content

Commit 7a9f1cb

Browse files
committed
Add testcase for issue #19
1 parent 406612f commit 7a9f1cb

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,24 @@
138138
}
139139
"""
140140

141+
TESTBLOCK_CASE_7 = """
142+
upstream xx.com_backend {
143+
server 10.193.2.2:9061 weight=1 max_fails=2 fail_timeout=30s;
144+
server 10.193.2.1:9061 weight=1 max_fails=2 fail_timeout=30s;
145+
session_sticky;
146+
}
147+
148+
server {
149+
listen 80;
150+
151+
location / {
152+
set $xlocation 'test';
153+
proxy_pass http://xx.com_backend;
154+
}
155+
}
156+
"""
157+
158+
141159

142160
class TestPythonNginx(unittest.TestCase):
143161
def test_basic_load(self):
@@ -213,6 +231,11 @@ def test_complex_upstream(self):
213231
out_data = '\n' + nginx.dumps(inp_data)
214232
self.assertEqual(TESTBLOCK_CASE_6, out_data)
215233

234+
def test_session_sticky(self):
235+
inp_data = nginx.loads(TESTBLOCK_CASE_7)
236+
out_data = '\n' + nginx.dumps(inp_data)
237+
self.assertEqual(TESTBLOCK_CASE_7, out_data)
238+
216239
def test_filtering(self):
217240
data = nginx.loads(TESTBLOCK_CASE_1)
218241
self.assertEqual(len(data.server.filter('Key', 'mykey')), 1)

0 commit comments

Comments
 (0)