Unit tests with Snowplow Micro

Hello,

I am trying to implement unit tests for tracking using pytest and Snowplow Micro as a collector.
Micro is running as a docker container pointed at our Iglu registry.

docker run -p 9090:9090 -e MICRO_IGLU_REGISTRY_URL -e MICRO_IGLU_API_KEY

It can get schemas from the registry, I checked that.

Tracker is initialised with http://localhost:9090 as the collector endpoint. However, I see no events reaching the Micro. Its stats show {'total': 0, 'good': 0, 'bad': 0} and there are no exceptions in the logs.

Hi,

have you set the collector postPath /com.snowplowanalytics.snowplow/tp2 in your testing setup? The whole event request URL should be: http://localhost:9090/com.snowplowanalytics.snowplow/tp2 in case you haven’t specified a custom postPath in Micro.

Hope that helps.
David

Hi @cealkate,

Which tracker are you using and where does it run? (Has to be on the same machine as Micro, unless you take some additional steps.)

I use Python tracker. In the logs it says that the emitter was initialised for the http://localhost:9090/com.snowplowanalytics.snowplow/tp2, Micro container and the tests are running on the same machine.

Hi @cealkate, you might need to call flush() on the tracker in order to flush any tracked events to the collector in your integration tests (see here).

By default, the buffer size is 10, which means that the tracker waits until 10 events are tracked before making a request – this is particularly useful in server-side apps where you don’t want to make a request for every tracked event as that would cause too much traffic.

1 Like

Thank you, flushing after sending an event solved the issue.

1 Like