I’ve recently been looking at our options for running some integration/end-to-end tests of our snowplow trackers.
Snowplow Micro looks great, and the two recent blog posts with examples were very informative. However, our application’s current CI/CD process does not lend itself well to being spun up and integration tested during the test/build pipeline (It’s mostly just unit tests being run during the build).
We do however have e2e tests running against the deployed infrastructure in our lower (aws) environments. I would like to add some e2e tests (i.e. using a browser automation framework) around the snowplow tracking to this test suite.
FWIW - We already have snowplow mini up and running, which would normally be used for manual verification/QA during the development phase.
If we were to use snowplow micro in this setup, I would need to host it inside the VPC somewhere (so it is visible to the deployed application/services). My question is, is this defeating the purpose of micro? If we already have a mini instance deployed, can we instead use that?
Is there a (public) API endpoint for elasticsearch on the mini instance that I could request (e.g. from a running test) events from? I haven’t been able to figure this out yet (I’m not too familiar with the mini setup). In the usage guide it looks like the elastic search api might be private only. Is this correct?
I’m wondering what my best option for e2e testing against (already deployed) trackers is: should I try to get mini to do what I want, or instead host a micro instance (on ECS/Fargate), either ephemerally or permanently.
Yes - you’d need to ensure your application can access Micro either via a private IP (in the same IP) or over the internet using a public IP - either method should work fine. If you use a public IP micro doesn’t need to be in the same VPC as your application itself - though generally micro is expected to run within a CI environment alongside the applicaiton.
You can definitely use a mini instance if you want. The API isn’t as agreeable as rather than the micro API you have to use the Elasticsearch API but that is certainly possible (and is in fact what we use for the ‘Stream Live Data’ feature in the Snowplow Inspector.
It is public but it looks like the documentation isn’t rendering that code block correctly which I’ve flagged as an issue. It uses basic auth (so you’ll need to provide a username and password) and then you should be able to access the full Elasticsearch API via
No, let me try again. We are trying to figure out how to fire and test events before code changes are committed. Something like PageView, won’t trigger until someone is on a page and is viewing that page. So I’m asking, is there a way to manually trigger PageView from a command line prompt so that the event “triggers” and sends data or placeholder data over to Snowplow Micro and runs the schema validation.
Another way to ask is: What is the earliest point we can trigger an event for testing?
What is the earliest point we can trigger an event for testing?
The earliest point is wherever your tracking code runs. More specifically, if, say, you are tracking the user journey on a page, as you mention above, then the ‘browser’ could for example be that earliest point.
Then, as you said:
Something like PageView, won’t trigger until someone is on a page and is viewing that page
This differs depending on whether you are interested in automated or manual testing, since, during automated testing you’d need a tool that will act as that ‘someone’ in an browser-like testing environment. There are such end-to-end web testing tools and frameworks, like Cypress and Nightwatch, and many more depending on the platform your digital products run.
Overall, what you need to do, either locally or in CI is:
spin up Micro (as @mike said above, Micro will collect and validate the events fired next by the tracker).
‘point’ your tracker to Micro’s collector endpoint.
interact or simulate an interaction with your page/mobile/server-side app.
examine the end state(i.e. the events in Micro) to ensure that tracking continues to be properly configured and your code changes can be confidently committed.
You can trigger events from the command line if you’d like (e.g., using a Curl GET request for example) but if you are looking to test before code has been committed then as @Ada has mentioned - the most common way to do so is by running front-end tests locally or in your CI/CD pipeline.