Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1197 from mozilla-services/bug/1196
Browse files Browse the repository at this point in the history
bug: sync endpoint and connection settings during integration testing
  • Loading branch information
pjenvey authored May 3, 2018
2 parents 77dab57 + 53be7e6 commit 83595a1
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions autopush/tests/test_rs_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ class TestRustWebPush(unittest.TestCase):
)

def start_ep(self, ep_conf):
self._ep_conf = ep_conf

# Endpoint HTTP router
self.ep = ep = EndpointApplication(
ep_conf,
Expand All @@ -127,17 +125,26 @@ def start_ep(self, ep_conf):
ep.startService()
self.addCleanup(ep.stopService)

def start_conn(self, conn_conf):
self.conn = conn = RustConnectionApplication(
conn_conf,
resource=autopush.tests.boto_resource,
)
conn.setup(rotate_tables=False, num_threads=2)
conn.startService()
self.addCleanup(conn.stopService)

def setUp(self):
self.logs = TestingLogObserver()
begin_or_register(self.logs)
self.addCleanup(globalLogPublisher.removeObserver, self.logs)

crypto_key = Fernet.generate_key()
ep_conf = AutopushConfig(
self._ep_conf = AutopushConfig(
crypto_key=crypto_key,
**self.endpoint_kwargs()
)
conn_conf = AutopushConfig(
self._conn_conf = AutopushConfig(
crypto_key=crypto_key,
auto_ping_interval=60.0,
auto_ping_timeout=10.0,
Expand All @@ -146,15 +153,9 @@ def setUp(self):
human_logs=False,
**self.conn_kwargs()
)
self.start_ep(ep_conf)
self.start_ep(self._ep_conf)
# Websocket server
self.conn = conn = RustConnectionApplication(
conn_conf,
resource=autopush.tests.boto_resource,
)
conn.setup(rotate_tables=False, num_threads=2)
conn.startService()
self.addCleanup(conn.stopService)
self.start_conn(self._conn_conf)

def endpoint_kwargs(self):
return self._endpoint_defaults
Expand Down Expand Up @@ -189,11 +190,15 @@ def _ws_url(self):
@inlineCallbacks
def test_no_rotation(self):
# override autopush settings
safe = self._ep_conf.allow_table_rotation
ep_safe = self._ep_conf.allow_table_rotation
conn_safe = self._conn_conf.allow_table_rotation
self._ep_conf.allow_table_rotation = False
self._conn_conf.allow_table_rotation = False
yield self.ep.stopService()
yield self.conn.stopService()
try:
self.start_ep(self._ep_conf)
self.start_conn(self._conn_conf)
data = str(uuid.uuid4())
client = yield self.quick_register()
result = yield client.send_notification(data=data)
Expand All @@ -212,8 +217,11 @@ def test_no_rotation(self):
assert table_name == self.ep.db.message_tables[0]
finally:
yield self.ep.stopService()
self._ep_conf.allow_table_rotation = safe
yield self.conn.stopService()
self._ep_conf.allow_table_rotation = ep_safe
self._conn_conf.allow_table_rotation = conn_safe
self.start_ep(self._ep_conf)
self.start_conn(self._conn_conf)
yield self.shut_down(client)

@inlineCallbacks
Expand Down

0 comments on commit 83595a1

Please sign in to comment.