GithubHelp home page GithubHelp logo

mozilla / burnham Goto Github PK

View Code? Open in Web Editor NEW
8.0 25.0 6.0 561 KB

Automated end-to-end testing for Mozilla's Glean telemetry. ๐Ÿ‘ฉโ€๐Ÿš€

License: Mozilla Public License 2.0

Python 96.26% Dockerfile 3.52% Shell 0.22%
python python3 glean

burnham's Introduction

burnham ๐Ÿ‘ฉโ€๐Ÿš€๐Ÿ“ˆ๐Ÿค–

โŒ As of August 4, 2022, the burnham end-to-end test suite was disabled on Airflow. The source code in this repository is no longer actively maintained and the repository was marked as read-only as a result. โŒ

The burnham project is an end-to-end test suite that aims to automatically verify that Glean-based products correctly measure, collect, and submit non-personal information to the GCP-based Data Platform and that the received telemetry data is then correctly processed, stored to the respective tables and made available in BigQuery.

Blog post about the proof of concept: https://raphael.codes/blog/automated-end-to-end-tests-for-glean/

Overview

Glean SDK

For Mozilla, getting reliable data from our products is critical to inform our decision making. Glean is a product analytics & telemetry solution that provides a consistent experience and behavior across all of our products.

Find out more in our Data Documentation. ๐Ÿ“

burnham

We have developed a command-line application based on the Glean SDK Python bindings for producing test data as part of the automated end-to-end test suite. The burnham application submits Glean pings to the Data Platform which validates and stores these pings in BigQuery tables.

You can find the code for the burnham application in the application directory. ๐Ÿ‘ฉโ€๐Ÿš€

burnham-bigquery

We also developed a test suite based on the pytest framework that dynamically generates tests. Each test runs a specific query on BigQuery to verify a certain test scenario. After the test session finished, we then store the results in a designated BigQuery table with ID burnham_derived.test_results_v1.

The test suite code is located in the bigquery directory. ๐Ÿ“Š

telemetry-airflow

We build and push Docker images for both burnham and burnham-bigquery on CI for pushes to the main branch of this repository. The end-to-end test suite is configured as a DAG on telemetry-airflow on the Data Platform and scheduled to run daily. It runs several instances of a burnham Docker container to produce Glean telemetry, uses Airflow sensors to wait for the data to be available in the various burnham live tables, and then runs burnham-bigquery to verify the results.

Please see the burnham DAG for more information. ๐Ÿ“‹

Redash

We created two scheduled queries that read the results from the burnham_derived.test_results_v1 table from the past 4 days. The queries run daily at 02:00 UTC after telemetry-airflow ran the burnham DAG.

Mozilla employees can find this information in the burnham dashboard.

Development status

We successfully completed the proof of concept and are now running burnham and burnham-bigquery in production. We are now actively working on developing additional test scenarios. ๐Ÿš€

Requirements

Both burnham and burnham-bigquery run on Python 3.7 on Debian.

Integration points

The burnham project has integration points with the Glean SDK team, the Data Platform team and the Ecosystem Test Engineering team.

Community Participation Guidelines

This repository is governed by Mozilla's code of conduct and etiquette. Please read the burnham Code of Conduct.

Project theme

The project theme is inspired by Michael Burnham, the fictional protagonist on the web television series Star Trek: Discovery portrayed by Sonequa Martin-Green. Burnham is a science specialist on the Discovery. She and her crew do research on spore drive technology and complete missions in outer space and these themes of scientific exploration and space travel are a perfect fit for this project. ๐Ÿ‘ฉโ€๐Ÿš€

burnham's People

Contributors

b4handjr avatar badboy avatar dependabot[bot] avatar dexterp37 avatar hackebrot avatar jklukas avatar mdboom avatar relud avatar wlach avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

burnham's Issues

Create Docker image with CLI app

We will be running the end-to-end tests as Docker containers in Airflow. For that we need to create a Docker image with the CLI app that submits telemetry to a server specified by the environment.

