def test_pipeline_registered_and_applied(self): wait_until_pipelines(self.es) # setup self.load_docs_with_template(self.get_payload_path("transactions.ndjson"), self.intake_url, 'transaction', 4) entries = self.es.search(index=index_transaction)['hits']['hits'] ua_found = False for e in entries: src = e['_source'] # ingest timestamp pipeline ingest_ts = src.get("event", {}).get("ingested") assert datetime.datetime.strptime(ingest_ts[:19], "%Y-%m-%dT%H:%M:%S") # user agent pipeline if 'user_agent' in src: ua_found = True ua = src['user_agent'] assert ua is not None assert ua["original"] == "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 " \ "(KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36, Mozilla Chrome Edge" assert ua["name"] == "Chrome" assert ua["version"] == "51.0.2704.103" assert ua["os"]["name"] == "Mac OS X" assert ua["os"]["version"] == "10.10.5" assert ua["os"]["full"] == "Mac OS X 10.10.5" assert ua["device"]["name"] == "Mac" assert ua_found
def setUp(self): # ensure pipelines do not get deleted on APM Server startup, otherwise `overwrite` flag cannot be tested self.skip_clean_pipelines = True # Ensure all pipelines are deleted before test es = Elasticsearch([self.get_elasticsearch_url()]) wait_until_pipelines_deleted(es) # Ensure `apm` pipeline is already registered in ES before APM Server is started self.pipeline_apm = "apm" es.ingest.put_pipeline(id=self.pipeline_apm, body={"description": "empty apm test pipeline", "processors": []}) wait_until_pipelines(es, ["apm"]) # When starting APM Server pipeline `apm` is already registered, the other pipelines are not super(PipelineOverwriteBase, self).setUp()
def test_pipeline_not_applied(self): wait_until_pipelines(self.es) self.load_docs_with_template(self.get_payload_path("transactions.ndjson"), self.intake_url, 'transaction', 4) uaFound = False entries = self.es.search(index=index_transaction)['hits']['hits'] for e in entries: src = e['_source'] if 'user_agent' in src: uaFound = True ua = src['user_agent'] assert ua is not None assert ua["original"] == "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 " \ "(KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36, Mozilla Chrome Edge" assert 'name' not in ua assert uaFound
def test_setup_pipelines(self): assert self.log_contains("Pipeline registration disabled") wait_until_pipelines(self.es, [])
def test_setup_pipelines(self): assert self.log_contains("Pipeline successfully registered: apm_user_agent") assert self.log_contains("Registered Ingest Pipelines successfully.") wait_until_pipelines(self.es)
def test_pipeline_not_registered(self): wait_until_pipelines(self.es, []) # events do not get stored when pipeline is missing with pytest.raises(TimeoutError): self.load_docs_with_template(self.get_payload_path("transactions.ndjson"), self.intake_url, 'transaction', 4)
def test_setup_pipelines(self): assert self.log_contains("No pipeline callback registered") wait_until_pipelines(self.es, [])