diff options
author | Zuul <zuul@review.opendev.org> | 2023-02-09 11:26:49 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2023-02-09 11:26:49 +0000 |
commit | 2559c3538b037af118d5092095f60e4514ff47ce (patch) | |
tree | 84b2fef8b437424c8243190e2ac082df0166f580 /tests | |
parent | 0618b876c8d34d5031f39e1d44090a683ce861ba (diff) | |
parent | 26523d8e5673a624c1ba5ae8bff2db96431d4b5a (diff) | |
download | zuul-2559c3538b037af118d5092095f60e4514ff47ce.tar.gz |
Merge "Fix ResourceWarnings in fingergw"
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/test_streaming.py | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/tests/unit/test_streaming.py b/tests/unit/test_streaming.py index ba3117f59..12b33e5c6 100644 --- a/tests/unit/test_streaming.py +++ b/tests/unit/test_streaming.py @@ -138,6 +138,17 @@ class TestStreamingBase(tests.base.AnsibleZuulTestCase): s.close() self.streamer.stop() + def _readSocket(self, sock, build_uuid, event, name): + msg = "%s\r\n" % build_uuid + sock.sendall(msg.encode('utf-8')) + event.set() # notify we are connected and req sent + while True: + data = sock.recv(1024) + if not data: + break + self.streaming_data[name] += data.decode('utf-8') + sock.shutdown(socket.SHUT_RDWR) + def runFingerClient(self, build_uuid, gateway_address, event, name=None): # Wait until the gateway is started for x in iterate_timeout(30, "finger client to start"): @@ -162,17 +173,10 @@ class TestStreamingBase(tests.base.AnsibleZuulTestCase): os.path.join(FIXTURE_DIR, 'fingergw/fingergw.key')) context.load_verify_locations( os.path.join(FIXTURE_DIR, 'fingergw/root-ca.pem')) - s = context.wrap_socket(s) - - msg = "%s\r\n" % build_uuid - s.sendall(msg.encode('utf-8')) - event.set() # notify we are connected and req sent - while True: - data = s.recv(1024) - if not data: - break - self.streaming_data[name] += data.decode('utf-8') - s.shutdown(socket.SHUT_RDWR) + with context.wrap_socket(s) as s: + self._readSocket(s, build_uuid, event, name) + else: + self._readSocket(s, build_uuid, event, name) def runFingerGateway(self, zone=None): self.log.info('Starting fingergw with zone %s', zone) |