def test_submit_pubsub_server_error( integration_test: IntegrationTest, publisher: PublisherClient, pubsub: Any, topic: str, ): if pubsub == "google": pytest.skip("requires pubsub emulator") # override pubsub status publisher.update_topic({"name": topic}, {"paths": ["status_code=internal"]}) integration_test.assert_accepted_and_queued() # restore pubsub status publisher.update_topic({"name": topic}, {"paths": ["status_code="]}) integration_test.assert_flushed()
def test_submit_pubsub_permission_denied( integration_test: IntegrationTest, publisher: PublisherClient, pubsub: str, topic: str, ): if pubsub == "google": pytest.skip("not implemented") else: publisher.update_topic({"name": topic}, {"paths": ["status_code=permission_denied"]}) integration_test.assert_accepted_and_queued() if pubsub == "google": pytest.skip("not implemented") else: publisher.update_topic({"name": topic}, {"paths": ["status_code="]}) integration_test.assert_flushed_and_delivered()
def test_submit_pubsub_timeout( integration_test: IntegrationTest, publisher: PublisherClient, pubsub: Any, topic: str, ): if pubsub == "google": pytest.skip("requires pubsub emulator") # override pubsub response time publisher.update_topic( {"name": topic}, {"paths": ["sleep=%.1f" % (PUBLISH_TIMEOUT_SECONDS + 1)]}) integration_test.assert_accepted_and_queued() # restore pubsub response time publisher.update_topic({"name": topic}, {"paths": ["sleep="]}) integration_test.assert_flushed()
def test_flush( integration_test: IntegrationTest, publisher: PublisherClient, pubsub: Any, topic: str, server_process: subprocess.Popen, ): if pubsub == "google": pytest.skip("requires pubsub emulator") # override pubsub status publisher.update_topic({"name": topic}, {"paths": ["status_code=internal"]}) integration_test.assert_accepted_and_queued() # stop server server_process.kill() server_process.wait() # start flush process = subprocess.Popen( [sys.executable, "-u", "-m", "ingestion_edge.flush"], stderr=subprocess.PIPE) assert process.stderr is not None for line in process.stderr: break # wait for an error to be logged assert process.poll() is None # server still running # restore pubsub status publisher.update_topic({"name": topic}, {"paths": ["status_code="]}) try: process.wait(5) except subprocess.TimeoutExpired: # kill after 5 seconds process.kill() assert process.wait() == 0 assert json.loads(line)["Fields"]["msg"] == "pubsub unavailable" integration_test.assert_delivered()