8000 feat(spanner): tests and samples for drop-database protection by devbww · Pull Request #11637 · googleapis/google-cloud-cpp · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(spanner): tests and samples for drop-database protection #11637

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

Merged
merged 1 commit into from
May 17, 2023

Conversation

devbww
Copy link
Contributor
@devbww devbww commented May 17, 2023

Exercise the new DatabaseAdminClient::UpdateDatabase() interface to set the Database.enable_drop_protection field.


This change is Reviewable

Exercise the new `DatabaseAdminClient::UpdateDatabase()` interface
to set the `Database.enable_drop_protection` field.
@product-auto-label product-auto-label bot added api: spanner Issues related to the Spanner API. samples Issues that are directly related to samples. labels May 17, 2023
@codecov
Copy link
codecov bot commented May 17, 2023

Codecov Report

❗ No coverage uploaded for pull request base (main@c7c7ca7). Click here to learn what that means.
Patch coverage: 22.72% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #11637   +/-   ##
=======================================
  Coverage        ?   93.77%           
=======================================
  Files           ?     1824           
  Lines           ?   164416           
  Branches        ?        0           
=======================================
  Hits            ?   154184           
  Misses          ?    10232           
  Partials        ?        0           
Impacted Files Coverage Δ
google/cloud/spanner/samples/samples.cc 61.74% <22.72%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@devbww devbww marked this pull request as ready for review May 17, 2023 07:15
@devbww devbww requested a review from a team as a code owner May 17, 2023 07:15
@snippet-bot
Copy link
snippet-bot bot commented May 17, 2023

Here is the summary of changes.

You are about to add 1 region tag.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@@ -581,6 +581,69 @@ TEST_F(DatabaseAdminClientTest, DatabasePostgreSQLBasics) {
EXPECT_STATUS_OK(drop_status);
}

/// @test Verify dropping a database fails with drop protection enabled.
TEST_F(DatabaseAdminClientTest, DropDatabaseProtection) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a test of our code or a test of the service? I do not think we want to spend a lot of time testing the service, that is not our job.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm (almost) totally with you. It does exercise our generated code a little, but the overarching reason for it is to cover a "thou shalt have" clause in the feature-specification doc that isn't worth contesting. :-|

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it is worth contesting, but not blocking this PR for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack.

database->set_enable_drop_protection(true);
auto updated = client_.UpdateDatabase(*database, update_mask).get();
if (emulator_) {
EXPECT_THAT(updated, StatusIs(StatusCode::kUnimplemented));
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider just skipping the test in this case. We already have tests for CreateDatabase() and DropDatabase().

Copy link
Contributor Author < 8000 /span>

Choose a reason for hiding this comment

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

The idea there is to get some active notification of when the behavior of the emulator changes.

We do have some instances of if (emulator) GTEST_SKIP(), but they are either old, or where the above tactic is too complicated.

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay.

}
google::cloud::spanner_admin::DatabaseAdminClient client(
google::cloud::spanner_admin::MakeDatabaseAdminConnection());
bool drop_protection = (argv[3][0] == 'T');
Copy link
Contributor

Choose a reason for hiding this comment

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

assuming ! argv[3].empty() ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

s[i] is actually [and weirdly] defined to return (a reference to) a char() value when i == s.size().

Copy link
Contributor

Choose a reason for hiding this comment

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

TIL

@devbww devbww merged commit 8ee7392 into googleapis:main May 17, 2023
@devbww devbww deleted the drop-database-protection branch May 17, 2023 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the Spanner API. samples Issues that are directly related to samples.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0