-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
serverutils: implement the testserver interfaces indirectly
TLDR: unit tests using TestServer/TestCluster now produce warning and notice messages upon certain suspicious API usage. For example: ``` $ dev test //pkg/server/storage_api -f TestStatusGetFiles === RUN TestStatusGetFiles ... pkg/server/storage_api/storage_api_test_test/pkg/server/storage_api/files_test.go:46: (TestStatusGetFiles) NOTICE: .GetStatusClient() called via implicit interface ApplicationLayerInterface; HINT: consider using .ApplicationLayer().GetStatusClient() instead. conditional_wrap.go:193: TIP: consider replacing the test server initialization from: ts, db, kvDB := serverutils.StartServer(t, ...) // or: tc := serverutils.StartCluster(t, ...) ts := tc.Server(0) To: srv, db, kvDB := serverutils.StartServer(t, ...) defer srv.Stop(...) ts := srv.ApplicationLayer() // or: tc := serverutils.StartCluster(t, ...) ts := tc.Server(0).ApplicationLayer() ``` The following warnings/notices are implemented. **ApplicationLayerInterface** The problem here is that the implicit implementation of `ApplicationLayerInterface` inside `TestServerInterface` is likely misused. If/when the test server automatically starts a secondary tenant, the *implicit* `ApplicationLayerInterface` refers to the system tenant, whereas only `.ApplicationLayer()` refers to the secondary tenant. It's likely that the test code should use the latter. For this, a warning is printed when a method from the *implicit* `ApplicationLayerInterface` is called. The warning is not printed if the test has indicated (via `DefaultTestTenant: base.TestIsForStorageLayerAndNeedsASystemTenant`) that it is ever only interested in the storage layer. **StorageLayerInterface** We want to promote the use of the explicit interface accessor `.StorageLayer()` to access the methods of `StorageLayerInterface`. For this, a notice is printed when a method from the *implicit* `StorageLayerInterface` is called. The notice is not printed if the test has indicated (via `DefaultTestTenant: base.TestIsForStorageLayerAndNeedsASystemTenant`) that it is ever only interested in the storage layer. **TenantControlInterface** We want to promote the use of the explicit interface accessor `.TenantController()` to access the methods of `TenantControlInterface`. For this, a notice is printed when a method from the *implicit* `TenantControlInterface` is called. Release note: None
- Loading branch information
Showing
21 changed files
with
1,005 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.