Test ping names

Is your feature request related to a problem? Please describe.
We recently saw a bug where custom pings that were named in kebab-case where being dropped by the schema at ingestion because they were invalid against the schema. We plan to fix the schema, but it would be nice to have a test to prevent this kind of thing in the future.

Describe the solution you'd like
Send some custom pings with various kinds of names and make sure they are ingested correctly.

Explicitly, we should support:

  • kebab-case
  • snake_case
  • numbers001

Explicitly not supported are capital letters or names over 30 characters.

Additional context

mozilla-services/mozilla-pipeline-schemas#470
mozilla/glean#616

Should Burnham use the client activity API?

Is your feature request related to a problem? Please describe.

Glean now provides the client activity API.
It is not yet implemented for Python.
This allows embedding applications to trigger behavior based on client activity.
On mobile this maps to foregrounding (active) and backgrounding (inactive).
For Desktop this maps to certain activity within a certain amount of time.

The API triggers the baseline and events ping, both otherwise internal pings.

Describe the solution you'd like

Would it be useful for burnham to use this API to simulate activity and thus test Glean's expected behavior around those pings?

Develop additional unit tests for burnham ๐Ÿš€

We currently run flake8 and mypy on the burnham code as well as one smoke test for the CLI. I suggest we develop additional unit tests to increase the code coverage and reduce the risk of breaking burnham. I also suggest we add an additional tox environment to report the code coverage and fail the tox environment if the code coverage falls under a certain value. This will make it easier for newcomers to contribute to the project.

See also #93

Testing new and upcoming Glean SDK releases

We recently discussed in the cross-team meeting whether we could run the existing tests also with older version of the Glean SDK used by products as well as the latest main branch.

This issue is for exploring this idea further and scoping out the work required to achieve this.

Update submission_timestamp in burnham DAG ๐Ÿ“ˆ

The burnham DAG currently uses:

WHERE
  submission_timestamp > TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 3 HOUR)
  AND metrics.uuid.test_run = @burnham_test_run

When we restart the verify_data task outside of this time window task, we don't get any results back.

@fbertsch suggested to use a parameter for submission_timestamp.

Dependency issue with glean-parser ๐Ÿ“ฆ

The Docker build step on CircleCI fails after upgrading glean-parser in #84

RUN python -m pip install --no-index --find-links=/tmp/wheels/ burnham
ERROR: Could not find a version that satisfies the requirement glean-parser==1.28.6 (from glean-sdk>=32.3.1->burnham) (from versions: 1.29.0)
ERROR: No matching distribution found for glean-parser==1.28.6 (from glean-sdk>=32.3.1->burnham)

Docker build for burnham broken ๐Ÿšง

We haven't made any changes to the Docker build configuration for burnham since the most recent successful build job. Here's what I found so far by comparing the CI logs:

Most recent successful build

pip 20.1.1
wheel 0.34.2
setuptools 47.3.1

Failing build

pip 20.1.1
wheel 0.34.2
setuptools 48.0.0

cc @jezdez

Publish burnham to PyPI

We currently don't publish new releases of the burnham CLI to PyPI.

Do you think it would be useful to start doing this? ๐Ÿ“ฆ

Test for disabling upload and deletion-request ping

We started discussing a new test for the deletion-request ping in #55. Testing that pings are deleted from BigQuery tables following a deletion-request is complicated. However we can test that burnham doesn't submit pings after disabling the upload in the Glean SDK, that the client gets a new client ID assigned after re-enabling the upload in the Glean SDK and the BigQuery live tables contain the expected data.

Proposed test scenario

Produce data ๐Ÿ‘ฉโ€๐Ÿš€

