Skip to content

Test pre-1.4 seal migration #9085

Merged
mjarmy merged 39 commits into
masterfrom
test-pre1.4-seal-migration-phase1
Jun 11, 2020
Merged

Test pre-1.4 seal migration #9085
mjarmy merged 39 commits into
masterfrom
test-pre1.4-seal-migration-phase1

Conversation

@mjarmy
Copy link
Copy Markdown
Contributor

@mjarmy mjarmy commented May 27, 2020

This PR refactors the seal migration code into vault.Core so it's easier to test, and rewrites the seal migration tests for pre-1.4 shamir->transit and transit->shamir so that the tests simulate bringing the cluster down to do the migration.

In addition, there are a couple of minor changes:

  • Add a few minor improvements to the reusable storage test suite.
  • Remove the test that existed solely to exercise reusable storage.

alexanderbez
alexanderbez previously approved these changes May 27, 2020
Copy link
Copy Markdown
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

It looks mainly like lift-n-drop changes. Given the context, change LGTM 👍

Comment thread vault/core.go
Comment thread vault/external_tests/seal_migration/seal_migration_pre14_test.go Outdated
Comment thread vault/external_tests/seal_migration/seal_migration_test.go Outdated
// Unseal
if storage.IsRaft {
testhelpers.RaftClusterJoinNodes(t, cluster)
if err := testhelpers.VerifyRaftConfiguration(leader, numTestCores); err != nil {
Copy link
Copy Markdown
Contributor

@calvn calvn Jun 10, 2020

Choose a reason for hiding this comment

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

Following up with our discussion offline earlier and after giving it a bit more thought, I think that the const numTestCore might be unnecessary.

In cases were the number of cores is needed, we can either use vault.DefaultNumCores or extrapolate that from the cluster's core length or options field.

For instance, in this particular case, instead of passing in numTestCores we can either pass in opts.NumCores or len(cluster.Cores) (the latter is probably safer just in to avoid opt's zero value from being used). When setting opts.NumCores (L251), we can either leave that out and have NewTestCluster use the default value of 3 when creating cores, explicit set it to vault.DefaultNumCores, or set it to some other value if we want. The flexibility of using different numbers of cores if desired should remain the same.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

What I'd like to do then is keep numTestCores, with its setting of 5, and use it to set opts.NumCores as we are already doing. But everywhere else in the tests I will use len(cluster.Cores). I believe this is in consonance with what you are proposing, while at the same time sticking with 5 for the number of test cores to prove that we haven't hardwired the default value of 3 anywhere in the tests.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there a specific reason to use 5 vs 3 (the vault.DefaultNumCores value) for a multi-cluster setup?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The specific reason is that I want to make sure I don't accidentally hard-wire the ReusableStorage stuff to use the default 3 cores, and since this is the only place right now in the code base that is using reusable storage, its the only place I can do that.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Keeping in mind the simplify use of numTestCores commit (7271985), which addresses some parts of Calvin's suggestion, I think the changes looks good.

The numTestCores variable as it is used now is only applicable to the seal migration package and is only used in places where the full cluster is not present. So, we can't do len(cluster.Cores). Also, the reason quoted by Mike to have 5 cores seems valid as it is walking a case that ensures creation of necessary number of reusable storage artifacts.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The only remaining usage of numTestCores seems to be on here:

My suggestion was not to use len(cluster.Cores) in that instance since opts.NumCores is the field that determines the number of cores the cluster should have, but rather re-use the const value, vault.DefaultNumCores, that we already have for multi-core cluster setups.

@mjarmy mjarmy merged commit 3d02fb4 into master Jun 11, 2020
@mjarmy mjarmy deleted the test-pre1.4-seal-migration-phase1 branch June 11, 2020 19:08
catsby added a commit that referenced this pull request Jun 15, 2020
* master: (36 commits)
  Minor transform docs rewording (#9223)
  Validate physical CockroachDB table config value before using it (#9191)
  Validate physical MySQL database and table config values before using them (#9189)
  add disable_iss_validation option to k8s auth docs (#9142)
  fix: configutil redeclared as imported package name (#9211)
  Integrate password policies into RabbitMQ secret engine (#9143)
  Clarify cache setting. (#9204)
  Test pre-1.4 seal migration  (#9085)
  Simple typos (#9119)
  Update contribution guidelines
  changelog++
  Add ssh signing algorithm as a role option.   (#9096)
  replacing "a key usage mode" as it is confusing (#9194)
  changelog++
  fix: invalidate cached clients after a config change in the aws secrets backend (#9186)
  website: remove whitepaper link from subnav (#9190)
  changelog++
  Improving transit batch encrypt and decrypt latencies (#8775)
  changelog++
  AWS: Add iam_groups parameter to role create/update (#8811)
  ...
andaley pushed a commit that referenced this pull request Jul 17, 2020
* enable seal wrap in all seal migration tests

* move adjustForSealMigration to vault package

* fix adjustForSealMigration

* begin working on new seal migration test

* create shamir seal migration test

* refactor testhelpers

* add VerifyRaftConfiguration to testhelpers

* stub out TestTransit

* Revert "refactor testhelpers"

This reverts commit 39593defd0d4c6fd79aedfd37df6298391abb9db.

* get shamir test working again

* stub out transit join

* work on transit join

* Revert "move resuable storage test to avoid creating import cycle"

This reverts commit b3ff231.

* remove debug code

* initTransit now works with raft join

* runTransit works with inmem

* work on runTransit with raft

* runTransit works with raft

* get rid of dis-used test

* cleanup tests

* TestSealMigration_TransitToShamir_Pre14

* TestSealMigration_ShamirToTransit_Pre14

* split for pre-1.4 testing

* add simple tests for transit and shamir

* fix typo in test suite

* debug wrapper type

* test debug

* test-debug

* refactor core migration

* Revert "refactor core migration"

This reverts commit a776452.

* begin refactor of adjustForSealMigration

* fix bug in adjustForSealMigration

* clean up tests

* clean up core refactoring

* fix bug in shamir->transit migration

* remove unnecessary lock from setSealsForMigration()

* rename sealmigration test package

* use ephemeral ports below 30000

* simplify use of numTestCores
pull Bot pushed a commit to Reality2byte/vault that referenced this pull request Sep 9, 2025
… into main (hashicorp#9085) (hashicorp#9087)

* Add support for RFC 9440/8941 structured headers in client certificate handling

* Add changelog

---------

Co-authored-by: Huseyin Unal <23301714+husunal@users.noreply.github.com>
anwittin pushed a commit that referenced this pull request Sep 18, 2025
… into main (#9085) (#9091) (#9195)

* Add support for RFC 9440/8941 structured headers in client certificate handling

* Add changelog

---------

Co-authored-by: Huseyin Unal <23301714+husunal@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants