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

Set rethink and mysql server DB storage tests to run on circle #824

Merged
merged 8 commits into from
Jul 19, 2016

Conversation

cyli
Copy link
Contributor

@cyli cyli commented Jul 11, 2016

Part of #797

This adds some basic rethinkDB TUF CRUD tests, and fixes the following issues:

  1. MemStorage's UpdateMany previously did a partial update even if there was a conflict. Now we check for conflicts before updating.
  2. MemStorage's UpdateMany allowed you to insert the same version twice.
  3. RethinkDB's UpdateMany did a partial update even if there was a conflict, because the deletion criteria value (for timestamp_checksum) was passed as a list not as strings.
  4. RethinkDB's Delete did not actually delete metadata, because the deletion criteria value
    (for gun) was passed as a list and not as strings.

This PR:

  • factor out server MetaStore tests to take a database/store so we can have tests for every type of DB
  • set up tests to run on CircleCI

One or more future PRs will factor out tests for NewTUFMetaStorage to be db-testable, and do the same for the signer tests.

@cyli cyli force-pushed the db-tests-refactor branch 8 times, most recently from e2e85d3 to ffdc5d2 Compare July 12, 2016 08:01
@cyli cyli changed the title WIP setting up rethink and mysql tests to run on circle WIP Set rethink and mysql server DB storage tests to run on circle Jul 12, 2016
@cyli cyli force-pushed the db-tests-refactor branch 2 times, most recently from 120869a to c801293 Compare July 12, 2016 23:05
@cyli cyli changed the title WIP Set rethink and mysql server DB storage tests to run on circle Set rethink and mysql server DB storage tests to run on circle Jul 13, 2016
@cyli cyli changed the title Set rethink and mysql server DB storage tests to run on circle WIP: Set rethink and mysql server DB storage tests to run on circle Jul 13, 2016
@cyli cyli force-pushed the db-tests-refactor branch 3 times, most recently from b47ce44 to a34a946 Compare July 13, 2016 21:15
@cyli cyli changed the title WIP: Set rethink and mysql server DB storage tests to run on circle Set rethink and mysql server DB storage tests to run on circle Jul 13, 2016
@@ -130,16 +130,13 @@ test:
@echo
go test -tags "${NOTARY_BUILDTAGS}" $(TESTOPTS) $(PKGS)

test-full: TESTOPTS =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for removing this target? Admittedly, I don't use it much because it doesn't include fmt and misspell

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only reason is because CI doesn't use it, and doesn't have the full linting. I can just add those, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(also, someone could just do make vet lint test)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I'm fine with either removing it or bringing it in parity with circle. Agree that the current version isn't particularly useful

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Combined all the lint functionality into one function, as per #830 (comment)

# misspell target, don't include Godeps, binaries, python tests, or git files
misspell:
@echo "+ $@"
# mispell - requires that the following be run first:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: misspell

@cyli cyli force-pushed the db-tests-refactor branch 2 times, most recently from ea97efd to f9caac5 Compare July 14, 2016 18:11
counter := make(map[string]int)
for _, tufObj := range expected {
k := entryKey(tufObj.Gun, tufObj.Role)
gun, ok := s.tufMeta[k]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we rename this to gunList or versionList for clarity?

@cyli cyli force-pushed the db-tests-refactor branch 2 times, most recently from 985502d to 52a51ac Compare July 14, 2016 23:01
@riyazdf
Copy link
Contributor

riyazdf commented Jul 18, 2016

LGTM! Thank you for all of your work on this :)

@@ -0,0 +1,27 @@
// +build !mysqldb
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this also include !rethinkdb?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately sqldb_tests has some sample config generation that's needed by tuf_store_test, which didn't get refactored in this PR. I plan on doing that in the next PR.

That's why sqlite3 is still needed because without that refactor, the rethinkdb tests still run the tuf_store_test, which depends on stuff in sqldb_test.

@endophage
Copy link
Contributor

Seems a little odd/confusing that the sqlite tests will not run if the mysql tests are run, but will run with the rethinkdb tests. Seems like they should either always run, or have their own build flag (rather than being !<something else>

Other than that, LGTM.

@cyli
Copy link
Contributor Author

cyli commented Jul 19, 2016

@endophage I am fixing that in the next PR - I needed to refactor some other tests in order to fix so me dependencies in sqldb_tests, so they're being run by rethink right now.

I'm planning on : no flags, sqlite3 tests run. mysqldb flag - mysql tests run. rethinkdb - rethink tests run. Does that sound right?

cyli added 8 commits July 19, 2016 15:49
Signed-off-by: Ying Li <ying.li@docker.com>
…eal MySQL server too

Signed-off-by: Ying Li <ying.li@docker.com>
Signed-off-by: Ying Li <ying.li@docker.com>
…ap test.

Signed-off-by: Ying Li <ying.li@docker.com>
…o they can be applied to rethink.

This also fixes the following bugs:

1.  MemStorage's UpdateMany previously did a partial update even if there was a conflict.
    Now we check for conflicts before updating.
2.  MemStorage's UpdateMany allowed you to insert the same version twice.
3.  RethinkDB's UpdateMany does a partial update even if there was a conflict, because the
    deletion criteria value (for timestamp_checksum) was passed as a list not as strings.
4.  RethinkDB's delete did not actually delete metadata, because the deletion criteria value
    (for gun) was passed as a list and not as strings.

Signed-off-by: Ying Li <ying.li@docker.com>
…ion test are separate.

Signed-off-by: Ying Li <ying.li@docker.com>
Signed-off-by: Ying Li <ying.li@docker.com>
…d old metadata is no longer current.

Also rename a variable to be more clear, and make invalid arguments to the integration/testdb scripts fail faster.

Signed-off-by: Ying Li <ying.li@docker.com>
@endophage
Copy link
Contributor

endophage commented Jul 19, 2016

@cyli sounds perfect! Merging now when CI finishes

@endophage endophage merged commit 1023a94 into notaryproject:master Jul 19, 2016
@cyli cyli deleted the db-tests-refactor branch July 19, 2016 23:29
@cyli cyli mentioned this pull request Jul 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants