Pros of tests?
How TDD helps with writing clean code?
Parts of TDD?
Write failing test -> test passes -> refactor
What is SUT?
System under tests (scope of the test)
Types of tests
What unit tests should check?
Public API and state of SUT, which is a class.
What is user-journey test?
It tests the whole scenario - like process of selecting an item and buying it. Exactly like user.
Pros:
- better testing most valuable functionality of app
- despite it’s big tests, quicker to write and maintain DJ test instead multiply EE tests for each step.
What contract tests check?
It defines request and response of the dependency. It is used in integration tests to simulate it AND in the dependency test suite. Thanks to this, we are sure that responses are closest to real one.
What is testing double?
This is prod code dependency which in tests needs to be somehow simulated.
Type of test doubles
What is fake in the testing scope?
lightweight implementation of a dependency, like in-memory db instead of real db.
What is stub in the testing scope?
test double which just returns things - no way to check how system interacts with it during test.
What is mock in the testing scope?
smarter stub - we can check how system interacts with it and still simulate return value.
Fake vs stub vs mock?
Usually fake > mock > stub (especially when fakes are written by an author of real dependency)
What is continuous integration?
Process of merging changes in code done by developers to master branch with additional automatic checks like “static analysis”, unit tests run on server
What is continuous delivery?
If pipeline isn’t fully automated, but automation is done as much as possible in current organization, it’s Continuous delivery. Ideally a system where there is manual check on staging env, and then its approval for prod deployment is reachable for all organizations.
What is continuous deployment?
Extreme version of “continuous” variations. Once PR is approved, everything is automated - new version hits the prod.
Quite rare
What are parts of usual CI/CD?
How to do proper review in CI/CD?
Most important part.
to do:
- checking tests
- checking feature
- backward-compatibility
- logs
What preprod rollout does?
What is canary deployment?
progressive rollout of deployment to subsets of users. Role of thumb are 3 batches. Next bigger than previous.
After each batch comprehensive checks.
When rollback (app and db) are used?
After rollout, there should be many checks (not only health check):
- performance of service
- time of response
If something isn’t correct, the engineer should retry deployment, rollback and wait on hotfix.
What is rollback?
It is bringing back previous version of app. It should be a mindless process, because decisions about rollback usually are made in stress moments on prod.
That’s why backward compatibility is so important.
What to do when there is big change which simply cannot be backward compatible?
Example:
task: change of producer-consumer schema:
division:
1. Consumer can handle both schema (Can be rollaback)
2. producer can produce new schema messages (Can rollback)
3. Leaving old schema (Cannot rollback, because of new messages in system)