(requires changes to burnham in this repository)

  • burnham client records to space_travel:warp_drive metric
  • burnham client submits discovery ping
  • burnham client calls Glean.set_upload_enabled(False)
  • burnham client records to space_travel:spore_drive metric
  • burnham client submits discovery ping
  • burnham client calls Glean.set_upload_enabled(True)
  • burnham client records to space_travel:spore_drive metric
  • burnham client submits discovery ping

Verify data ๐Ÿ“ˆ

(requires changes to the burnham DAG in telemetry-airflow)

  • table discovery_v1 contains ping with space_travel:warp_drive metric values from client with ID A
  • table discovery_v1 does not contain ping with space_travel:spore_drive metric values from client with ID A
  • table discovery_v1 contains ping with space_travel:spore_drive metric values from client with ID B
  • table deletion_request_v1 contains ping client with ID A

Thoughts? Comments? Suggestions?

Update GitHub labels ๐Ÿ“

I suggest we update our GitHub labels to increase clarity around what an issue/pull-request is about.

(https://github.com/hackebrot/labels makes bulk editing labels easier)

Create labels for the different integration points:

  • glean-sdk
  • telemetry-airflow

Create labels to flag the involved burnham components:

  • application
  • bigquery
  • fake-data-platform

Split the feature label into:

  • capability (for example: improved logging)
  • test scenario (for example: a new test for the deletion-request ping)

Create labels for GitHub integrations:

  • Dependabot
  • Circle CI
  • GitHub

Anything else? ๐Ÿค”

Update code checks for burnham and burnham-bigquery ๐Ÿค–

We recently merged a pull-request from Dependabot that introduced incompatible dependencies for burnham (#84). As a consequence we cannot push new Docker images to GKE because the Docker workflow fails.

@jklukas correctly pointed out in #88 (comment) that we need checks that exercise the build workflow.

We currently run the following code checks on CircleCI (see config file):

  • flake8
  • mypy
  • pytest

All of these run in a tox environment. As a first step, I suggest we update the installation step to also install from requirements.txt so that any dependency conflict is detected there. I also think we should build the Docker images for pull-requests.

According to the documentation of the CircleCI orb that we use for the Docker workflows, we should be able to add a gcp-gcr/build-image step. Ideally it will only run if the respective subdirectories are modified.

Update project documentation ๐Ÿ“

There are a few things we could improve about the documentation.

Project README:

  • Update Development Status (the project is still under active development, but completed the poc stage)
  • Add section to overview with burnham_derived.test_results_v1 table
  • Add link to Redash dashboard with test results
  • Update telemetry-airflow section (we now query multiple tables and use multiple sensors)

Application README:

  • Update Development Status (the application API is stable now)
  • Note that we currently don't upload new burnham releases to PyPI

BigQuery README:

  • Update Development Status (the project is still under active development, but completed the poc stage)

Test that pings are deleted following deletion-request

Verify that the Data Platform deletes Glean telemetry for a client.

This test is slightly different from other tests as we may need to run a sequence of steps:

  • produce Glean telemetry
  • verify that it's available in BigQuery tables
  • submit deletion-request ping
  • verify that the telemetry for this client has been deleted

Switch to Calendar Versioning

Knowing when the used burnham version was released will help us diagnose failing end-to-end tests. I suggest we follow the versioning scheme YY.MINOR.MICRO. ๐Ÿ“†

Duplicate documents in latest test run

The most recent burnham test run failed and I can see two rows with the same document_id in the burnham live tables resulting in incorrect labeled_counter metric values. ๐Ÿค”

Enable auto pull-requests for new Glean SDK releases ๐Ÿ“ฆ

We unpinned the Glean SDK version in #67. The next step is to automatically build and push an updated burnham Docker image to GKE for new releases of the Python bindings on PyPI. We have configured CircleCI to build and push Docker images for pushes to the main branch. Can we add a requirements.txt file and set up Dependabot to automatically open pull-requests against that file for new releases of the Glean SDK? ๐Ÿค–

https://github.blog/2020-06-01-keep-all-your-packages-up-to-date-with-dependabot/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.