Skip to content

cleanup(storage): rename testbench to emulator#5518

Merged
coryan merged 17 commits intogoogleapis:masterfrom
vnghia:emulator
Nov 24, 2020
Merged

cleanup(storage): rename testbench to emulator#5518
coryan merged 17 commits intogoogleapis:masterfrom
vnghia:emulator

Conversation

@vnghia
Copy link
Copy Markdown
Contributor

@vnghia vnghia commented Nov 18, 2020

0aa076d: Rename UsingTestbench to UsingEmulator in google/cloud/storage/
2b0e63b: enable test against emulator for TEST_F(ObjectFileIntegrationTest, UploadFileBinary)
Other commits are self-explanatory

Finally, close #4751 🎉


This change is Reviewable

@vnghia vnghia requested a review from a team November 18, 2020 09:20
@product-auto-label product-auto-label Bot added the api: storage Issues related to the Cloud Storage API. label Nov 18, 2020
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Nov 18, 2020
@ghost
Copy link
Copy Markdown

ghost commented Nov 18, 2020

Does not need to be done in this PR, but I think the dependencies in setup-development-environment.md need to be updated as well.

@coryan coryan added the kokoro:run Add this label to force Kokoro to re-run the tests. label Nov 18, 2020
Copy link
Copy Markdown
Contributor

@coryan coryan left a comment

Choose a reason for hiding this comment

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

🎊

This is awesome news. I am a bit concerned about changes to the "public" interface. I am going to discuss with my colleagues, I suspect we will need to change some things in a backwards compatible way.

+kokoro:run

Reviewed 69 of 69 files at r1.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @vnvo2409)


google/cloud/storage/client_options.h, line 63 at r1 (raw file):

 * By default, several environment variables are read to configure the client:
 *
 * - `CLOUD_STORAGE_EMULATOR_ENDPOINT`: if set, use this http endpoint to

I think this would make the change a breaking change, and I am not sure we need to do it. I mean, the naming will be a bit awkward without this change, but OTOH, I am not sure we need to break any build scripts / tests that application developers may have created.

To be clear, I am not sure this is a blocker, but I am not sure it is not either. Let me chat with some folks here, including @devjgm .


google/cloud/storage/doc/storage-main.dox, line 61 at r1 (raw file):

- `CLOUD_STORAGE_ENABLE_TRACING=raw-client,http` enables all logging.

- `CLOUD_STORAGE_EMULATOR_ENDPOINT=...` override the default endpoint used by

Putting a pin here to think about backwards compatibility.


google/cloud/storage/emulator/emulator.py, line 680 at r1 (raw file):

                    None,
                )
                blob.metadata.metadata["x_emulator_transfer_encoding"] = ":".join(

This is also something that application developers may be using in their own testing.


google/cloud/storage/emulator/README.md, line 45 at r1 (raw file):

### return-broken-stream

Set request headers with `x-goog-emulator-instructions: return-broken-stream`.

I know folks in other libraries (notably golang, maybe Python and Java too) use these headers to do their own testing. I think we should not break their code. What if we supported both x-goo-emulator-instructions and x-goog-testbench-instructions with the same semantics?


google/cloud/storage/tools/run_testbench_utils.sh, line 19 at r1 (raw file):

source module lib/io.sh

EMULATOR_PID=0

I note this file is not renamed, any reason why it should not be?

@kokoro-team kokoro-team removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Nov 18, 2020
@vnghia
Copy link
Copy Markdown
Contributor Author

vnghia commented Nov 18, 2020

I note this file is not renamed, any reason why it should not be?

I forgot this function. The whole CI will collapse

@vnghia
Copy link
Copy Markdown
Contributor Author

vnghia commented Nov 18, 2020

This is awesome news. I am a bit concerned about changes to the "public" interface. I am going to discuss with my colleagues, I suspect we will need to change some things in a backwards compatible way.

I think we could rename from emulator to testbench but I prefer the emulator 😕

I know folks in other libraries (notably golang, maybe Python and Java too) use these headers to do their own testing. I think we should not break their code. What if we supported both x-goo-emulator-instructions and x-goog-testbench-instructions with the same semantics?

It shouldn't be too hard. I think so

@codecov
Copy link
Copy Markdown

codecov Bot commented Nov 18, 2020

Codecov Report

Merging #5518 (71b0cd9) into master (d7d3576) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #5518   +/-   ##
=======================================
  Coverage   95.56%   95.56%           
=======================================
  Files        1065     1065           
  Lines       98059    98055    -4     
=======================================
+ Hits        93706    93707    +1     
+ Misses       4353     4348    -5     
Impacted Files Coverage Δ
google/cloud/storage/client_options.h 100.00% <ø> (ø)
...loud/storage/internal/grpc_client_failures_test.cc 100.00% <ø> (ø)
...e/cloud/storage/testing/storage_integration_test.h 100.00% <ø> (ø)
...s/object_list_objects_versions_integration_test.cc 79.54% <ø> (ø)
...d/storage/tests/object_rewrite_integration_test.cc 96.64% <ø> (ø)
...d/storage/benchmarks/throughput_experiment_test.cc 98.11% <100.00%> (ø)
google/cloud/storage/client_options.cc 97.18% <100.00%> (+0.08%) ⬆️
google/cloud/storage/client_options_test.cc 100.00% <100.00%> (ø)
...oud/storage/examples/storage_bucket_acl_samples.cc 96.79% <100.00%> (ø)
...ud/storage/examples/storage_bucket_cors_samples.cc 94.54% <100.00%> (ø)
... and 55 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d7d3576...71b0cd9. Read the comment docs.

@coryan coryan added the kokoro:run Add this label to force Kokoro to re-run the tests. label Nov 18, 2020
Copy link
Copy Markdown
Contributor

@coryan coryan left a comment

Choose a reason for hiding this comment

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

To be clear, I like the emulator name better too. Just that in some places we may need to support both the old name and the new name.

+kokoro:run

Reviewed 1 of 1 files at r2.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @vnvo2409)

