Skip to content

Commit eff4cca

Browse files
authored
cleanup(storage): rename testbench to emulator (#5518)
1 parent 5ffb601 commit eff4cca

70 files changed

Lines changed: 329 additions & 3871 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,5 @@ cmake-build-*/
2525
# Ignore staging files for the ci/kokoro/install builds
2626
ci/kokoro/install/ccache-contents/
2727

28-
google/cloud/storage/testbench/__pycache__/
29-
google/cloud/storage/testbench/*.pyc
3028
google/cloud/storage/emulator/**/__pycache__/
3129
google/cloud/storage/emulator/**/*.pyc

ci/kokoro/docker/Dockerfile.fedora

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ RUN dnf makecache && \
2929
# the container's /etc/passwd file.
3030
RUN echo 'root:' | chpasswd
3131

32-
# Install the Python modules needed to run the storage testbench
32+
# Install the Python modules needed to run the storage emulator
3333
RUN pip3 install --upgrade pip
3434
RUN pip3 install setuptools wheel
3535
RUN pip3 install git+git://github.com/googleapis/python-storage@8cf6c62a96ba3fff7e5028d931231e28e5029f1c

ci/kokoro/docker/Dockerfile.fedora-install

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ RUN pip3 install cmake_format==0.6.8
5252
# Install black to automatically format the Python files.
5353
RUN pip3 install black==19.3b0
5454

55-
# Install the Python modules needed to run the storage testbench
55+
# Install the Python modules needed to run the storage emulator
5656
RUN dnf makecache && dnf install -y python3-devel
5757
RUN pip3 install setuptools wheel
5858
RUN pip3 install git+git://github.com/googleapis/python-storage@8cf6c62a96ba3fff7e5028d931231e28e5029f1c

ci/kokoro/docker/Dockerfile.fedora-libcxx-msan

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ RUN dnf makecache && \
2929
# the container's /etc/passwd file.
3030
RUN echo 'root:' | chpasswd
3131

32-
# Install the Python modules needed to run the storage testbench
32+
# Install the Python modules needed to run the storage emulator
3333
RUN pip3 install --upgrade pip
3434
RUN pip3 install setuptools wheel
3535
RUN pip3 install git+git://github.com/googleapis/python-storage@8cf6c62a96ba3fff7e5028d931231e28e5029f1c

google/cloud/storage/benchmarks/throughput_experiment_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ bool ProductionOnly(ApiName api) {
4242
}
4343

4444
TEST_P(ThroughputExperimentIntegrationTest, Upload) {
45-
if (UsingTestbench() && ProductionOnly(GetParam())) GTEST_SKIP();
45+
if (UsingEmulator() && ProductionOnly(GetParam())) GTEST_SKIP();
4646

4747
auto client = MakeIntegrationTestClient();
4848
ASSERT_STATUS_OK(client);
@@ -71,7 +71,7 @@ TEST_P(ThroughputExperimentIntegrationTest, Upload) {
7171
}
7272

7373
TEST_P(ThroughputExperimentIntegrationTest, Download) {
74-
if (UsingTestbench() && ProductionOnly(GetParam())) GTEST_SKIP();
74+
if (UsingEmulator() && ProductionOnly(GetParam())) GTEST_SKIP();
7575

7676
auto client = MakeIntegrationTestClient();
7777
ASSERT_STATUS_OK(client);

google/cloud/storage/ci/run_integration_tests_emulator_bazel.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ if [[ "$exit_status" -ne 0 ]]; then
3939
exit "${exit_status}"
4040
fi
4141

42-
# Configure run_testbench_utils.sh to run the GCS testbench.
43-
source "${PROJECT_ROOT}/google/cloud/storage/tools/run_testbench_utils.sh"
42+
# Configure run_emulator_utils.sh to run the GCS emulator.
43+
source "${PROJECT_ROOT}/google/cloud/storage/tools/run_emulator_utils.sh"
4444

4545
# These can only run against production
4646
production_only_targets=(
@@ -54,13 +54,13 @@ production_only_targets=(
5454
--test_tag_filters="integration-test" -- \
5555
"${production_only_targets[@]}"
5656

57-
# `start_testbench` creates unsightly *.log files in the current directory
57+
# `start_emulator` creates unsightly *.log files in the current directory
5858
# (which is ${PROJECT_ROOT}) and we cannot use a subshell because we want the
5959
# environment variables that it sets.
6060
pushd "${HOME}" >/dev/null
61-
# Start the testbench on a fixed port, otherwise the Bazel cache gets
61+
# Start the emulator on a fixed port, otherwise the Bazel cache gets
6262
# invalidated on each run.
63-
start_testbench 8585 8000
63+
start_emulator 8585 8000
6464
popd >/dev/null
6565

6666
excluded_targets=(
@@ -78,32 +78,32 @@ done
7878
# `storage_bucket_samples` binary is missing the examples that use said bucket
7979
# are missing too.
8080
EMULATOR_SHA=$(git ls-files google/cloud/storage/emulator | sort | cat | sha256sum)
81-
testbench_args=(
82-
"--test_env=CLOUD_STORAGE_TESTBENCH_ENDPOINT=${CLOUD_STORAGE_TESTBENCH_ENDPOINT}"
81+
emulator_args=(
82+
"--test_env=CLOUD_STORAGE_EMULATOR_ENDPOINT=${CLOUD_STORAGE_EMULATOR_ENDPOINT}"
8383
"--test_env=CLOUD_STORAGE_GRPC_ENDPOINT=${CLOUD_STORAGE_GRPC_ENDPOINT}"
8484
"--test_env=HTTPBIN_ENDPOINT=${HTTPBIN_ENDPOINT}"
8585
"--test_env=GOOGLE_CLOUD_CPP_STORAGE_TEST_HMAC_SERVICE_ACCOUNT=fake-service-account-sign@example.com"
8686
"--test_env=GOOGLE_CLOUD_CPP_AUTO_RUN_EXAMPLES=yes"
8787
"--test_env=EMULATOR_SHA=${EMULATOR_SHA}"
8888
)
89-
"${BAZEL_BIN}" run "${bazel_test_args[@]}" "${testbench_args[@]}" \
89+
"${BAZEL_BIN}" run "${bazel_test_args[@]}" "${emulator_args[@]}" \
9090
"//google/cloud/storage/examples:storage_bucket_samples" \
9191
-- create-bucket-for-project \
9292
"${GOOGLE_CLOUD_CPP_STORAGE_TEST_DESTINATION_BUCKET_NAME}" \
9393
"${GOOGLE_CLOUD_PROJECT}" >/dev/null
9494

9595
# We need to forward some environment variables suitable for running against
96-
# the testbench. Note that the HMAC service account is completely invalid and
96+
# the emulator. Note that the HMAC service account is completely invalid and
9797
# it is not unique to each test, neither is a problem when using the emulator.
98-
"${BAZEL_BIN}" "${BAZEL_VERB}" "${bazel_test_args[@]}" "${testbench_args[@]}" \
98+
"${BAZEL_BIN}" "${BAZEL_VERB}" "${bazel_test_args[@]}" "${emulator_args[@]}" \
9999
--test_tag_filters="integration-test" -- \
100100
"//google/cloud/storage/...:all" \
101101
"${excluded_targets[@]}"
102102
exit_status=$?
103103

104104
if [[ "$exit_status" -ne 0 ]]; then
105105
source "${PROJECT_ROOT}/ci/define-dump-log.sh"
106-
dump_log "${HOME}/testbench.log"
106+
dump_log "${HOME}/gcs_emulator.log"
107107
fi
108108

109109
exit "${exit_status}"

google/cloud/storage/ci/run_integration_tests_emulator_cmake.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ shift
3232
ctest_args=("$@")
3333

3434
# Configure run_emulators_utils.sh to find the instance admin emulator.
35-
source "${PROJECT_ROOT}/google/cloud/storage/tools/run_testbench_utils.sh"
35+
source "${PROJECT_ROOT}/google/cloud/storage/tools/run_emulator_utils.sh"
3636

3737
# Use the same configuration parameters as we use for testing against
3838
# production. Easier to maintain just one copy.
@@ -43,7 +43,7 @@ export GOOGLE_CLOUD_CPP_STORAGE_TEST_SIGNING_KEYFILE="${PROJECT_ROOT}/google/clo
4343
export GOOGLE_CLOUD_CPP_STORAGE_TEST_SIGNING_CONFORMANCE_FILENAME="${PROJECT_ROOT}/google/cloud/storage/tests/v4_signatures.json"
4444

4545
cd "${BINARY_DIR}"
46-
start_testbench
46+
start_emulator
4747

4848
# GOOGLE_CLOUD_CPP_STORAGE_TEST_BUCKET_NAME is automatically created, but we
4949
# need to create the *DESTINATION_BUCKET_NAME too. Note that when the
@@ -59,12 +59,12 @@ fi
5959
ctest -R "^storage_" "${ctest_args[@]}"
6060
exit_status=$?
6161

62-
kill_testbench
62+
kill_emulator
6363
trap '' EXIT
6464

6565
if [[ "$exit_status" -ne 0 ]]; then
6666
source "${PROJECT_ROOT}/ci/define-dump-log.sh"
67-
dump_log "${HOME}/testbench.log"
67+
dump_log "${HOME}/emulator.log"
6868
fi
6969

7070
exit "${exit_status}"

google/cloud/storage/client_options.cc

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,29 @@ using ::google::cloud::internal::GetEnv;
3232

3333
namespace internal {
3434

35+
absl::optional<std::string> GetEmulator() {
36+
auto emulator = GetEnv("CLOUD_STORAGE_EMULATOR_ENDPOINT");
37+
if (emulator) return emulator;
38+
return GetEnv("CLOUD_STORAGE_TESTBENCH_ENDPOINT");
39+
}
40+
3541
std::string JsonEndpoint(ClientOptions const& options) {
36-
return GetEnv("CLOUD_STORAGE_TESTBENCH_ENDPOINT")
37-
.value_or(options.endpoint_) +
38-
"/storage/" + options.version();
42+
return GetEmulator().value_or(options.endpoint_) + "/storage/" +
43+
options.version();
3944
}
4045

4146
std::string JsonUploadEndpoint(ClientOptions const& options) {
42-
return GetEnv("CLOUD_STORAGE_TESTBENCH_ENDPOINT")
43-
.value_or(options.endpoint_) +
44-
"/upload/storage/" + options.version();
47+
return GetEmulator().value_or(options.endpoint_) + "/upload/storage/" +
48+
options.version();
4549
}
4650

4751
std::string XmlEndpoint(ClientOptions const& options) {
48-
return GetEnv("CLOUD_STORAGE_TESTBENCH_ENDPOINT").value_or(options.endpoint_);
52+
return GetEmulator().value_or(options.endpoint_);
4953
}
5054

5155
std::string IamEndpoint(ClientOptions const& options) {
52-
auto testbench = GetEnv("CLOUD_STORAGE_TESTBENCH_ENDPOINT");
53-
if (testbench) return *testbench + "/iamapi";
56+
auto emulator = GetEmulator();
57+
if (emulator) return *emulator + "/iamapi";
5458
return options.iam_endpoint();
5559
}
5660

@@ -59,7 +63,7 @@ std::string IamEndpoint(ClientOptions const& options) {
5963
namespace {
6064
StatusOr<std::shared_ptr<oauth2::Credentials>> StorageDefaultCredentials(
6165
ChannelOptions const& channel_options) {
62-
auto emulator = cloud::internal::GetEnv("CLOUD_STORAGE_TESTBENCH_ENDPOINT");
66+
auto emulator = internal::GetEmulator();
6367
if (emulator.has_value()) {
6468
return StatusOr<std::shared_ptr<oauth2::Credentials>>(
6569
oauth2::CreateAnonymousCredentials());
@@ -126,7 +130,7 @@ ClientOptions::ClientOptions(std::shared_ptr<oauth2::Credentials> credentials,
126130
download_stall_timeout_(
127131
GOOGLE_CLOUD_CPP_STORAGE_DEFAULT_DOWNLOAD_STALL_TIMEOUT),
128132
channel_options_(std::move(channel_options)) {
129-
auto emulator = GetEnv("CLOUD_STORAGE_TESTBENCH_ENDPOINT");
133+
auto emulator = internal::GetEmulator();
130134
if (emulator.has_value()) {
131135
endpoint_ = *emulator;
132136
iam_endpoint_ = *emulator + "/iamapi";

google/cloud/storage/client_options.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class ChannelOptions {
6060
*
6161
* By default, several environment variables are read to configure the client:
6262
*
63-
* - `CLOUD_STORAGE_TESTBENCH_ENDPOINT`: if set, use this http endpoint to
63+
* - `CLOUD_STORAGE_EMULATOR_ENDPOINT`: if set, use this http endpoint to
6464
* make all http requests instead of the production GCS service. Also,
6565
* if set, the `CreateDefaultClientOptions()` function will use an
6666
* `AnonymousCredentials` object instead of loading Application Default
@@ -82,7 +82,7 @@ class ClientOptions {
8282
* Creates a `ClientOptions` with Google Application Default %Credentials.
8383
*
8484
* If Application Default %Credentials could not be loaded, this returns a
85-
* `Status` with failure details. If the `CLOUD_STORAGE_TESTBENCH_ENDPOINT`
85+
* `Status` with failure details. If the `CLOUD_STORAGE_EMULATOR_ENDPOINT`
8686
* environment variable is set, this function instead uses an
8787
* `AnonymousCredentials` to configure the client.
8888
*/

google/cloud/storage/client_options_test.cc

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ class ClientOptionsTest : public ::testing::Test {
3131
public:
3232
ClientOptionsTest()
3333
: enable_tracing_("CLOUD_STORAGE_ENABLE_TRACING", {}),
34-
endpoint_("CLOUD_STORAGE_TESTBENCH_ENDPOINT", {}),
34+
endpoint_("CLOUD_STORAGE_EMULATOR_ENDPOINT", {}),
35+
old_endpoint_("CLOUD_STORAGE_TESTBENCH_ENDPOINT", {}),
3536
generator_(std::random_device{}()) {}
3637

3738
std::string CreateRandomFileName() {
@@ -46,6 +47,7 @@ class ClientOptionsTest : public ::testing::Test {
4647
protected:
4748
testing_util::ScopedEnvironment enable_tracing_;
4849
testing_util::ScopedEnvironment endpoint_;
50+
testing_util::ScopedEnvironment old_endpoint_;
4951
google::cloud::internal::DefaultPRNG generator_;
5052
};
5153

@@ -124,7 +126,7 @@ TEST_F(ClientOptionsTest, EnableHttp) {
124126
}
125127

126128
TEST_F(ClientOptionsTest, EndpointsDefault) {
127-
testing_util::ScopedEnvironment endpoint("CLOUD_STORAGE_TESTBENCH_ENDPOINT",
129+
testing_util::ScopedEnvironment endpoint("CLOUD_STORAGE_EMULATOR_ENDPOINT",
128130
{});
129131
ClientOptions options(oauth2::CreateAnonymousCredentials());
130132
EXPECT_EQ("https://storage.googleapis.com", options.endpoint());
@@ -137,7 +139,7 @@ TEST_F(ClientOptionsTest, EndpointsDefault) {
137139
}
138140

139141
TEST_F(ClientOptionsTest, EndpointsOverride) {
140-
testing_util::ScopedEnvironment endpoint("CLOUD_STORAGE_TESTBENCH_ENDPOINT",
142+
testing_util::ScopedEnvironment endpoint("CLOUD_STORAGE_EMULATOR_ENDPOINT",
141143
{});
142144
ClientOptions options(oauth2::CreateAnonymousCredentials());
143145
options.set_endpoint("http://127.0.0.1.nip.io:1234");
@@ -151,7 +153,21 @@ TEST_F(ClientOptionsTest, EndpointsOverride) {
151153
internal::IamEndpoint(options));
152154
}
153155

154-
TEST_F(ClientOptionsTest, EndpointsTestBench) {
156+
TEST_F(ClientOptionsTest, EndpointsEmulator) {
157+
testing_util::ScopedEnvironment endpoint("CLOUD_STORAGE_EMULATOR_ENDPOINT",
158+
"http://localhost:1234");
159+
ClientOptions options(oauth2::CreateAnonymousCredentials());
160+
EXPECT_EQ("http://localhost:1234", options.endpoint());
161+
EXPECT_EQ("http://localhost:1234/storage/v1",
162+
internal::JsonEndpoint(options));
163+
EXPECT_EQ("http://localhost:1234/upload/storage/v1",
164+
internal::JsonUploadEndpoint(options));
165+
EXPECT_EQ("http://localhost:1234", internal::XmlEndpoint(options));
166+
EXPECT_EQ("http://localhost:1234/iamapi", internal::IamEndpoint(options));
167+
}
168+
169+
TEST_F(ClientOptionsTest, OldEndpointsEmulator) {
170+
google::cloud::internal::UnsetEnv("CLOUD_STORAGE_EMULATOR_ENDPOINT");
155171
testing_util::ScopedEnvironment endpoint("CLOUD_STORAGE_TESTBENCH_ENDPOINT",
156172
"http://localhost:1234");
157173
ClientOptions options(oauth2::CreateAnonymousCredentials());

0 commit comments

Comments
 (0)