Integration tests across environments
Databricks Machine Learning Professional · Lesson 15 of 22 · 1:47:12
YouTube loads only after you press play. This chapter opens at its timestamp in the full course. Watch on YouTube ↗
Learning with these videos? Subscribe for new courses and exam-style questions.
Subscribe on YouTube (opens in a new tab)In this lesson
Prepare for the Databricks Certified Machine Learning Professional exam. In this lesson: which tests run in which environment, what an integration test covers, keeping tests fast and cheap, and an example design. Includes three original practice questions.
Study notes
The text of this lesson, to read at your own pace. Information as of November 2026.
Pieces and the whole
Every function of Pebblecove's pipeline passes its unit tests, and yet the first nightly run in production failed: the training job expected a column that the feature job had renamed. Unit tests check the pieces, while integration tests check that the pieces work together. This lesson covers which tests run in which environment, and how to design an integration test for a machine learning system.
Tests by environment
Each environment runs its own kind of tests. In development, data scientists run unit tests as they write code, and can try the pipelines on samples of data. When a pull request targets the main branch, continuous integration runs the unit tests on every change, since they are fast, and blocks the merge if any of them fails. In staging, integration tests run the pipelines together, in an environment that mimics production, with the staging catalog and its own compute. And in production, the model validation checks and the monitoring take over, on real data.
What an integration test covers
An integration test runs the machine learning system end to end, the way production will, and checks that every stage works with the next. It runs feature engineering to write the feature tables, training to fit and log a model, and evaluation to compute its metrics on held out data. Then it registers and validates the model, deploys it, for example to a temporary serving endpoint, and runs batch or real time inference against it. Each stage asserts what it produced: tables with the expected columns, a registered model version, metrics within a sane range, and predictions in the expected format. And monitoring jobs can be included, so their tables and alerts are checked too.
Fast and cheap
A full integration test on data of production size would be slow and expensive, so it keeps the logic and shrinks the cost. It trains on a small subset of the data, or with fewer iterations, since the goal is to prove that the pipeline runs, not to build the best model. Temporary resources, like a serving endpoint, are created for the test and deleted afterwards. And the jobs work in the staging catalog, so the test never writes to production tables.
An example design
Here is a design for Pebblecove. A job in staging chains tasks: the feature task writes the host features to the staging catalog, and the training task fits the model on one month of data, and logs it to MLflow. The evaluation task compares the metrics with a minimal threshold, and the registration task creates a model version in the staging catalog. The deployment task serves it on a temporary endpoint, and the inference task sends sample requests, and checks the format of the responses. The last task deletes the endpoint, and the job fails if any assertion fails, which blocks the release.
Recap
Let's recap. Unit tests run in development and on every pull request, and integration tests run in staging. An integration test runs the system end to end: feature engineering, training, evaluation, deployment, and inference. Each stage asserts what it produced, like columns, a model version, metrics, and the format of predictions. A small subset of data, fewer iterations, and temporary resources keep it fast and cheap. And production relies on validation checks and monitoring.
Quick checks for this lesson
The 3 questions of this lesson, as plain text. The button above runs them with shuffled choices and the reason behind every choice.
Where do the unit tests run automatically, on every proposed change?
- In production, after each deployment
- In continuous integration, on each pull request
- In staging, once a month
- On each data scientist’s laptop only
Show the answer
In continuous integration, on each pull request
Unit tests are fast, so continuous integration runs them on every pull request, before any merge. “In production, after each deployment” would find the problems after they reach production. “In staging, once a month” is too rare, and staging is where the integration tests run. And “On each data scientist’s laptop only” would depend on people remembering to run them.
The integration test takes six hours, because it trains on the full history. What keeps its value while cutting its cost?
- Skip the training stage
- Run it only in production
- Train on a small subset, with fewer iterations
- Replace it with more unit tests
Show the answer
Train on a small subset, with fewer iterations
The test proves that the stages work together, which a small subset of data, or fewer iterations, still shows. “Skip the training stage” would remove a stage, so the test is no longer end to end. “Run it only in production” would find the failures too late. And “Replace it with more unit tests” only checks the pieces, not how they fit together.
Which assertion belongs in the inference stage of an integration test?
- The responses have the expected format
- The model beats the Champion by five percent
- Every unit test passed on the laptop
- The feature table has a new column
Show the answer
The responses have the expected format
The inference stage checks that the deployed model answers, in the expected format, with one prediction per input. “The model beats the Champion by five percent” is a decision about promotion, made in production, not a check that the pipeline works. “Every unit test passed on the laptop” would belong to continuous integration, before staging. And “The feature table has a new column” would check the feature stage, not inference.