@kokoro-team kokoro-team removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Nov 18, 2020
@vnghia
Copy link
Copy Markdown
Contributor Author

vnghia commented Nov 24, 2020

@coryan Is there any update about this PR ?

Copy link
Copy Markdown
Contributor

@coryan coryan left a comment

Choose a reason for hiding this comment

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

I think we need to preserve backwards compatibility where we can. See below for details.

Reviewable status: all files reviewed, 9 unresolved discussions (waiting on @vnvo2409)


google/cloud/storage/client_options.h, line 63 at r1 (raw file):

Previously, coryan (Carlos O'Ryan) wrote…

I think this would make the change a breaking change, and I am not sure we need to do it. I mean, the naming will be a bit awkward without this change, but OTOH, I am not sure we need to break any build scripts / tests that application developers may have created.

To be clear, I am not sure this is a blocker, but I am not sure it is not either. Let me chat with some folks here, including @devjgm .

This is definitely a breaking change, I think the best way to proceed is to continue to support the old option, but change the documentation to recommend the new one.

These changes are Okay, but I will be asking for other changes elsewhere.


google/cloud/storage/client_options.cc, line 34 at r2 (raw file):

namespace internal {

I think we want a helper function like so:

absl::optional<std::string> GetEmulator() {
  auto emulator = GetEnv("CLOUD_STORAGE_EMULATOR_ENDPOINT");
  if (emulator) return emulator;
  return GetEnv("CLOUD_STORAGE_TESTBENCH_ENDPOINT");
}

this function would be used in this file like so:

std::string JsonEndpoint(ClientOptions const& options) {
  return GetEmulator().value_or(options.endpoint_) + "/storage/" + options.version();
}

This would preserve backwards compatibility and we would signal to users (in the documentation) that the new name is preferred.


google/cloud/storage/well_known_headers_test.cc, line 28 at r2 (raw file):

/// @test Verify that CustomHeader works as expected.
TEST(WellKnownHeader, CustomHeader) {
  CustomHeader header("x-goog-emulator-instructions", "do-stuff");

FYI, these changes are Okay, but the emulator needs to support the old values for backwards compatibility, more on that later.


google/cloud/storage/doc/storage-main.dox, line 61 at r1 (raw file):

Previously, coryan (Carlos O'Ryan) wrote…

Putting a pin here to think about backwards compatibility.

I think we should add a description for the old option, something like:

- `CLOUD_STORAGE_TESTBENCH_ENDPOINT=...` **DEPRECATED** use `CLOUD_STORAGE_EMULATOR_ENDPOINT` instead.

google/cloud/storage/emulator/emulator.py, line 680 at r1 (raw file):

Previously, coryan (Carlos O'Ryan) wrote…

This is also something that application developers may be using in their own testing.

I think we need to preserve the backwards compatible behavior. please keep the old names for these attributes, e.g. x_testbench_transfer_encoding.


google/cloud/storage/emulator/grpc_server.py, line 139 at r2 (raw file):

            request, bucket, context
        )
        upload.metadata.metadata["x_emulator_upload"] = "resumable"

Ditto, please preserve the returned name. If we must, we can return both the new and old names.


google/cloud/storage/emulator/README.md, line 41 at r2 (raw file):

## Force Failures

You can force the following failures by using the `x-goog-emulator-instructions` header.

Maybe add something like:

... using the `x-goog-emulator-instructions` header. The `x-goog-testbench-instructions` header is deprecated, but supported for backwards compatibility, please change your code to use `x-goog-emulator-instructions` instead.

google/cloud/storage/emulator/gcs/object.py, line 93 at r2 (raw file):

    ):
        if context is None:
            instruction = request.headers.get("x-goog-emulator-instructions")

maybe:

instruction = request.headers.get("x-goog-emulator-instructions") or request.headers.get("x-goog-testbench-instructions")

But if there is a more pythonic way to say "use a if present, b if not present" then I am all for it.


google/cloud/storage/emulator/gcs/object.py, line 175 at r2 (raw file):

            "bucket": bucket.name,
            "name": object_name,
            "metadata": {"x_emulator_upload": "simple"},

As above, we need to preserve backwards compatibility for these.


google/cloud/storage/examples/storage_examples_common.cc, line 27 at r2 (raw file):

bool UsingEmulator() {
  return !google::cloud::internal::GetEnv("CLOUD_STORAGE_EMULATOR_ENDPOINT")

I think we should support the backwards compatibility option here. Thoughts?


google/cloud/storage/internal/retry_object_read_source.cc, line 74 at r2 (raw file):

    return result;
  }
  bool has_emulator_instructions = false;

FYI, I thought about asking for backwards compatibility here, but it is not needed, this is our own code to support our own tests, we are fine.


google/cloud/storage/tests/object_basic_crud_integration_test.cc, line 155 at r2 (raw file):

StatusOr<Client> CreateNonDefaultClient() {
  auto emulator =
      google::cloud::internal::GetEnv("CLOUD_STORAGE_EMULATOR_ENDPOINT");

FYI, another case where backwards compatibility does not seem necessary.

@vnghia
Copy link
Copy Markdown
Contributor Author

vnghia commented Nov 24, 2020

Done,
I've already copied the emulator to a different location and run the test agaist master in order to verify that the emulator supports both testbench and emulator ( grpc_integration_test failed but it is acceptable, cause no one uses grpc right now )

@vnghia vnghia requested a review from coryan November 24, 2020 17:34
@coryan coryan added the kokoro:run Add this label to force Kokoro to re-run the tests. label Nov 24, 2020
Copy link
Copy Markdown
Contributor

@coryan coryan left a comment

Choose a reason for hiding this comment

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

+kokoro:run

With this change a few x_testbench_* attributes in the object metadata are becoming x_emulator_*. That is still a breaking change. I would be Okay if we created both, with the old ones mark as deprecated (maybe to be removed in 90 days or something). Thoughts?

Reviewed 12 of 12 files at r3.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@kokoro-team kokoro-team removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Nov 24, 2020
@vnghia
Copy link
Copy Markdown
Contributor Author

vnghia commented Nov 24, 2020

I would be Okay if we created both, with the old ones mark as deprecated (maybe to be removed in 90 days or something). Thoughts?

On server side, we created only x_emulator_*. However, when the client requests the object metadata, x_testbench_* will be automatically added into the response ( you could take a look at rest_metadata ). I think we could keep supporting x_testbench_* even after 90 days. I think there should be no problems.

@coryan
Copy link
Copy Markdown
Contributor

coryan commented Nov 24, 2020

On server side, we created only x_emulator_*. However, when the client requests the object metadata, x_testbench_* will be automatically added into the response ( you could take a look at rest_metadata ).

I missed that, thanks!

Copy link
Copy Markdown
Contributor

@coryan coryan left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@coryan coryan merged commit eff4cca into googleapis:master Nov 24, 2020
@vnghia vnghia deleted the emulator branch November 24, 2020 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: storage Issues related to the Cloud Storage API. cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add testbench support for GCS+gRPC

4 participants