Replies: 1 comment
-
|
I have hit migration issues before that were likely related to the lack of testing around the process of upgrading OpenWISP. I recently added this test in With a "narrow focus"/"low-level"There are things we can already do with some django tooling.
We would need some time to investigate these, learn from other django communities, and come up with a sensible approach... At a "medium-level"We could use SQLite, apply the migrations, store the output file somewhere (or a checksum, or extract a schema, or...), and check if the subsequent test runs give the same result. Then at a higher-levelWe should make sure that workflow like these work as expected, especially for releases:
Not sure if automating it is the way to go, or having having somewhat of a manual process when releases occur, is easier to operate and maintain ? However, complexity in this area can increase very quickly:
Current OpenWISP tests are complex, do not always work, and take time to execute. Some answers
I don't think fixture is a workable approach for this... also there would be significant "infrastructure" effort required (creating, storing, moving files/images around, etc.)
In my experience, openwisp-users is simple enough and the data it manages is critical enough, to make it a good candidate for migration testing experiments. AlternativeFinally I want to side-track a bit, and mention an alternative approach, since in my experience the "upgrading database" strategy has been quite cumbersome.
Another possibility, with the same end result, is to:
The main benefits are:
In that process, the migration testing complexity grows linearly to the number of releases And I think the community would gain to have a dump/restore workflow documented (Is it In my mind the 'database upgrade' process is actually an optimization, but we should get the fundamentals (fresh deploy + backup/restore process) right first. That was long, time to concludeI didn't expect to write something that long, but here we are. I hope some of it will be a useful piece of information at least. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
While investigating a recent migration issue with dropping jsonfield package, I noticed a gap in our current testing strategy.
Today, our CI primarily validates fresh installations. Every CI run starts from a clean database, applies all migrations, and executes the test suite. While this gives us confidence that a new installation works correctly, it does not fully validate upgrades from previously released versions.
As a result, certain classes of migration issues can go unnoticed until users perform upgrades in production. These issues may involve schema changes, indexes, constraints, migration ordering, data migrations, or assumptions that only hold true on a freshly created database.
Goals
The goal of this proposal is to:
Proposed Approach
Introduce automated upgrade fixtures that represent databases created with previous OpenWISP releases.
Whenever a new release is published, a dedicated workflow would automatically:
Subsequent pull requests could then:
This would allow us to continuously verify that upgrades continue to work correctly, rather than only validating fresh installations.
CI Integration
Most OpenWISP repositories already execute a test matrix across multiple Python and Django versions.
Instead of introducing an entirely separate CI pipeline, we could extend one of the existing matrix entries to perform upgrade validation:
This would provide upgrade coverage while keeping CI execution time and complexity under control.
Reusability Across OpenWISP
Since this problem affects multiple projects, it would be useful to implement the fixture generation and upgrade testing logic as reusable GitHub Actions.
Potential adopters include:
A shared implementation would reduce duplication and ensure a consistent upgrade-testing strategy across the ecosystem.
Possible Implementations
I have been exploring a few implementation options:
Database Dumps
Generate a database dump whenever a release is published and restore it during CI before running migrations.
Versioned Database Containers
Generate a database fixture during the release process and publish it as a versioned container image. CI could then start directly from that fixture when validating upgrades.
There may be other approaches that achieve the same goal, so I would like to keep the discussion focused on the problem and overall strategy rather than a specific implementation.
Benefits
Open Questions
I'd be interested in hearing feedback, alternative approaches, or examples of similar solutions used in other projects.
Beta Was this translation helpful? Give feedback.
All reactions