Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create tool to detect database changes between branches/commits #89

Closed
AndrewSisley opened this issue Dec 10, 2021 · 3 comments · Fixed by #202
Closed

Create tool to detect database changes between branches/commits #89

AndrewSisley opened this issue Dec 10, 2021 · 3 comments · Fixed by #202
Assignees
Labels
area/testing Related to any test or testing suite ci/build This is issue is about the build or CI system, and the administration of it.

Comments

@AndrewSisley
Copy link
Contributor

AndrewSisley commented Dec 10, 2021

Needs to flag if anything changes between branches/commits - e.g. if the cid format changes between a feature branch and develop, or develop and master/main.

Could be done in a few ways, but need to make sure that it doesn't block the build and will not clutter up go test ./.... Code could live in another repo. Could be a test of go-tests dependent on an environment variable (and not run by default). Doesn't have to be written in Go, but if so check in with other team members/CTO first.

Check should do something similar to:

  • git checkout and pull branch a (e.g. develop)
  • create a new database
  • write a whole of stuff to it
  • dump database into variable/file
  • repeat for comparison branch (e.g. sisley/feat/I123)
  • compare outputs and notify

Would be good to hook it up to the CI system github PRs somehow in the future, but should be considered out of scope for this issue (but don't do anything too weird that might make that overly difficult).

@AndrewSisley AndrewSisley added the area/testing Related to any test or testing suite label Dec 10, 2021
@AndrewSisley AndrewSisley self-assigned this Dec 10, 2021
@AndrewSisley
Copy link
Contributor Author

Thought some more about this:

  • Should not based on direct calls to the defra code base (and should use the CLI, or potentially, but hopefully not - the http api), it should be possible to use https://pkg.go.dev/plugin but if the method signatures have changed between commits then it will break this
  • Should be possible to integrate it with a Breaking changes dir/list, and have the tests fail if the breaking changes are not documented there - could be a set of human-readable .md files with perhaps a hash of the original, and new print dumps. Test code could scan for files not present in the old branch/commit and compare the hashes with the print dump outputs. I don't think there is a sensible way to link these files to commits (which would be nice) due to interactive rebasing and PR squashing.
  • I cant yet think of a good way of determining which branch to compare against (git log might mislead if a feat. branch is based off another feat. branch but the current will be merged into develop without the base going in first). Suggest using environment variables, with the current branch being one default and develop being the other default.

@jsimnz jsimnz added the ci/build This is issue is about the build or CI system, and the administration of it. label Dec 10, 2021
@AndrewSisley AndrewSisley removed their assignment Dec 13, 2021
@jsimnz jsimnz added this to the DefraDB v0.3 milestone Jan 24, 2022
@AndrewSisley
Copy link
Contributor Author

AndrewSisley commented Jan 25, 2022

Had a bit of a think on this lately, and I think it should be feasible to further modify the integration tests to allow them to run across two versions, orchestrated by a controlling process (name: conductor in the text below):

  1. Conductor starts running tests, triggered by the setting of an environment variable
  2. Conductor checks out develop branch (configurable via env. param?) in new t.TestDir()
  3. For each test:
    3.a) Conductor generates a t.TestDir()
    3.b) Conductor spins up a new process running the develop branch using badger-db in 3.a, this process runs the test up until the db.ExecQuery call - setting up the database with test data/schema
    3.c) Conductor runs the test on the current branch from the db.ExecQuery call against the now-populated badger-db in 3.a, and raises failures just like any other Go test

Would give us a high degree of coverage for minimal effort (compared to some kind of snapshotting system). It doesn't have to be done this way, but is currently my favourite method.

Would need/like to hook it up to the CI system to trigger some kind of acknowledgable warning on PR, but that could be done later if needed (running manually is better than not running). Or, on re-read of my earlier comment - integrated with a breaking-changes directory!

@AndrewSisley
Copy link
Contributor Author

AndrewSisley commented Jan 25, 2022

Blocked on #128 (badger-db tests) and #141 (conflicts)

@jsimnz jsimnz modified the milestones: DefraDB v0.3, DefraDB v0.2.1 Jan 25, 2022
@AndrewSisley AndrewSisley self-assigned this Jan 27, 2022
AndrewSisley added a commit that referenced this issue Mar 2, 2022
)

* Correctly set CI test environment variables

Looks like the original way does not work with gotestsum (a guess, we switched over to that shortly after adding these in)

* Add automatic test support for database format changes

* Add database change detection step to CI
shahzadlone pushed a commit to shahzadlone/defradb that referenced this issue Feb 23, 2024
shahzadlone pushed a commit to shahzadlone/defradb that referenced this issue Feb 23, 2024
…ourcenetwork#89)

* Correctly set CI test environment variables

Looks like the original way does not work with gotestsum (a guess, we switched over to that shortly after adding these in)

* Add automatic test support for database format changes

* Add database change detection step to CI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/testing Related to any test or testing suite ci/build This is issue is about the build or CI system, and the administration of it.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants