From b902004358278220f0b553d961f3bdc2835a9cbf Mon Sep 17 00:00:00 2001 From: Shubhangi Singh Date: Fri, 27 Sep 2024 11:02:02 +0000 Subject: [PATCH 01/40] adding universe domain tests+ ENV vars --- .kokoro/continuous/acceptance.cfg | 2 +- .kokoro/presubmit/acceptance.cfg | 2 +- .../storage/universe_domain_test.rb | 79 +++++++++++++++++++ .../acceptance/storage_helper.rb | 6 ++ 4 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 google-cloud-storage/acceptance/storage/universe_domain_test.rb diff --git a/.kokoro/continuous/acceptance.cfg b/.kokoro/continuous/acceptance.cfg index 4b8cf4e90276..206409bac25f 100644 --- a/.kokoro/continuous/acceptance.cfg +++ b/.kokoro/continuous/acceptance.cfg @@ -29,7 +29,7 @@ env_vars: { env_vars: { key: "SECRET_MANAGER_KEYS" - value: "" + value: "client-library-test-universe-domain-credential" } env_vars: { diff --git a/.kokoro/presubmit/acceptance.cfg b/.kokoro/presubmit/acceptance.cfg index 93a92eaa0842..e2972dfb43ca 100644 --- a/.kokoro/presubmit/acceptance.cfg +++ b/.kokoro/presubmit/acceptance.cfg @@ -29,7 +29,7 @@ env_vars: { env_vars: { key: "SECRET_MANAGER_KEYS" - value: "" + value: "client-library-test-universe-domain-credential" } env_vars: { diff --git a/google-cloud-storage/acceptance/storage/universe_domain_test.rb b/google-cloud-storage/acceptance/storage/universe_domain_test.rb new file mode 100644 index 000000000000..95e2ddbba446 --- /dev/null +++ b/google-cloud-storage/acceptance/storage/universe_domain_test.rb @@ -0,0 +1,79 @@ +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require "storage_helper" + +describe Google::Cloud::Storage do + let :storage do + Google::Cloud::Storage.new( + project_id: $test_universe_project_id, + credentials: $test_universe_domain_credential, + universe_domain: $test_universe_domain + ) + end + let(:bucket_name) { $bucket_names.first } + let(:bucket_location) { $test_universe_location } + let :bucket do + storage.bucket(bucket_name) || safe_gcs_execute { storage.create_bucket bucket_name, location: bucket_location } + end + + let :files do + { logo: { path: "acceptance/data/CloudPlatform_128px_Retina.png" } } + end + + after :all do + # Clean up: Ensure the bucket and objects are deleted after tests + bucket = storage.bucket bucket_name + if bucket + bucket.files.each(&:delete) # Delete all objects in the bucket + bucket.delete + end + end + + it "creates a new bucket with universe_domain" do + # Verify that the bucket is created + _(bucket.name).must_equal bucket_name + _(bucket.location).must_equal bucket_location + end + + it "uploads an object form a path in the bucket" do + # Upload an object + object_name = "CloudLogo.png" + original = File.new files[:logo][:path] + uploaded_file = bucket.create_file original, "CloudLogo.png" + # Verify object was uploaded + _(uploaded_file.name).must_equal object_name + + # Retrive object + retrieved_file = bucket.file object_name + + # Verify object + _(retrieved_file.name).must_equal object_name + end + + it "uploads and verifies an object in the bucket" do + # Upload an object + object_name = "test-object.txt" + object_content = "Hello this a test file" + uploaded_file = bucket.create_file StringIO.new(object_content), object_name + + # Verify object was uploaded + _(uploaded_file.name).must_equal object_name + + # Verify object content + retrieved_file = bucket.file object_name + downloaded_content = retrieved_file.download.read + _(downloaded_content).must_equal object_content + end +end diff --git a/google-cloud-storage/acceptance/storage_helper.rb b/google-cloud-storage/acceptance/storage_helper.rb index ab1ee4071634..f5a7d01f5c62 100644 --- a/google-cloud-storage/acceptance/storage_helper.rb +++ b/google-cloud-storage/acceptance/storage_helper.rb @@ -28,6 +28,12 @@ Minitest::Reporters.use! [Minitest::Reporters::SpecReporter.new, Minitest::Reporters::JUnitReporter.new] end +# Universe Domain Test project Credentials +$test_universe_domain = ENV["TEST_UNIVERSE_DOMAIN"] +$test_universe_project_id = ENV["TEST_UNIVERSE_PROJECT_ID"] +$test_universe_location = ENV["TEST_UNIVERSE_LOCATION"] +$test_universe_domain_credential = ENV["TEST_UNIVERSE_DOMAIN_CREDENTIAL"] + # Create shared storage object so we don't create new for each test scopes = ["https://www.googleapis.com/auth/devstorage.full_control", "https://www.googleapis.com/auth/iam"] $storage = Google::Cloud.new.storage retries: 10, scope: scopes From 59266ac2dd45cf9e18c5427bb591d4177660f898 Mon Sep 17 00:00:00 2001 From: Shubhangi Singh Date: Mon, 30 Sep 2024 04:40:39 +0000 Subject: [PATCH 02/40] removing unwanted change --- .kokoro/continuous/acceptance.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.kokoro/continuous/acceptance.cfg b/.kokoro/continuous/acceptance.cfg index 206409bac25f..4b8cf4e90276 100644 --- a/.kokoro/continuous/acceptance.cfg +++ b/.kokoro/continuous/acceptance.cfg @@ -29,7 +29,7 @@ env_vars: { env_vars: { key: "SECRET_MANAGER_KEYS" - value: "client-library-test-universe-domain-credential" + value: "" } env_vars: { From cef3000992a953bfe20c1a7aafd0823510703d3e Mon Sep 17 00:00:00 2001 From: Shubhangi Singh Date: Mon, 30 Sep 2024 05:37:02 +0000 Subject: [PATCH 03/40] removing test specific env vars from common file --- .../acceptance/storage/universe_domain_test.rb | 7 +++++++ google-cloud-storage/acceptance/storage_helper.rb | 6 ------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/google-cloud-storage/acceptance/storage/universe_domain_test.rb b/google-cloud-storage/acceptance/storage/universe_domain_test.rb index 95e2ddbba446..9223d8228a98 100644 --- a/google-cloud-storage/acceptance/storage/universe_domain_test.rb +++ b/google-cloud-storage/acceptance/storage/universe_domain_test.rb @@ -15,6 +15,13 @@ require "storage_helper" describe Google::Cloud::Storage do + + # Universe Domain Test project Credentials + $test_universe_domain = ENV["TEST_UNIVERSE_DOMAIN"] + $test_universe_project_id = ENV["TEST_UNIVERSE_PROJECT_ID"] + $test_universe_location = ENV["TEST_UNIVERSE_LOCATION"] + $test_universe_domain_credential = ENV["TEST_UNIVERSE_DOMAIN_CREDENTIAL"] + let :storage do Google::Cloud::Storage.new( project_id: $test_universe_project_id, diff --git a/google-cloud-storage/acceptance/storage_helper.rb b/google-cloud-storage/acceptance/storage_helper.rb index f5a7d01f5c62..ab1ee4071634 100644 --- a/google-cloud-storage/acceptance/storage_helper.rb +++ b/google-cloud-storage/acceptance/storage_helper.rb @@ -28,12 +28,6 @@ Minitest::Reporters.use! [Minitest::Reporters::SpecReporter.new, Minitest::Reporters::JUnitReporter.new] end -# Universe Domain Test project Credentials -$test_universe_domain = ENV["TEST_UNIVERSE_DOMAIN"] -$test_universe_project_id = ENV["TEST_UNIVERSE_PROJECT_ID"] -$test_universe_location = ENV["TEST_UNIVERSE_LOCATION"] -$test_universe_domain_credential = ENV["TEST_UNIVERSE_DOMAIN_CREDENTIAL"] - # Create shared storage object so we don't create new for each test scopes = ["https://www.googleapis.com/auth/devstorage.full_control", "https://www.googleapis.com/auth/iam"] $storage = Google::Cloud.new.storage retries: 10, scope: scopes From 9726809289cd49dddbfd3bb4e72d088fbac63fdc Mon Sep 17 00:00:00 2001 From: Shubhangi Singh Date: Mon, 30 Sep 2024 07:40:07 +0000 Subject: [PATCH 04/40] adding system env vars --- .kokoro/integration.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.kokoro/integration.sh b/.kokoro/integration.sh index af6fb32bf5be..c1b9fe423be2 100755 --- a/.kokoro/integration.sh +++ b/.kokoro/integration.sh @@ -29,6 +29,12 @@ for ruby_version in "${ruby_versions[@]}"; do # is in a read-only location. export GEM_HOME=$HOME/.gem export PATH=$GEM_HOME/bin:$PATH + + # For universe domain testing + export TEST_UNIVERSE_DOMAIN_CREDENTIAL=$(realpath ${KOKORO_GFILE_DIR}/secret_manager/client-library-test-universe-domain-credential) + export TEST_UNIVERSE_DOMAIN=$(gcloud secrets versions access latest --project cloud-devrel-kokoro-resources --secret=client-library-test-universe-domain) + export TEST_UNIVERSE_PROJECT_ID=$(gcloud secrets versions access latest --project cloud-devrel-kokoro-resources --secret=client-library-test-universe-project-id) + export TEST_UNIVERSE_LOCATION=$(gcloud secrets versions access latest --project cloud-devrel-kokoro-resources --secret=client-library-test-universe-storage-location) gem install --no-document toys From a331bbdd32a1cbd02997be72c9d5c52ac5bf5388 Mon Sep 17 00:00:00 2001 From: Shubhangi Singh Date: Mon, 30 Sep 2024 07:54:30 +0000 Subject: [PATCH 05/40] adding system env vars to test file --- .kokoro/integration.sh | 6 ------ .../acceptance/storage/universe_domain_test.rb | 7 +++++++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.kokoro/integration.sh b/.kokoro/integration.sh index c1b9fe423be2..af6fb32bf5be 100755 --- a/.kokoro/integration.sh +++ b/.kokoro/integration.sh @@ -29,12 +29,6 @@ for ruby_version in "${ruby_versions[@]}"; do # is in a read-only location. export GEM_HOME=$HOME/.gem export PATH=$GEM_HOME/bin:$PATH - - # For universe domain testing - export TEST_UNIVERSE_DOMAIN_CREDENTIAL=$(realpath ${KOKORO_GFILE_DIR}/secret_manager/client-library-test-universe-domain-credential) - export TEST_UNIVERSE_DOMAIN=$(gcloud secrets versions access latest --project cloud-devrel-kokoro-resources --secret=client-library-test-universe-domain) - export TEST_UNIVERSE_PROJECT_ID=$(gcloud secrets versions access latest --project cloud-devrel-kokoro-resources --secret=client-library-test-universe-project-id) - export TEST_UNIVERSE_LOCATION=$(gcloud secrets versions access latest --project cloud-devrel-kokoro-resources --secret=client-library-test-universe-storage-location) gem install --no-document toys diff --git a/google-cloud-storage/acceptance/storage/universe_domain_test.rb b/google-cloud-storage/acceptance/storage/universe_domain_test.rb index 9223d8228a98..3b32a37434e1 100644 --- a/google-cloud-storage/acceptance/storage/universe_domain_test.rb +++ b/google-cloud-storage/acceptance/storage/universe_domain_test.rb @@ -16,6 +16,13 @@ describe Google::Cloud::Storage do + system( + "export TEST_UNIVERSE_DOMAIN_CREDENTIAL=$(realpath ${KOKORO_GFILE_DIR}/secret_manager/client-library-test-universe-domain-credential) + export TEST_UNIVERSE_DOMAIN=$(gcloud secrets versions access latest --project cloud-devrel-kokoro-resources --secret=client-library-test-universe-domain) + export TEST_UNIVERSE_PROJECT_ID=$(gcloud secrets versions access latest --project cloud-devrel-kokoro-resources --secret=client-library-test-universe-project-id) + export TEST_UNIVERSE_LOCATION=$(gcloud secrets versions access latest --project cloud-devrel-kokoro-resources --secret=client-library-test-universe-storage-location)" + ) + # Universe Domain Test project Credentials $test_universe_domain = ENV["TEST_UNIVERSE_DOMAIN"] $test_universe_project_id = ENV["TEST_UNIVERSE_PROJECT_ID"] From 9eb76aedbe6bea4ca788b887e4884225cdd3c15c Mon Sep 17 00:00:00 2001 From: Shubhangi Singh Date: Mon, 30 Sep 2024 11:05:41 +0000 Subject: [PATCH 06/40] try initiating bucket --- .../acceptance/storage/universe_domain_test.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/google-cloud-storage/acceptance/storage/universe_domain_test.rb b/google-cloud-storage/acceptance/storage/universe_domain_test.rb index 3b32a37434e1..8f2018dec4cd 100644 --- a/google-cloud-storage/acceptance/storage/universe_domain_test.rb +++ b/google-cloud-storage/acceptance/storage/universe_domain_test.rb @@ -46,6 +46,10 @@ { logo: { path: "acceptance/data/CloudPlatform_128px_Retina.png" } } end + before :all do + bucket + end + after :all do # Clean up: Ensure the bucket and objects are deleted after tests bucket = storage.bucket bucket_name From b7494743f0139ad5038624a66e71149d6c15b6e7 Mon Sep 17 00:00:00 2001 From: Shubhangi Singh Date: Mon, 30 Sep 2024 11:37:43 +0000 Subject: [PATCH 07/40] try skipping location check --- .../acceptance/storage/universe_domain_test.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/google-cloud-storage/acceptance/storage/universe_domain_test.rb b/google-cloud-storage/acceptance/storage/universe_domain_test.rb index 8f2018dec4cd..ba847a1ace66 100644 --- a/google-cloud-storage/acceptance/storage/universe_domain_test.rb +++ b/google-cloud-storage/acceptance/storage/universe_domain_test.rb @@ -22,7 +22,7 @@ export TEST_UNIVERSE_PROJECT_ID=$(gcloud secrets versions access latest --project cloud-devrel-kokoro-resources --secret=client-library-test-universe-project-id) export TEST_UNIVERSE_LOCATION=$(gcloud secrets versions access latest --project cloud-devrel-kokoro-resources --secret=client-library-test-universe-storage-location)" ) - + # Universe Domain Test project Credentials $test_universe_domain = ENV["TEST_UNIVERSE_DOMAIN"] $test_universe_project_id = ENV["TEST_UNIVERSE_PROJECT_ID"] @@ -46,7 +46,8 @@ { logo: { path: "acceptance/data/CloudPlatform_128px_Retina.png" } } end - before :all do + before do + # always create the bucket bucket end @@ -62,7 +63,6 @@ it "creates a new bucket with universe_domain" do # Verify that the bucket is created _(bucket.name).must_equal bucket_name - _(bucket.location).must_equal bucket_location end it "uploads an object form a path in the bucket" do From 60e87d514f5255d9c57ddeaef5e2eb82600f16cf Mon Sep 17 00:00:00 2001 From: Shubhangi Singh Date: Mon, 30 Sep 2024 12:37:08 +0000 Subject: [PATCH 08/40] putting sytem vars in integration.sh --- .kokoro/integration.sh | 7 ++++++ .../storage/universe_domain_test.rb | 22 +++++-------------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/.kokoro/integration.sh b/.kokoro/integration.sh index af6fb32bf5be..36a8314f3127 100755 --- a/.kokoro/integration.sh +++ b/.kokoro/integration.sh @@ -30,6 +30,13 @@ for ruby_version in "${ruby_versions[@]}"; do export GEM_HOME=$HOME/.gem export PATH=$GEM_HOME/bin:$PATH + # Universe Domain Test project Credentials + export TEST_UNIVERSE_DOMAIN_CREDENTIAL=$(realpath ${KOKORO_GFILE_DIR}/secret_manager/client-library-test-universe-domain-credential) + export TEST_UNIVERSE_DOMAIN=$(gcloud secrets versions access latest --project cloud-devrel-kokoro-resources --secret=client-library-test-universe-domain) + export TEST_UNIVERSE_PROJECT_ID=$(gcloud secrets versions access latest --project cloud-devrel-kokoro-resources --secret=client-library-test-universe-project-id) + export TEST_UNIVERSE_LOCATION=$(gcloud secrets versions access latest --project cloud-devrel-kokoro-resources --secret=client-library-test-universe-storage-location) + + gem install --no-document toys toys ci -v --load-kokoro-context $EXTRA_CI_ARGS < /dev/null diff --git a/google-cloud-storage/acceptance/storage/universe_domain_test.rb b/google-cloud-storage/acceptance/storage/universe_domain_test.rb index ba847a1ace66..f6799eb9b5ca 100644 --- a/google-cloud-storage/acceptance/storage/universe_domain_test.rb +++ b/google-cloud-storage/acceptance/storage/universe_domain_test.rb @@ -16,28 +16,16 @@ describe Google::Cloud::Storage do - system( - "export TEST_UNIVERSE_DOMAIN_CREDENTIAL=$(realpath ${KOKORO_GFILE_DIR}/secret_manager/client-library-test-universe-domain-credential) - export TEST_UNIVERSE_DOMAIN=$(gcloud secrets versions access latest --project cloud-devrel-kokoro-resources --secret=client-library-test-universe-domain) - export TEST_UNIVERSE_PROJECT_ID=$(gcloud secrets versions access latest --project cloud-devrel-kokoro-resources --secret=client-library-test-universe-project-id) - export TEST_UNIVERSE_LOCATION=$(gcloud secrets versions access latest --project cloud-devrel-kokoro-resources --secret=client-library-test-universe-storage-location)" - ) - - # Universe Domain Test project Credentials - $test_universe_domain = ENV["TEST_UNIVERSE_DOMAIN"] - $test_universe_project_id = ENV["TEST_UNIVERSE_PROJECT_ID"] - $test_universe_location = ENV["TEST_UNIVERSE_LOCATION"] - $test_universe_domain_credential = ENV["TEST_UNIVERSE_DOMAIN_CREDENTIAL"] - let :storage do + # Universe Domain Test project Credentials Google::Cloud::Storage.new( - project_id: $test_universe_project_id, - credentials: $test_universe_domain_credential, - universe_domain: $test_universe_domain + project_id: ENV["TEST_UNIVERSE_PROJECT_ID"], + credentials: ENV["TEST_UNIVERSE_DOMAIN_CREDENTIAL"], + universe_domain: ENV["TEST_UNIVERSE_DOMAIN"] ) end let(:bucket_name) { $bucket_names.first } - let(:bucket_location) { $test_universe_location } + let(:bucket_location) { ENV["TEST_UNIVERSE_LOCATION"] } let :bucket do storage.bucket(bucket_name) || safe_gcs_execute { storage.create_bucket bucket_name, location: bucket_location } end From 567c9ce883a42c2fd5fe5d1def7af2c79fcbc8b3 Mon Sep 17 00:00:00 2001 From: Shubhangi Singh Date: Mon, 30 Sep 2024 13:06:37 +0000 Subject: [PATCH 09/40] undo --- .kokoro/integration.sh | 7 ------- .../acceptance/storage/universe_domain_test.rb | 7 +++++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.kokoro/integration.sh b/.kokoro/integration.sh index 36a8314f3127..af6fb32bf5be 100755 --- a/.kokoro/integration.sh +++ b/.kokoro/integration.sh @@ -30,13 +30,6 @@ for ruby_version in "${ruby_versions[@]}"; do export GEM_HOME=$HOME/.gem export PATH=$GEM_HOME/bin:$PATH - # Universe Domain Test project Credentials - export TEST_UNIVERSE_DOMAIN_CREDENTIAL=$(realpath ${KOKORO_GFILE_DIR}/secret_manager/client-library-test-universe-domain-credential) - export TEST_UNIVERSE_DOMAIN=$(gcloud secrets versions access latest --project cloud-devrel-kokoro-resources --secret=client-library-test-universe-domain) - export TEST_UNIVERSE_PROJECT_ID=$(gcloud secrets versions access latest --project cloud-devrel-kokoro-resources --secret=client-library-test-universe-project-id) - export TEST_UNIVERSE_LOCATION=$(gcloud secrets versions access latest --project cloud-devrel-kokoro-resources --secret=client-library-test-universe-storage-location) - - gem install --no-document toys toys ci -v --load-kokoro-context $EXTRA_CI_ARGS < /dev/null diff --git a/google-cloud-storage/acceptance/storage/universe_domain_test.rb b/google-cloud-storage/acceptance/storage/universe_domain_test.rb index f6799eb9b5ca..0edfdee444be 100644 --- a/google-cloud-storage/acceptance/storage/universe_domain_test.rb +++ b/google-cloud-storage/acceptance/storage/universe_domain_test.rb @@ -16,6 +16,13 @@ describe Google::Cloud::Storage do + system( + "export TEST_UNIVERSE_DOMAIN_CREDENTIAL=$(realpath ${KOKORO_GFILE_DIR}/secret_manager/client-library-test-universe-domain-credential) + export TEST_UNIVERSE_DOMAIN=$(gcloud secrets versions access latest --project cloud-devrel-kokoro-resources --secret=client-library-test-universe-domain) + export TEST_UNIVERSE_PROJECT_ID=$(gcloud secrets versions access latest --project cloud-devrel-kokoro-resources --secret=client-library-test-universe-project-id) + export TEST_UNIVERSE_LOCATION=$(gcloud secrets versions access latest --project cloud-devrel-kokoro-resources --secret=client-library-test-universe-storage-location)" + ) + let :storage do # Universe Domain Test project Credentials Google::Cloud::Storage.new( From 538a75bb889e151657bf86046101127fa95d0c80 Mon Sep 17 00:00:00 2001 From: Shubhangi Singh Date: Tue, 1 Oct 2024 07:11:16 +0000 Subject: [PATCH 10/40] trying env vars --- .kokoro/integration.sh | 7 +++++++ .../acceptance/storage/universe_domain_test.rb | 8 -------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.kokoro/integration.sh b/.kokoro/integration.sh index af6fb32bf5be..36a8314f3127 100755 --- a/.kokoro/integration.sh +++ b/.kokoro/integration.sh @@ -30,6 +30,13 @@ for ruby_version in "${ruby_versions[@]}"; do export GEM_HOME=$HOME/.gem export PATH=$GEM_HOME/bin:$PATH + # Universe Domain Test project Credentials + export TEST_UNIVERSE_DOMAIN_CREDENTIAL=$(realpath ${KOKORO_GFILE_DIR}/secret_manager/client-library-test-universe-domain-credential) + export TEST_UNIVERSE_DOMAIN=$(gcloud secrets versions access latest --project cloud-devrel-kokoro-resources --secret=client-library-test-universe-domain) + export TEST_UNIVERSE_PROJECT_ID=$(gcloud secrets versions access latest --project cloud-devrel-kokoro-resources --secret=client-library-test-universe-project-id) + export TEST_UNIVERSE_LOCATION=$(gcloud secrets versions access latest --project cloud-devrel-kokoro-resources --secret=client-library-test-universe-storage-location) + + gem install --no-document toys toys ci -v --load-kokoro-context $EXTRA_CI_ARGS < /dev/null diff --git a/google-cloud-storage/acceptance/storage/universe_domain_test.rb b/google-cloud-storage/acceptance/storage/universe_domain_test.rb index 0edfdee444be..6c0439e09194 100644 --- a/google-cloud-storage/acceptance/storage/universe_domain_test.rb +++ b/google-cloud-storage/acceptance/storage/universe_domain_test.rb @@ -15,14 +15,6 @@ require "storage_helper" describe Google::Cloud::Storage do - - system( - "export TEST_UNIVERSE_DOMAIN_CREDENTIAL=$(realpath ${KOKORO_GFILE_DIR}/secret_manager/client-library-test-universe-domain-credential) - export TEST_UNIVERSE_DOMAIN=$(gcloud secrets versions access latest --project cloud-devrel-kokoro-resources --secret=client-library-test-universe-domain) - export TEST_UNIVERSE_PROJECT_ID=$(gcloud secrets versions access latest --project cloud-devrel-kokoro-resources --secret=client-library-test-universe-project-id) - export TEST_UNIVERSE_LOCATION=$(gcloud secrets versions access latest --project cloud-devrel-kokoro-resources --secret=client-library-test-universe-storage-location)" - ) - let :storage do # Universe Domain Test project Credentials Google::Cloud::Storage.new( From 1b5b7b94c82b8330c4ddd472b583839dd5ae84a9 Mon Sep 17 00:00:00 2001 From: Shubhangi Singh Date: Tue, 1 Oct 2024 07:47:19 +0000 Subject: [PATCH 11/40] trying read secrets --- .kokoro/integration.sh | 7 ------- .kokoro/presubmit/acceptance.cfg | 2 +- .../acceptance/storage/universe_domain_test.rb | 6 ++++++ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.kokoro/integration.sh b/.kokoro/integration.sh index 36a8314f3127..af6fb32bf5be 100755 --- a/.kokoro/integration.sh +++ b/.kokoro/integration.sh @@ -30,13 +30,6 @@ for ruby_version in "${ruby_versions[@]}"; do export GEM_HOME=$HOME/.gem export PATH=$GEM_HOME/bin:$PATH - # Universe Domain Test project Credentials - export TEST_UNIVERSE_DOMAIN_CREDENTIAL=$(realpath ${KOKORO_GFILE_DIR}/secret_manager/client-library-test-universe-domain-credential) - export TEST_UNIVERSE_DOMAIN=$(gcloud secrets versions access latest --project cloud-devrel-kokoro-resources --secret=client-library-test-universe-domain) - export TEST_UNIVERSE_PROJECT_ID=$(gcloud secrets versions access latest --project cloud-devrel-kokoro-resources --secret=client-library-test-universe-project-id) - export TEST_UNIVERSE_LOCATION=$(gcloud secrets versions access latest --project cloud-devrel-kokoro-resources --secret=client-library-test-universe-storage-location) - - gem install --no-document toys toys ci -v --load-kokoro-context $EXTRA_CI_ARGS < /dev/null diff --git a/.kokoro/presubmit/acceptance.cfg b/.kokoro/presubmit/acceptance.cfg index e2972dfb43ca..eeb69d13cae2 100644 --- a/.kokoro/presubmit/acceptance.cfg +++ b/.kokoro/presubmit/acceptance.cfg @@ -29,7 +29,7 @@ env_vars: { env_vars: { key: "SECRET_MANAGER_KEYS" - value: "client-library-test-universe-domain-credential" + value: "client-library-test-universe-domain,client-library-test-universe-domain-credential,client-library-test-universe-project-id,client-library-test-universe-storage-location" } env_vars: { diff --git a/google-cloud-storage/acceptance/storage/universe_domain_test.rb b/google-cloud-storage/acceptance/storage/universe_domain_test.rb index 6c0439e09194..42278c717431 100644 --- a/google-cloud-storage/acceptance/storage/universe_domain_test.rb +++ b/google-cloud-storage/acceptance/storage/universe_domain_test.rb @@ -15,6 +15,12 @@ require "storage_helper" describe Google::Cloud::Storage do + # Universe Domain Test project Credentials + ENV["TEST_UNIVERSE_DOMAIN_CREDENTIAL"] = File.realpath(File.join(ENV[KOKORO_GFILE_DIR], 'secret_manager', 'client-library-test-universe-domain-credential')) + ENV["TEST_UNIVERSE_DOMAIN"] = File.read(File.realpath(File.join(ENV[KOKORO_GFILE_DIR], 'secret_manager', 'client-library-test-universe-domain'))).strip + ENV["TEST_UNIVERSE_PROJECT_ID"] = File.read(File.realpath(File.join(ENV[KOKORO_GFILE_DIR], 'secret_manager', 'client-library-test-universe-project-id'))).strip + ENV["TEST_UNIVERSE_LOCATION"] = File.read(File.realpath(File.join(ENV[KOKORO_GFILE_DIR], 'secret_manager', 'client-library-test-universe-storage-location'))).strip + let :storage do # Universe Domain Test project Credentials Google::Cloud::Storage.new( From 8a73629c81a8382429916c26cb18cb20adaeb7af Mon Sep 17 00:00:00 2001 From: Shubhangi Singh Date: Tue, 1 Oct 2024 07:52:37 +0000 Subject: [PATCH 12/40] fix syntax --- .../acceptance/storage/universe_domain_test.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/google-cloud-storage/acceptance/storage/universe_domain_test.rb b/google-cloud-storage/acceptance/storage/universe_domain_test.rb index 42278c717431..89384433eb2b 100644 --- a/google-cloud-storage/acceptance/storage/universe_domain_test.rb +++ b/google-cloud-storage/acceptance/storage/universe_domain_test.rb @@ -16,10 +16,10 @@ describe Google::Cloud::Storage do # Universe Domain Test project Credentials - ENV["TEST_UNIVERSE_DOMAIN_CREDENTIAL"] = File.realpath(File.join(ENV[KOKORO_GFILE_DIR], 'secret_manager', 'client-library-test-universe-domain-credential')) - ENV["TEST_UNIVERSE_DOMAIN"] = File.read(File.realpath(File.join(ENV[KOKORO_GFILE_DIR], 'secret_manager', 'client-library-test-universe-domain'))).strip - ENV["TEST_UNIVERSE_PROJECT_ID"] = File.read(File.realpath(File.join(ENV[KOKORO_GFILE_DIR], 'secret_manager', 'client-library-test-universe-project-id'))).strip - ENV["TEST_UNIVERSE_LOCATION"] = File.read(File.realpath(File.join(ENV[KOKORO_GFILE_DIR], 'secret_manager', 'client-library-test-universe-storage-location'))).strip + ENV["TEST_UNIVERSE_DOMAIN_CREDENTIAL"] = File.realpath(File.join(ENV["KOKORO_GFILE_DIR"], 'secret_manager', 'client-library-test-universe-domain-credential')) + ENV["TEST_UNIVERSE_DOMAIN"] = File.read(File.realpath(File.join(ENV["KOKORO_GFILE_DIR"], 'secret_manager', 'client-library-test-universe-domain'))).strip + ENV["TEST_UNIVERSE_PROJECT_ID"] = File.read(File.realpath(File.join(ENV["KOKORO_GFILE_DIR"], 'secret_manager', 'client-library-test-universe-project-id'))).strip + ENV["TEST_UNIVERSE_LOCATION"] = File.read(File.realpath(File.join(ENV["KOKORO_GFILE_DIR"], 'secret_manager', 'client-library-test-universe-storage-location'))).strip let :storage do # Universe Domain Test project Credentials From 94a0e391736645de6b202d2c4266b277ea549c3f Mon Sep 17 00:00:00 2001 From: Shubhangi Singh Date: Tue, 1 Oct 2024 08:07:12 +0000 Subject: [PATCH 13/40] trying env vars --- .kokoro/integration.sh | 5 +++++ .../acceptance/storage/universe_domain_test.rb | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.kokoro/integration.sh b/.kokoro/integration.sh index af6fb32bf5be..400944e4a148 100755 --- a/.kokoro/integration.sh +++ b/.kokoro/integration.sh @@ -30,6 +30,11 @@ for ruby_version in "${ruby_versions[@]}"; do export GEM_HOME=$HOME/.gem export PATH=$GEM_HOME/bin:$PATH + export TEST_UNIVERSE_DOMAIN=$(cat ${KOKORO_GFILE_DIR}/secret_manager/client-library-test-universe-domain) + export TEST_UNIVERSE_PROJECT_ID=$(cat ${KOKORO_GFILE_DIR}/secret_manager/client-library-test-universe-project-id) + export TEST_UNIVERSE_LOCATION=$(cat ${KOKORO_GFILE_DIR}/secret_manager/client-library-test-universe-storage-location) + export TEST_UNIVERSE_DOMAIN_CREDENTIAL=$(realpath ${KOKORO_GFILE_DIR}/secret_manager/client-library-test-universe-domain-credential) + gem install --no-document toys toys ci -v --load-kokoro-context $EXTRA_CI_ARGS < /dev/null diff --git a/google-cloud-storage/acceptance/storage/universe_domain_test.rb b/google-cloud-storage/acceptance/storage/universe_domain_test.rb index 89384433eb2b..f6799eb9b5ca 100644 --- a/google-cloud-storage/acceptance/storage/universe_domain_test.rb +++ b/google-cloud-storage/acceptance/storage/universe_domain_test.rb @@ -15,11 +15,6 @@ require "storage_helper" describe Google::Cloud::Storage do - # Universe Domain Test project Credentials - ENV["TEST_UNIVERSE_DOMAIN_CREDENTIAL"] = File.realpath(File.join(ENV["KOKORO_GFILE_DIR"], 'secret_manager', 'client-library-test-universe-domain-credential')) - ENV["TEST_UNIVERSE_DOMAIN"] = File.read(File.realpath(File.join(ENV["KOKORO_GFILE_DIR"], 'secret_manager', 'client-library-test-universe-domain'))).strip - ENV["TEST_UNIVERSE_PROJECT_ID"] = File.read(File.realpath(File.join(ENV["KOKORO_GFILE_DIR"], 'secret_manager', 'client-library-test-universe-project-id'))).strip - ENV["TEST_UNIVERSE_LOCATION"] = File.read(File.realpath(File.join(ENV["KOKORO_GFILE_DIR"], 'secret_manager', 'client-library-test-universe-storage-location'))).strip let :storage do # Universe Domain Test project Credentials From 2758666f9282d4625b3bfaf958f54964b553d10a Mon Sep 17 00:00:00 2001 From: Shubhangi Singh Date: Tue, 1 Oct 2024 08:33:46 +0000 Subject: [PATCH 14/40] try env vars --- .kokoro/integration.sh | 5 ---- .kokoro/presubmit/acceptance.cfg | 2 +- google-cloud-storage/Gemfile | 3 ++- .../storage/universe_domain_test.rb | 25 +++++++++++++++++++ 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/.kokoro/integration.sh b/.kokoro/integration.sh index 400944e4a148..af6fb32bf5be 100755 --- a/.kokoro/integration.sh +++ b/.kokoro/integration.sh @@ -30,11 +30,6 @@ for ruby_version in "${ruby_versions[@]}"; do export GEM_HOME=$HOME/.gem export PATH=$GEM_HOME/bin:$PATH - export TEST_UNIVERSE_DOMAIN=$(cat ${KOKORO_GFILE_DIR}/secret_manager/client-library-test-universe-domain) - export TEST_UNIVERSE_PROJECT_ID=$(cat ${KOKORO_GFILE_DIR}/secret_manager/client-library-test-universe-project-id) - export TEST_UNIVERSE_LOCATION=$(cat ${KOKORO_GFILE_DIR}/secret_manager/client-library-test-universe-storage-location) - export TEST_UNIVERSE_DOMAIN_CREDENTIAL=$(realpath ${KOKORO_GFILE_DIR}/secret_manager/client-library-test-universe-domain-credential) - gem install --no-document toys toys ci -v --load-kokoro-context $EXTRA_CI_ARGS < /dev/null diff --git a/.kokoro/presubmit/acceptance.cfg b/.kokoro/presubmit/acceptance.cfg index eeb69d13cae2..e2972dfb43ca 100644 --- a/.kokoro/presubmit/acceptance.cfg +++ b/.kokoro/presubmit/acceptance.cfg @@ -29,7 +29,7 @@ env_vars: { env_vars: { key: "SECRET_MANAGER_KEYS" - value: "client-library-test-universe-domain,client-library-test-universe-domain-credential,client-library-test-universe-project-id,client-library-test-universe-storage-location" + value: "client-library-test-universe-domain-credential" } env_vars: { diff --git a/google-cloud-storage/Gemfile b/google-cloud-storage/Gemfile index aa5496faa85e..517c261b9ee4 100644 --- a/google-cloud-storage/Gemfile +++ b/google-cloud-storage/Gemfile @@ -6,8 +6,9 @@ gem "google-cloud-core", path: "../google-cloud-core" gem "google-cloud-errors", path: "../google-cloud-errors" gem "google-cloud-pubsub", path: "../google-cloud-pubsub" gem "google-cloud-pubsub-v1", path: "../google-cloud-pubsub-v1" +gem "google-cloud-secret_manager",path: "../google-cloud-secret_manager" gem "minitest-reporters", "~> 1.5.0", require: false gem "rake" -gem "minitest" +gem "minitest" \ No newline at end of file diff --git a/google-cloud-storage/acceptance/storage/universe_domain_test.rb b/google-cloud-storage/acceptance/storage/universe_domain_test.rb index f6799eb9b5ca..2f3d2a204fcf 100644 --- a/google-cloud-storage/acceptance/storage/universe_domain_test.rb +++ b/google-cloud-storage/acceptance/storage/universe_domain_test.rb @@ -13,8 +13,33 @@ # limitations under the License. require "storage_helper" +require "google/cloud/secret_manager" describe Google::Cloud::Storage do + # Universe Domain Test project Credentials + secret_project = 'cloud-devrel-kokoro-resources' + secret_domain_id = 'client-library-test-universe-domain' + secret_project_id = 'client-library-test-universe-project-id' + secret_location_id = 'client-library-test-universe-storage-location' + secret_version = 'latest' + + client = Google::Cloud::SecretManager.secret_manager_service + ENV["TEST_UNIVERSE_DOMAIN"] = client.secret_version_path( + project: secret_project, + secret: secret_domain_id, + secret_version: secret_version + ) + ENV["TEST_UNIVERSE_PROJECT_ID"] = client.secret_version_path( + project: secret_project, + secret: secret_project_id, + secret_version: secret_version + ) + ENV["TEST_UNIVERSE_LOCATION"] = client.secret_version_path( + project: secret_project, + secret: secret_location_id, + secret_version: secret_version + ) + ENV["TEST_UNIVERSE_DOMAIN_CREDENTIAL"] = File.realpath(File.join(ENV['KOKORO_GFILE_DIR'], 'secret_manager', 'client-library-test-universe-domain-credential')) let :storage do # Universe Domain Test project Credentials From 7b5800d3c070251ca8002b82f6a9712a93b5ca14 Mon Sep 17 00:00:00 2001 From: Shubhangi Singh Date: Tue, 1 Oct 2024 08:56:18 +0000 Subject: [PATCH 15/40] try removing things from integration.sh --- .kokoro/presubmit/acceptance.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.kokoro/presubmit/acceptance.cfg b/.kokoro/presubmit/acceptance.cfg index e2972dfb43ca..93a92eaa0842 100644 --- a/.kokoro/presubmit/acceptance.cfg +++ b/.kokoro/presubmit/acceptance.cfg @@ -29,7 +29,7 @@ env_vars: { env_vars: { key: "SECRET_MANAGER_KEYS" - value: "client-library-test-universe-domain-credential" + value: "" } env_vars: { From 7bcf1fb5a0ef4be7ed748162dbac22356d328a54 Mon Sep 17 00:00:00 2001 From: Shubhangi Singh Date: Tue, 1 Oct 2024 09:02:23 +0000 Subject: [PATCH 16/40] undo --- .kokoro/presubmit/acceptance.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.kokoro/presubmit/acceptance.cfg b/.kokoro/presubmit/acceptance.cfg index 93a92eaa0842..e2972dfb43ca 100644 --- a/.kokoro/presubmit/acceptance.cfg +++ b/.kokoro/presubmit/acceptance.cfg @@ -29,7 +29,7 @@ env_vars: { env_vars: { key: "SECRET_MANAGER_KEYS" - value: "" + value: "client-library-test-universe-domain-credential" } env_vars: { From 159b7afa0e3888af0ab734d257d6cb1e5f741d63 Mon Sep 17 00:00:00 2001 From: Shubhangi Singh Date: Tue, 1 Oct 2024 09:11:11 +0000 Subject: [PATCH 17/40] rubocop thing --- .../acceptance/storage/universe_domain_test.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/google-cloud-storage/acceptance/storage/universe_domain_test.rb b/google-cloud-storage/acceptance/storage/universe_domain_test.rb index 2f3d2a204fcf..aa33ed8084ab 100644 --- a/google-cloud-storage/acceptance/storage/universe_domain_test.rb +++ b/google-cloud-storage/acceptance/storage/universe_domain_test.rb @@ -17,11 +17,11 @@ describe Google::Cloud::Storage do # Universe Domain Test project Credentials - secret_project = 'cloud-devrel-kokoro-resources' - secret_domain_id = 'client-library-test-universe-domain' - secret_project_id = 'client-library-test-universe-project-id' - secret_location_id = 'client-library-test-universe-storage-location' - secret_version = 'latest' + secret_project = "cloud-devrel-kokoro-resources" + secret_domain_id = "client-library-test-universe-domain" + secret_project_id = "client-library-test-universe-project-id" + secret_location_id = "client-library-test-universe-storage-location'" + secret_version = "latest" client = Google::Cloud::SecretManager.secret_manager_service ENV["TEST_UNIVERSE_DOMAIN"] = client.secret_version_path( @@ -39,7 +39,7 @@ secret: secret_location_id, secret_version: secret_version ) - ENV["TEST_UNIVERSE_DOMAIN_CREDENTIAL"] = File.realpath(File.join(ENV['KOKORO_GFILE_DIR'], 'secret_manager', 'client-library-test-universe-domain-credential')) + ENV["TEST_UNIVERSE_DOMAIN_CREDENTIAL"] = File.realpath(File.join(ENV["KOKORO_GFILE_DIR"], "secret_manager", "client-library-test-universe-domain-credential")) let :storage do # Universe Domain Test project Credentials From 7f281f0ce7a9b282a34be5c8637de4d2196dd904 Mon Sep 17 00:00:00 2001 From: Shubhangi Singh Date: Tue, 1 Oct 2024 11:09:49 +0000 Subject: [PATCH 18/40] try --- .../acceptance/storage/universe_domain_test.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/google-cloud-storage/acceptance/storage/universe_domain_test.rb b/google-cloud-storage/acceptance/storage/universe_domain_test.rb index aa33ed8084ab..7b9d4b536410 100644 --- a/google-cloud-storage/acceptance/storage/universe_domain_test.rb +++ b/google-cloud-storage/acceptance/storage/universe_domain_test.rb @@ -20,7 +20,8 @@ secret_project = "cloud-devrel-kokoro-resources" secret_domain_id = "client-library-test-universe-domain" secret_project_id = "client-library-test-universe-project-id" - secret_location_id = "client-library-test-universe-storage-location'" + secret_location_id = "client-library-test-universe-storage-location" + secret_domain_cred_id = "client-library-test-universe-domain-credential" secret_version = "latest" client = Google::Cloud::SecretManager.secret_manager_service @@ -39,7 +40,12 @@ secret: secret_location_id, secret_version: secret_version ) - ENV["TEST_UNIVERSE_DOMAIN_CREDENTIAL"] = File.realpath(File.join(ENV["KOKORO_GFILE_DIR"], "secret_manager", "client-library-test-universe-domain-credential")) + + ENV["TEST_UNIVERSE_DOMAIN_CREDENTIAL"] = client.secret_version_path( + project: secret_project, + secret: secret_domain_cred_id, + secret_version: secret_version + ) let :storage do # Universe Domain Test project Credentials From b416e24cbf8d7eecd28a050e12884ba18cbde548 Mon Sep 17 00:00:00 2001 From: Shubhangi Singh Date: Tue, 1 Oct 2024 11:39:20 +0000 Subject: [PATCH 19/40] moving back to setting system env vars from ruby file --- google-cloud-storage/Gemfile | 2 - .../storage/universe_domain_test.rb | 38 ++++--------------- 2 files changed, 7 insertions(+), 33 deletions(-) diff --git a/google-cloud-storage/Gemfile b/google-cloud-storage/Gemfile index 517c261b9ee4..3693b6b93bab 100644 --- a/google-cloud-storage/Gemfile +++ b/google-cloud-storage/Gemfile @@ -6,8 +6,6 @@ gem "google-cloud-core", path: "../google-cloud-core" gem "google-cloud-errors", path: "../google-cloud-errors" gem "google-cloud-pubsub", path: "../google-cloud-pubsub" gem "google-cloud-pubsub-v1", path: "../google-cloud-pubsub-v1" -gem "google-cloud-secret_manager",path: "../google-cloud-secret_manager" - gem "minitest-reporters", "~> 1.5.0", require: false gem "rake" diff --git a/google-cloud-storage/acceptance/storage/universe_domain_test.rb b/google-cloud-storage/acceptance/storage/universe_domain_test.rb index 7b9d4b536410..b346d69fa650 100644 --- a/google-cloud-storage/acceptance/storage/universe_domain_test.rb +++ b/google-cloud-storage/acceptance/storage/universe_domain_test.rb @@ -13,42 +13,18 @@ # limitations under the License. require "storage_helper" -require "google/cloud/secret_manager" describe Google::Cloud::Storage do - # Universe Domain Test project Credentials - secret_project = "cloud-devrel-kokoro-resources" - secret_domain_id = "client-library-test-universe-domain" - secret_project_id = "client-library-test-universe-project-id" - secret_location_id = "client-library-test-universe-storage-location" - secret_domain_cred_id = "client-library-test-universe-domain-credential" - secret_version = "latest" - - client = Google::Cloud::SecretManager.secret_manager_service - ENV["TEST_UNIVERSE_DOMAIN"] = client.secret_version_path( - project: secret_project, - secret: secret_domain_id, - secret_version: secret_version - ) - ENV["TEST_UNIVERSE_PROJECT_ID"] = client.secret_version_path( - project: secret_project, - secret: secret_project_id, - secret_version: secret_version - ) - ENV["TEST_UNIVERSE_LOCATION"] = client.secret_version_path( - project: secret_project, - secret: secret_location_id, - secret_version: secret_version - ) - - ENV["TEST_UNIVERSE_DOMAIN_CREDENTIAL"] = client.secret_version_path( - project: secret_project, - secret: secret_domain_cred_id, - secret_version: secret_version + # Setting Universe Domain Test project Credentials in env vars + system( + "export TEST_UNIVERSE_DOMAIN_CREDENTIAL=$(realpath ${KOKORO_GFILE_DIR}/secret_manager/client-library-test-universe-domain-credential) + export TEST_UNIVERSE_DOMAIN=$(gcloud secrets versions access latest --project cloud-devrel-kokoro-resources --secret=client-library-test-universe-domain) + export TEST_UNIVERSE_PROJECT_ID=$(gcloud secrets versions access latest --project cloud-devrel-kokoro-resources --secret=client-library-test-universe-project-id) + export TEST_UNIVERSE_LOCATION=$(gcloud secrets versions access latest --project cloud-devrel-kokoro-resources --secret=client-library-test-universe-storage-location)" ) let :storage do - # Universe Domain Test project Credentials + # Fetching Universe Domain Test project Credentials Google::Cloud::Storage.new( project_id: ENV["TEST_UNIVERSE_PROJECT_ID"], credentials: ENV["TEST_UNIVERSE_DOMAIN_CREDENTIAL"], From fe89c5d00383d28d4559de7e1f3cb1bcf7d33838 Mon Sep 17 00:00:00 2001 From: Shubhangi Singh Date: Tue, 1 Oct 2024 12:30:48 +0000 Subject: [PATCH 20/40] resolving rubocop issue --- google-cloud-storage/Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/google-cloud-storage/Gemfile b/google-cloud-storage/Gemfile index 3693b6b93bab..a48936104d84 100644 --- a/google-cloud-storage/Gemfile +++ b/google-cloud-storage/Gemfile @@ -9,4 +9,4 @@ gem "google-cloud-pubsub-v1", path: "../google-cloud-pubsub-v1" gem "minitest-reporters", "~> 1.5.0", require: false gem "rake" -gem "minitest" \ No newline at end of file +gem "minitest" From cd869042de5b20fb173d8f92c684ad79b57c0d2e Mon Sep 17 00:00:00 2001 From: bajajnehaa Date: Tue, 1 Oct 2024 18:11:24 +0000 Subject: [PATCH 21/40] Fetch all secrets using populate-screts --- .kokoro/presubmit/acceptance.cfg | 2 +- .../storage/universe_domain_test.rb | 21 +++++++++---------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/.kokoro/presubmit/acceptance.cfg b/.kokoro/presubmit/acceptance.cfg index e2972dfb43ca..232468f796ef 100644 --- a/.kokoro/presubmit/acceptance.cfg +++ b/.kokoro/presubmit/acceptance.cfg @@ -29,7 +29,7 @@ env_vars: { env_vars: { key: "SECRET_MANAGER_KEYS" - value: "client-library-test-universe-domain-credential" + value: "client-library-test-universe-domain, client-library-test-universe-project-id, client-library-test-universe-storage-location, client-library-test-universe-domain-credential" } env_vars: { diff --git a/google-cloud-storage/acceptance/storage/universe_domain_test.rb b/google-cloud-storage/acceptance/storage/universe_domain_test.rb index b346d69fa650..8c897ea20029 100644 --- a/google-cloud-storage/acceptance/storage/universe_domain_test.rb +++ b/google-cloud-storage/acceptance/storage/universe_domain_test.rb @@ -15,24 +15,23 @@ require "storage_helper" describe Google::Cloud::Storage do - # Setting Universe Domain Test project Credentials in env vars - system( - "export TEST_UNIVERSE_DOMAIN_CREDENTIAL=$(realpath ${KOKORO_GFILE_DIR}/secret_manager/client-library-test-universe-domain-credential) - export TEST_UNIVERSE_DOMAIN=$(gcloud secrets versions access latest --project cloud-devrel-kokoro-resources --secret=client-library-test-universe-domain) - export TEST_UNIVERSE_PROJECT_ID=$(gcloud secrets versions access latest --project cloud-devrel-kokoro-resources --secret=client-library-test-universe-project-id) - export TEST_UNIVERSE_LOCATION=$(gcloud secrets versions access latest --project cloud-devrel-kokoro-resources --secret=client-library-test-universe-storage-location)" - ) + # Fetch secret values from the secret_manager path + TEST_UNIVERSE_PROJECT_ID = File.read(File.realpath(File.join(ENV["KOKORO_GFILE_DIR"], "secret_manager", "client-library-test-universe-project-id"))) + TEST_UNIVERSE_LOCATION = File.read(File.realpath(File.join(ENV["KOKORO_GFILE_DIR"], "secret_manager", "client-library-test-universe-storage-location"))) + TEST_UNIVERSE_DOMAIN = File.read(File.realpath(File.join( ENV["KOKORO_GFILE_DIR"], "secret_manager", "client-library-test-universe-domain"))) + TEST_UNIVERSE_DOMAIN_CREDENTIAL = File.realpath(File.join( ENV["KOKORO_GFILE_DIR"], "secret_manager", "client-library-test-universe-domain-credential")) + let :storage do # Fetching Universe Domain Test project Credentials Google::Cloud::Storage.new( - project_id: ENV["TEST_UNIVERSE_PROJECT_ID"], - credentials: ENV["TEST_UNIVERSE_DOMAIN_CREDENTIAL"], - universe_domain: ENV["TEST_UNIVERSE_DOMAIN"] + project_id: TEST_UNIVERSE_PROJECT_ID, + credentials: TEST_UNIVERSE_DOMAIN_CREDENTIAL, + universe_domain: TEST_UNIVERSE_DOMAIN ) end let(:bucket_name) { $bucket_names.first } - let(:bucket_location) { ENV["TEST_UNIVERSE_LOCATION"] } + let(:bucket_location) { TEST_UNIVERSE_LOCATION } let :bucket do storage.bucket(bucket_name) || safe_gcs_execute { storage.create_bucket bucket_name, location: bucket_location } end From 1480fb36755d7dbd1eca97de39dc5eeeba31c54f Mon Sep 17 00:00:00 2001 From: bajajnehaa Date: Tue, 1 Oct 2024 18:22:09 +0000 Subject: [PATCH 22/40] debug mode ON --- google-cloud-storage/acceptance/storage/universe_domain_test.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/google-cloud-storage/acceptance/storage/universe_domain_test.rb b/google-cloud-storage/acceptance/storage/universe_domain_test.rb index 8c897ea20029..a142de52ad8a 100644 --- a/google-cloud-storage/acceptance/storage/universe_domain_test.rb +++ b/google-cloud-storage/acceptance/storage/universe_domain_test.rb @@ -14,6 +14,8 @@ require "storage_helper" +Google::Apis.logger.level = Logger::DEBUG + describe Google::Cloud::Storage do # Fetch secret values from the secret_manager path TEST_UNIVERSE_PROJECT_ID = File.read(File.realpath(File.join(ENV["KOKORO_GFILE_DIR"], "secret_manager", "client-library-test-universe-project-id"))) From 5c188b3194c73a48817e8895c76ef02dabc88319 Mon Sep 17 00:00:00 2001 From: bajajnehaa Date: Tue, 1 Oct 2024 19:02:54 +0000 Subject: [PATCH 23/40] Rewrite the universe domain test --- .../storage/universe_domain_test.rb | 77 +++++-------------- 1 file changed, 19 insertions(+), 58 deletions(-) diff --git a/google-cloud-storage/acceptance/storage/universe_domain_test.rb b/google-cloud-storage/acceptance/storage/universe_domain_test.rb index a142de52ad8a..2841847c249e 100644 --- a/google-cloud-storage/acceptance/storage/universe_domain_test.rb +++ b/google-cloud-storage/acceptance/storage/universe_domain_test.rb @@ -14,8 +14,6 @@ require "storage_helper" -Google::Apis.logger.level = Logger::DEBUG - describe Google::Cloud::Storage do # Fetch secret values from the secret_manager path TEST_UNIVERSE_PROJECT_ID = File.read(File.realpath(File.join(ENV["KOKORO_GFILE_DIR"], "secret_manager", "client-library-test-universe-project-id"))) @@ -24,70 +22,33 @@ TEST_UNIVERSE_DOMAIN_CREDENTIAL = File.realpath(File.join( ENV["KOKORO_GFILE_DIR"], "secret_manager", "client-library-test-universe-domain-credential")) - let :storage do - # Fetching Universe Domain Test project Credentials + let :universe_domain_storage do Google::Cloud::Storage.new( project_id: TEST_UNIVERSE_PROJECT_ID, - credentials: TEST_UNIVERSE_DOMAIN_CREDENTIAL, + keyfile: TEST_UNIVERSE_DOMAIN_CREDENTIAL, universe_domain: TEST_UNIVERSE_DOMAIN ) end - let(:bucket_name) { $bucket_names.first } - let(:bucket_location) { TEST_UNIVERSE_LOCATION } - let :bucket do - storage.bucket(bucket_name) || safe_gcs_execute { storage.create_bucket bucket_name, location: bucket_location } - end - - let :files do - { logo: { path: "acceptance/data/CloudPlatform_128px_Retina.png" } } - end - - before do - # always create the bucket - bucket - end - - after :all do - # Clean up: Ensure the bucket and objects are deleted after tests - bucket = storage.bucket bucket_name - if bucket - bucket.files.each(&:delete) # Delete all objects in the bucket - bucket.delete - end - end - it "creates a new bucket with universe_domain" do - # Verify that the bucket is created + it "creates a new bucket and uploads an object with universe_domain" do + # Create a bucket + bucket_name = $bucket_names.first + bucket = safe_gcs_execute { universe_domain_storage.create_bucket bucket_name, location: TEST_UNIVERSE_LOCATION } _(bucket.name).must_equal bucket_name - end - - it "uploads an object form a path in the bucket" do - # Upload an object - object_name = "CloudLogo.png" - original = File.new files[:logo][:path] - uploaded_file = bucket.create_file original, "CloudLogo.png" - # Verify object was uploaded - _(uploaded_file.name).must_equal object_name - - # Retrive object - retrieved_file = bucket.file object_name - # Verify object - _(retrieved_file.name).must_equal object_name - end - - it "uploads and verifies an object in the bucket" do # Upload an object - object_name = "test-object.txt" - object_content = "Hello this a test file" - uploaded_file = bucket.create_file StringIO.new(object_content), object_name - - # Verify object was uploaded - _(uploaded_file.name).must_equal object_name - - # Verify object content - retrieved_file = bucket.file object_name - downloaded_content = retrieved_file.download.read - _(downloaded_content).must_equal object_content + file_name = "ud-test-file" + payload = StringIO.new "Hello world!" + file = bucket.create_file payload, file_name + _(file.name).must_equal file_name + + # Delete the object + file.delete + file = bucket.file file_name + _(file).must_be_nil + + # Delete the bucket + bucket.delete + _(bucket).must_be_nil end end From 6e16b14f764344d35e2656731a65404a84bef4cd Mon Sep 17 00:00:00 2001 From: bajajnehaa Date: Tue, 1 Oct 2024 19:16:19 +0000 Subject: [PATCH 24/40] futher debugging --- .../acceptance/storage/universe_domain_test.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/google-cloud-storage/acceptance/storage/universe_domain_test.rb b/google-cloud-storage/acceptance/storage/universe_domain_test.rb index 2841847c249e..7fac24af67dc 100644 --- a/google-cloud-storage/acceptance/storage/universe_domain_test.rb +++ b/google-cloud-storage/acceptance/storage/universe_domain_test.rb @@ -34,6 +34,8 @@ # Create a bucket bucket_name = $bucket_names.first bucket = safe_gcs_execute { universe_domain_storage.create_bucket bucket_name, location: TEST_UNIVERSE_LOCATION } + puts "bucket: #{bucket.inspect}" + _(bucket).wont_be_nil _(bucket.name).must_equal bucket_name # Upload an object @@ -42,6 +44,10 @@ file = bucket.create_file payload, file_name _(file.name).must_equal file_name + # Read the file uploaded + uploaded_file = bucket.file file_name + _(uploaded_file.name).must_equal file_name + # Delete the object file.delete file = bucket.file file_name From 784c5e5c0b533dafbc04bb415f06585fbacd7de5 Mon Sep 17 00:00:00 2001 From: bajajnehaa Date: Tue, 1 Oct 2024 19:29:49 +0000 Subject: [PATCH 25/40] debug failure --- .../storage/universe_domain_test.rb | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/google-cloud-storage/acceptance/storage/universe_domain_test.rb b/google-cloud-storage/acceptance/storage/universe_domain_test.rb index 7fac24af67dc..0848e8fd8381 100644 --- a/google-cloud-storage/acceptance/storage/universe_domain_test.rb +++ b/google-cloud-storage/acceptance/storage/universe_domain_test.rb @@ -14,6 +14,8 @@ require "storage_helper" +Google::Apis.logger.level = Logger::DEBUG + describe Google::Cloud::Storage do # Fetch secret values from the secret_manager path TEST_UNIVERSE_PROJECT_ID = File.read(File.realpath(File.join(ENV["KOKORO_GFILE_DIR"], "secret_manager", "client-library-test-universe-project-id"))) @@ -32,29 +34,29 @@ it "creates a new bucket and uploads an object with universe_domain" do # Create a bucket - bucket_name = $bucket_names.first - bucket = safe_gcs_execute { universe_domain_storage.create_bucket bucket_name, location: TEST_UNIVERSE_LOCATION } - puts "bucket: #{bucket.inspect}" - _(bucket).wont_be_nil - _(bucket.name).must_equal bucket_name + ud_bucket_name = "ud-test-bucket" + ud_bucket = safe_gcs_execute { universe_domain_storage.create_bucket ud_bucket_name, location: TEST_UNIVERSE_LOCATION } + puts "bucket: #{ud_bucket.inspect}" + _(ud_bucket).wont_be_nil + _(ud_bucket.name).must_equal ud_bucket_name # Upload an object - file_name = "ud-test-file" - payload = StringIO.new "Hello world!" - file = bucket.create_file payload, file_name - _(file.name).must_equal file_name + ud_file_name = "ud-test-file" + ud_payload = StringIO.new "Hello world!" + ud_file = bucket.create_file ud_payload, ud_file_name + _(ud_file.name).must_equal ud_file_name # Read the file uploaded - uploaded_file = bucket.file file_name - _(uploaded_file.name).must_equal file_name + uploaded_ud_file = bucket.file ud_file_name + _(uploaded_ud_file.name).must_equal ud_file_name # Delete the object - file.delete - file = bucket.file file_name - _(file).must_be_nil + ud_file.delete + ud_file = bucket.file ud_file_name + _(ud_file).must_be_nil # Delete the bucket - bucket.delete - _(bucket).must_be_nil + ud_bucket.delete + _(ud_bucket).must_be_nil end end From 1fbb1d8c424ff36e2b5aeb61fc74551f682d5807 Mon Sep 17 00:00:00 2001 From: bajajnehaa Date: Tue, 1 Oct 2024 19:42:56 +0000 Subject: [PATCH 26/40] fix typo and other stuff --- .../acceptance/storage/universe_domain_test.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/google-cloud-storage/acceptance/storage/universe_domain_test.rb b/google-cloud-storage/acceptance/storage/universe_domain_test.rb index 0848e8fd8381..a6959ab2aa50 100644 --- a/google-cloud-storage/acceptance/storage/universe_domain_test.rb +++ b/google-cloud-storage/acceptance/storage/universe_domain_test.rb @@ -43,17 +43,16 @@ # Upload an object ud_file_name = "ud-test-file" ud_payload = StringIO.new "Hello world!" - ud_file = bucket.create_file ud_payload, ud_file_name + ud_file = ud_bucket.create_file ud_payload, ud_file_name _(ud_file.name).must_equal ud_file_name # Read the file uploaded - uploaded_ud_file = bucket.file ud_file_name + uploaded_ud_file = ud_bucket.file ud_file_name _(uploaded_ud_file.name).must_equal ud_file_name # Delete the object - ud_file.delete - ud_file = bucket.file ud_file_name - _(ud_file).must_be_nil + uploaded_ud_file.delete + _(uploaded_ud_file).must_be_nil # Delete the bucket ud_bucket.delete From 606a72a34a75bab4dbfdd9536e20b15980149a8f Mon Sep 17 00:00:00 2001 From: bajajnehaa Date: Tue, 1 Oct 2024 20:05:32 +0000 Subject: [PATCH 27/40] Make sure bucket is deleted after test runs --- .../acceptance/storage/universe_domain_test.rb | 14 +++++++++++--- google-cloud-storage/acceptance/storage_helper.rb | 6 +++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/google-cloud-storage/acceptance/storage/universe_domain_test.rb b/google-cloud-storage/acceptance/storage/universe_domain_test.rb index a6959ab2aa50..fe9000ef1c3b 100644 --- a/google-cloud-storage/acceptance/storage/universe_domain_test.rb +++ b/google-cloud-storage/acceptance/storage/universe_domain_test.rb @@ -24,18 +24,26 @@ TEST_UNIVERSE_DOMAIN_CREDENTIAL = File.realpath(File.join( ENV["KOKORO_GFILE_DIR"], "secret_manager", "client-library-test-universe-domain-credential")) - let :universe_domain_storage do + let :ud_storage do Google::Cloud::Storage.new( project_id: TEST_UNIVERSE_PROJECT_ID, keyfile: TEST_UNIVERSE_DOMAIN_CREDENTIAL, universe_domain: TEST_UNIVERSE_DOMAIN ) end + let(:ud_bucket_name) { bucket_names "ud-test-bucket" } + + after do + ud_bucket = ud_storage.bucket ud_bucket_name + if ud_bucket + ud_bucket.files.all &:delete + safe_gcs_execute { ud_bucket.delete } + end + end it "creates a new bucket and uploads an object with universe_domain" do # Create a bucket - ud_bucket_name = "ud-test-bucket" - ud_bucket = safe_gcs_execute { universe_domain_storage.create_bucket ud_bucket_name, location: TEST_UNIVERSE_LOCATION } + ud_bucket = safe_gcs_execute { ud_storage.create_bucket ud_bucket_name, location: TEST_UNIVERSE_LOCATION } puts "bucket: #{ud_bucket.inspect}" _(ud_bucket).wont_be_nil _(ud_bucket.name).must_equal ud_bucket_name diff --git a/google-cloud-storage/acceptance/storage_helper.rb b/google-cloud-storage/acceptance/storage_helper.rb index ab1ee4071634..2d40db877bee 100644 --- a/google-cloud-storage/acceptance/storage_helper.rb +++ b/google-cloud-storage/acceptance/storage_helper.rb @@ -123,12 +123,16 @@ def safe_gcs_execute retries: 5 require "time" require "securerandom" t = Time.now.utc.iso8601.gsub ":", "-" -$bucket_names = 3.times.map { "gcloud-ruby-acceptance-#{t}-#{SecureRandom.hex(4)}".downcase } +$bucket_names = bucket_names $prefix = "gcloud_ruby_acceptance_#{t}_#{SecureRandom.hex(4)}".downcase.gsub "-", "_" # bucket names for second project $bucket_names_2 = 3.times.map { "gcloud-ruby-acceptance-2-#{t}-#{SecureRandom.hex(4)}".downcase } $bucket_name_public = "gcloud-ruby-acceptance-public-read".freeze +def bucket_names prefix: "gcloud-ruby-acceptance" + 3.times.map { "#{prefix}-#{t}-#{SecureRandom.hex(4)}".downcase } +end + def bucket_public begin b = storage.bucket $bucket_name_public From b6d9596e7ae2af0b8e5999af40c0b77feb98d2ed Mon Sep 17 00:00:00 2001 From: bajajnehaa Date: Tue, 1 Oct 2024 20:14:06 +0000 Subject: [PATCH 28/40] change method name --- .../acceptance/storage/universe_domain_test.rb | 2 +- google-cloud-storage/acceptance/storage_helper.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/google-cloud-storage/acceptance/storage/universe_domain_test.rb b/google-cloud-storage/acceptance/storage/universe_domain_test.rb index fe9000ef1c3b..b50924c36742 100644 --- a/google-cloud-storage/acceptance/storage/universe_domain_test.rb +++ b/google-cloud-storage/acceptance/storage/universe_domain_test.rb @@ -31,7 +31,7 @@ universe_domain: TEST_UNIVERSE_DOMAIN ) end - let(:ud_bucket_name) { bucket_names "ud-test-bucket" } + let(:ud_bucket_name) { generate_bucket_names "ud-test-ruby-bucket" } after do ud_bucket = ud_storage.bucket ud_bucket_name diff --git a/google-cloud-storage/acceptance/storage_helper.rb b/google-cloud-storage/acceptance/storage_helper.rb index 2d40db877bee..a61a93c29a6f 100644 --- a/google-cloud-storage/acceptance/storage_helper.rb +++ b/google-cloud-storage/acceptance/storage_helper.rb @@ -123,13 +123,13 @@ def safe_gcs_execute retries: 5 require "time" require "securerandom" t = Time.now.utc.iso8601.gsub ":", "-" -$bucket_names = bucket_names +$bucket_names = generate_bucket_names $prefix = "gcloud_ruby_acceptance_#{t}_#{SecureRandom.hex(4)}".downcase.gsub "-", "_" # bucket names for second project $bucket_names_2 = 3.times.map { "gcloud-ruby-acceptance-2-#{t}-#{SecureRandom.hex(4)}".downcase } $bucket_name_public = "gcloud-ruby-acceptance-public-read".freeze -def bucket_names prefix: "gcloud-ruby-acceptance" +def generate_bucket_names prefix="gcloud-ruby-acceptance" 3.times.map { "#{prefix}-#{t}-#{SecureRandom.hex(4)}".downcase } end From c0dcc85cc4857adba5afb6dbef4adaa4c61b5a5a Mon Sep 17 00:00:00 2001 From: bajajnehaa Date: Tue, 1 Oct 2024 20:23:16 +0000 Subject: [PATCH 29/40] revert the generate_bucket_names method --- .../acceptance/storage/universe_domain_test.rb | 2 +- google-cloud-storage/acceptance/storage_helper.rb | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/google-cloud-storage/acceptance/storage/universe_domain_test.rb b/google-cloud-storage/acceptance/storage/universe_domain_test.rb index b50924c36742..917f47d4b9e5 100644 --- a/google-cloud-storage/acceptance/storage/universe_domain_test.rb +++ b/google-cloud-storage/acceptance/storage/universe_domain_test.rb @@ -31,7 +31,7 @@ universe_domain: TEST_UNIVERSE_DOMAIN ) end - let(:ud_bucket_name) { generate_bucket_names "ud-test-ruby-bucket" } + let(:ud_bucket_name) { "ud-test-ruby-bucket-#{t}-#{SecureRandom.hex(4)}".downcase } after do ud_bucket = ud_storage.bucket ud_bucket_name diff --git a/google-cloud-storage/acceptance/storage_helper.rb b/google-cloud-storage/acceptance/storage_helper.rb index a61a93c29a6f..ab1ee4071634 100644 --- a/google-cloud-storage/acceptance/storage_helper.rb +++ b/google-cloud-storage/acceptance/storage_helper.rb @@ -123,16 +123,12 @@ def safe_gcs_execute retries: 5 require "time" require "securerandom" t = Time.now.utc.iso8601.gsub ":", "-" -$bucket_names = generate_bucket_names +$bucket_names = 3.times.map { "gcloud-ruby-acceptance-#{t}-#{SecureRandom.hex(4)}".downcase } $prefix = "gcloud_ruby_acceptance_#{t}_#{SecureRandom.hex(4)}".downcase.gsub "-", "_" # bucket names for second project $bucket_names_2 = 3.times.map { "gcloud-ruby-acceptance-2-#{t}-#{SecureRandom.hex(4)}".downcase } $bucket_name_public = "gcloud-ruby-acceptance-public-read".freeze -def generate_bucket_names prefix="gcloud-ruby-acceptance" - 3.times.map { "#{prefix}-#{t}-#{SecureRandom.hex(4)}".downcase } -end - def bucket_public begin b = storage.bucket $bucket_name_public From 050c188cbf6f30c010b2fe82f8bd654d22122131 Mon Sep 17 00:00:00 2001 From: bajajnehaa Date: Tue, 1 Oct 2024 20:35:24 +0000 Subject: [PATCH 30/40] fix --- google-cloud-storage/acceptance/storage/universe_domain_test.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/google-cloud-storage/acceptance/storage/universe_domain_test.rb b/google-cloud-storage/acceptance/storage/universe_domain_test.rb index 917f47d4b9e5..45aae5ffad40 100644 --- a/google-cloud-storage/acceptance/storage/universe_domain_test.rb +++ b/google-cloud-storage/acceptance/storage/universe_domain_test.rb @@ -31,6 +31,7 @@ universe_domain: TEST_UNIVERSE_DOMAIN ) end + let(:t) { Time.now.utc.iso8601.gsub ":", "-" } let(:ud_bucket_name) { "ud-test-ruby-bucket-#{t}-#{SecureRandom.hex(4)}".downcase } after do From 564b4690999d2b174cffb06aa0cbf1d6454929a3 Mon Sep 17 00:00:00 2001 From: bajajnehaa Date: Tue, 1 Oct 2024 21:03:32 +0000 Subject: [PATCH 31/40] debugging --- .../acceptance/storage/universe_domain_test.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/google-cloud-storage/acceptance/storage/universe_domain_test.rb b/google-cloud-storage/acceptance/storage/universe_domain_test.rb index 45aae5ffad40..63ed6c009bb5 100644 --- a/google-cloud-storage/acceptance/storage/universe_domain_test.rb +++ b/google-cloud-storage/acceptance/storage/universe_domain_test.rb @@ -14,9 +14,9 @@ require "storage_helper" -Google::Apis.logger.level = Logger::DEBUG - -describe Google::Cloud::Storage do +describe Google::Cloud::Storage, :universe_domain do + Google::Apis.logger.level = Logger::DEBUG + # Fetch secret values from the secret_manager path TEST_UNIVERSE_PROJECT_ID = File.read(File.realpath(File.join(ENV["KOKORO_GFILE_DIR"], "secret_manager", "client-library-test-universe-project-id"))) TEST_UNIVERSE_LOCATION = File.read(File.realpath(File.join(ENV["KOKORO_GFILE_DIR"], "secret_manager", "client-library-test-universe-storage-location"))) @@ -27,7 +27,7 @@ let :ud_storage do Google::Cloud::Storage.new( project_id: TEST_UNIVERSE_PROJECT_ID, - keyfile: TEST_UNIVERSE_DOMAIN_CREDENTIAL, + credentials: TEST_UNIVERSE_DOMAIN_CREDENTIAL, universe_domain: TEST_UNIVERSE_DOMAIN ) end From 334dbd68ff3bb4edd7a54d26e56cb7355b75aa69 Mon Sep 17 00:00:00 2001 From: Shubhangi Singh Date: Thu, 3 Oct 2024 09:29:24 +0000 Subject: [PATCH 32/40] try debuging --- google-cloud-storage/acceptance/storage/universe_domain_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/google-cloud-storage/acceptance/storage/universe_domain_test.rb b/google-cloud-storage/acceptance/storage/universe_domain_test.rb index 63ed6c009bb5..fbc9733ccb5d 100644 --- a/google-cloud-storage/acceptance/storage/universe_domain_test.rb +++ b/google-cloud-storage/acceptance/storage/universe_domain_test.rb @@ -45,7 +45,7 @@ it "creates a new bucket and uploads an object with universe_domain" do # Create a bucket ud_bucket = safe_gcs_execute { ud_storage.create_bucket ud_bucket_name, location: TEST_UNIVERSE_LOCATION } - puts "bucket: #{ud_bucket.inspect}" + puts "shubhangi_ud_bucket: #{ud_bucket.inspect}" _(ud_bucket).wont_be_nil _(ud_bucket.name).must_equal ud_bucket_name From 29cf0d37ecdd8d8f0f91ed22e94ca7b4e6498041 Mon Sep 17 00:00:00 2001 From: Shubhangi Singh Date: Thu, 3 Oct 2024 09:47:15 +0000 Subject: [PATCH 33/40] try debugging --- .../storage/universe_domain_test.rb | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/google-cloud-storage/acceptance/storage/universe_domain_test.rb b/google-cloud-storage/acceptance/storage/universe_domain_test.rb index fbc9733ccb5d..e5bc8d255693 100644 --- a/google-cloud-storage/acceptance/storage/universe_domain_test.rb +++ b/google-cloud-storage/acceptance/storage/universe_domain_test.rb @@ -17,13 +17,30 @@ describe Google::Cloud::Storage, :universe_domain do Google::Apis.logger.level = Logger::DEBUG - # Fetch secret values from the secret_manager path - TEST_UNIVERSE_PROJECT_ID = File.read(File.realpath(File.join(ENV["KOKORO_GFILE_DIR"], "secret_manager", "client-library-test-universe-project-id"))) - TEST_UNIVERSE_LOCATION = File.read(File.realpath(File.join(ENV["KOKORO_GFILE_DIR"], "secret_manager", "client-library-test-universe-storage-location"))) - TEST_UNIVERSE_DOMAIN = File.read(File.realpath(File.join( ENV["KOKORO_GFILE_DIR"], "secret_manager", "client-library-test-universe-domain"))) - TEST_UNIVERSE_DOMAIN_CREDENTIAL = File.realpath(File.join( ENV["KOKORO_GFILE_DIR"], "secret_manager", "client-library-test-universe-domain-credential")) - + # Universe Domain Test project Credentials + secret_project = 'cloud-devrel-kokoro-resources' + secret_domain_id = 'client-library-test-universe-domain' + secret_project_id = 'client-library-test-universe-project-id' + secret_location_id = 'client-library-test-universe-storage-location' + secret_version = 'latest' + client = Google::Cloud::SecretManager.secret_manager_service + ENV["TEST_UNIVERSE_DOMAIN"] = client.secret_version_path( + project: secret_project, + secret: secret_domain_id, + secret_version: secret_version + ) + ENV["TEST_UNIVERSE_PROJECT_ID"] = client.secret_version_path( + project: secret_project, + secret: secret_project_id, + secret_version: secret_version + ) + ENV["TEST_UNIVERSE_LOCATION"] = client.secret_version_path( + project: secret_project, + secret: secret_location_id, + secret_version: secret_version + ) + ENV["TEST_UNIVERSE_DOMAIN_CREDENTIAL"] = File.realpath(File.join(ENV['KOKORO_GFILE_DIR'], 'secret_manager', 'client-library-test-universe-domain-credential')) let :ud_storage do Google::Cloud::Storage.new( project_id: TEST_UNIVERSE_PROJECT_ID, @@ -34,6 +51,7 @@ let(:t) { Time.now.utc.iso8601.gsub ":", "-" } let(:ud_bucket_name) { "ud-test-ruby-bucket-#{t}-#{SecureRandom.hex(4)}".downcase } + after do ud_bucket = ud_storage.bucket ud_bucket_name if ud_bucket From 36fa4f8cbae2fb1475dbeee079105c7f74498275 Mon Sep 17 00:00:00 2001 From: Shubhangi Singh Date: Thu, 3 Oct 2024 09:53:24 +0000 Subject: [PATCH 34/40] try --- .../storage/universe_domain_test.rb | 29 ++++--------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/google-cloud-storage/acceptance/storage/universe_domain_test.rb b/google-cloud-storage/acceptance/storage/universe_domain_test.rb index e5bc8d255693..0218d72afee7 100644 --- a/google-cloud-storage/acceptance/storage/universe_domain_test.rb +++ b/google-cloud-storage/acceptance/storage/universe_domain_test.rb @@ -17,30 +17,13 @@ describe Google::Cloud::Storage, :universe_domain do Google::Apis.logger.level = Logger::DEBUG - # Universe Domain Test project Credentials - secret_project = 'cloud-devrel-kokoro-resources' - secret_domain_id = 'client-library-test-universe-domain' - secret_project_id = 'client-library-test-universe-project-id' - secret_location_id = 'client-library-test-universe-storage-location' - secret_version = 'latest' + # Fetch secret values from the secret_manager path + TEST_UNIVERSE_PROJECT_ID = File.read(File.realpath(File.join(ENV["KOKORO_GFILE_DIR"], "secret_manager", "client-library-test-universe-project-id"))) + TEST_UNIVERSE_LOCATION = File.read(File.realpath(File.join(ENV["KOKORO_GFILE_DIR"], "secret_manager", "client-library-test-universe-storage-location"))) + TEST_UNIVERSE_DOMAIN = File.read(File.realpath(File.join( ENV["KOKORO_GFILE_DIR"], "secret_manager", "client-library-test-universe-domain"))) + TEST_UNIVERSE_DOMAIN_CREDENTIAL = File.realpath(File.join( ENV["KOKORO_GFILE_DIR"], "secret_manager", "client-library-test-universe-domain-credential")) + - client = Google::Cloud::SecretManager.secret_manager_service - ENV["TEST_UNIVERSE_DOMAIN"] = client.secret_version_path( - project: secret_project, - secret: secret_domain_id, - secret_version: secret_version - ) - ENV["TEST_UNIVERSE_PROJECT_ID"] = client.secret_version_path( - project: secret_project, - secret: secret_project_id, - secret_version: secret_version - ) - ENV["TEST_UNIVERSE_LOCATION"] = client.secret_version_path( - project: secret_project, - secret: secret_location_id, - secret_version: secret_version - ) - ENV["TEST_UNIVERSE_DOMAIN_CREDENTIAL"] = File.realpath(File.join(ENV['KOKORO_GFILE_DIR'], 'secret_manager', 'client-library-test-universe-domain-credential')) let :ud_storage do Google::Cloud::Storage.new( project_id: TEST_UNIVERSE_PROJECT_ID, From 685277ae9247af14ae88f7f72ce92d875b26e827 Mon Sep 17 00:00:00 2001 From: Shubhangi Singh Date: Thu, 3 Oct 2024 11:07:41 +0000 Subject: [PATCH 35/40] try --- .../storage/universe_domain_test.rb | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/google-cloud-storage/acceptance/storage/universe_domain_test.rb b/google-cloud-storage/acceptance/storage/universe_domain_test.rb index 0218d72afee7..0ec60fe542e6 100644 --- a/google-cloud-storage/acceptance/storage/universe_domain_test.rb +++ b/google-cloud-storage/acceptance/storage/universe_domain_test.rb @@ -35,13 +35,13 @@ let(:ud_bucket_name) { "ud-test-ruby-bucket-#{t}-#{SecureRandom.hex(4)}".downcase } - after do - ud_bucket = ud_storage.bucket ud_bucket_name - if ud_bucket - ud_bucket.files.all &:delete - safe_gcs_execute { ud_bucket.delete } - end - end + # after do + # ud_bucket = ud_storage.bucket ud_bucket_name + # if ud_bucket + # ud_bucket.files.all &:delete + # safe_gcs_execute { ud_bucket.delete } + # end + # end it "creates a new bucket and uploads an object with universe_domain" do # Create a bucket @@ -56,10 +56,15 @@ ud_file = ud_bucket.create_file ud_payload, ud_file_name _(ud_file.name).must_equal ud_file_name + puts "shubhangi_ud_bucket file uploloaded: #{ud_file_name}" + # Read the file uploaded uploaded_ud_file = ud_bucket.file ud_file_name _(uploaded_ud_file.name).must_equal ud_file_name + puts "shubhangi_ud_bucket file Read done: #{ud_file_name}" + + # Delete the object uploaded_ud_file.delete _(uploaded_ud_file).must_be_nil @@ -67,5 +72,8 @@ # Delete the bucket ud_bucket.delete _(ud_bucket).must_be_nil + + puts "shubhangi_ud_bucket bucket supposed to be deleted" + end end From 4e50db8b2dfed60a59b53bfd0091eb5c6031d21c Mon Sep 17 00:00:00 2001 From: Shubhangi Singh Date: Thu, 3 Oct 2024 11:36:30 +0000 Subject: [PATCH 36/40] try --- .../acceptance/storage/universe_domain_test.rb | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/google-cloud-storage/acceptance/storage/universe_domain_test.rb b/google-cloud-storage/acceptance/storage/universe_domain_test.rb index 0ec60fe542e6..54051a3229f0 100644 --- a/google-cloud-storage/acceptance/storage/universe_domain_test.rb +++ b/google-cloud-storage/acceptance/storage/universe_domain_test.rb @@ -34,14 +34,13 @@ let(:t) { Time.now.utc.iso8601.gsub ":", "-" } let(:ud_bucket_name) { "ud-test-ruby-bucket-#{t}-#{SecureRandom.hex(4)}".downcase } - - # after do - # ud_bucket = ud_storage.bucket ud_bucket_name - # if ud_bucket - # ud_bucket.files.all &:delete - # safe_gcs_execute { ud_bucket.delete } - # end - # end + after do + ud_bucket = ud_storage.bucket ud_bucket_name + if ud_bucket + ud_bucket.files.all &:delete + safe_gcs_execute { ud_bucket.delete } + end + end it "creates a new bucket and uploads an object with universe_domain" do # Create a bucket From 68915e8245387a7fce0a7f8a51a687c19c853288 Mon Sep 17 00:00:00 2001 From: Shubhangi Singh Date: Thu, 3 Oct 2024 12:03:49 +0000 Subject: [PATCH 37/40] try --- google-cloud-storage/acceptance/storage/universe_domain_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/google-cloud-storage/acceptance/storage/universe_domain_test.rb b/google-cloud-storage/acceptance/storage/universe_domain_test.rb index 54051a3229f0..b22a7ff9e098 100644 --- a/google-cloud-storage/acceptance/storage/universe_domain_test.rb +++ b/google-cloud-storage/acceptance/storage/universe_domain_test.rb @@ -44,7 +44,7 @@ it "creates a new bucket and uploads an object with universe_domain" do # Create a bucket - ud_bucket = safe_gcs_execute { ud_storage.create_bucket ud_bucket_name, location: TEST_UNIVERSE_LOCATION } + ud_bucket = ud_storage.create_bucket ud_bucket_name, location: TEST_UNIVERSE_LOCATION puts "shubhangi_ud_bucket: #{ud_bucket.inspect}" _(ud_bucket).wont_be_nil _(ud_bucket.name).must_equal ud_bucket_name From b28de5865b2c0dad067695475ec82b3d51fdc671 Mon Sep 17 00:00:00 2001 From: Shubhangi Singh Date: Thu, 3 Oct 2024 12:26:18 +0000 Subject: [PATCH 38/40] try --- .../storage/universe_domain_test.rb | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/google-cloud-storage/acceptance/storage/universe_domain_test.rb b/google-cloud-storage/acceptance/storage/universe_domain_test.rb index b22a7ff9e098..21a85db5c88d 100644 --- a/google-cloud-storage/acceptance/storage/universe_domain_test.rb +++ b/google-cloud-storage/acceptance/storage/universe_domain_test.rb @@ -23,7 +23,6 @@ TEST_UNIVERSE_DOMAIN = File.read(File.realpath(File.join( ENV["KOKORO_GFILE_DIR"], "secret_manager", "client-library-test-universe-domain"))) TEST_UNIVERSE_DOMAIN_CREDENTIAL = File.realpath(File.join( ENV["KOKORO_GFILE_DIR"], "secret_manager", "client-library-test-universe-domain-credential")) - let :ud_storage do Google::Cloud::Storage.new( project_id: TEST_UNIVERSE_PROJECT_ID, @@ -34,13 +33,13 @@ let(:t) { Time.now.utc.iso8601.gsub ":", "-" } let(:ud_bucket_name) { "ud-test-ruby-bucket-#{t}-#{SecureRandom.hex(4)}".downcase } - after do - ud_bucket = ud_storage.bucket ud_bucket_name - if ud_bucket - ud_bucket.files.all &:delete - safe_gcs_execute { ud_bucket.delete } - end - end + # after do + # ud_bucket = ud_storage.bucket ud_bucket_name + # if ud_bucket + # ud_bucket.files.all &:delete + # safe_gcs_execute { ud_bucket.delete } + # end + # end it "creates a new bucket and uploads an object with universe_domain" do # Create a bucket @@ -64,15 +63,15 @@ puts "shubhangi_ud_bucket file Read done: #{ud_file_name}" - # Delete the object - uploaded_ud_file.delete - _(uploaded_ud_file).must_be_nil + # # Delete the object + # uploaded_ud_file.delete + # _(uploaded_ud_file).must_be_nil - # Delete the bucket - ud_bucket.delete - _(ud_bucket).must_be_nil + # # Delete the bucket + # ud_bucket.delete + # _(ud_bucket).must_be_nil - puts "shubhangi_ud_bucket bucket supposed to be deleted" + # puts "shubhangi_ud_bucket bucket supposed to be deleted" end end From cd18f247fd74a5192a7f0deb8835eadb2eb77421 Mon Sep 17 00:00:00 2001 From: Shubhangi Singh Date: Thu, 3 Oct 2024 14:34:29 +0000 Subject: [PATCH 39/40] try --- .../storage/universe_domain_test.rb | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/google-cloud-storage/acceptance/storage/universe_domain_test.rb b/google-cloud-storage/acceptance/storage/universe_domain_test.rb index 21a85db5c88d..578112f52989 100644 --- a/google-cloud-storage/acceptance/storage/universe_domain_test.rb +++ b/google-cloud-storage/acceptance/storage/universe_domain_test.rb @@ -33,18 +33,18 @@ let(:t) { Time.now.utc.iso8601.gsub ":", "-" } let(:ud_bucket_name) { "ud-test-ruby-bucket-#{t}-#{SecureRandom.hex(4)}".downcase } - # after do - # ud_bucket = ud_storage.bucket ud_bucket_name - # if ud_bucket - # ud_bucket.files.all &:delete - # safe_gcs_execute { ud_bucket.delete } - # end - # end + after do + ud_bucket = ud_storage.bucket ud_bucket_name + if ud_bucket + ud_bucket.files.all &:delete + safe_gcs_execute { ud_bucket.delete } + end + end it "creates a new bucket and uploads an object with universe_domain" do # Create a bucket ud_bucket = ud_storage.create_bucket ud_bucket_name, location: TEST_UNIVERSE_LOCATION - puts "shubhangi_ud_bucket: #{ud_bucket.inspect}" + puts "ud_bucket: #{ud_bucket.inspect}" _(ud_bucket).wont_be_nil _(ud_bucket.name).must_equal ud_bucket_name @@ -54,24 +54,23 @@ ud_file = ud_bucket.create_file ud_payload, ud_file_name _(ud_file.name).must_equal ud_file_name - puts "shubhangi_ud_bucket file uploloaded: #{ud_file_name}" + puts "ud_bucket file uploloaded: #{ud_file_name}" # Read the file uploaded uploaded_ud_file = ud_bucket.file ud_file_name _(uploaded_ud_file.name).must_equal ud_file_name - puts "shubhangi_ud_bucket file Read done: #{ud_file_name}" - + puts "ud_bucket file Read done: #{ud_file_name}" - # # Delete the object - # uploaded_ud_file.delete - # _(uploaded_ud_file).must_be_nil + # Delete the object + uploaded_ud_file.delete + _(uploaded_ud_file).must_be_nil - # # Delete the bucket - # ud_bucket.delete - # _(ud_bucket).must_be_nil + # Delete the bucket + ud_bucket.delete + _(ud_bucket).must_be_nil - # puts "shubhangi_ud_bucket bucket supposed to be deleted" + puts "ud_bucket bucket supposed to be deleted" end end From b6ccf6e8ecd8431f940375964f2c6203d297bcd7 Mon Sep 17 00:00:00 2001 From: Shubhangi Singh Date: Fri, 4 Oct 2024 13:12:47 +0000 Subject: [PATCH 40/40] removing loggers --- .../acceptance/storage/universe_domain_test.rb | 8 -------- 1 file changed, 8 deletions(-) diff --git a/google-cloud-storage/acceptance/storage/universe_domain_test.rb b/google-cloud-storage/acceptance/storage/universe_domain_test.rb index 578112f52989..e958c6d2a2cb 100644 --- a/google-cloud-storage/acceptance/storage/universe_domain_test.rb +++ b/google-cloud-storage/acceptance/storage/universe_domain_test.rb @@ -15,7 +15,6 @@ require "storage_helper" describe Google::Cloud::Storage, :universe_domain do - Google::Apis.logger.level = Logger::DEBUG # Fetch secret values from the secret_manager path TEST_UNIVERSE_PROJECT_ID = File.read(File.realpath(File.join(ENV["KOKORO_GFILE_DIR"], "secret_manager", "client-library-test-universe-project-id"))) @@ -44,7 +43,6 @@ it "creates a new bucket and uploads an object with universe_domain" do # Create a bucket ud_bucket = ud_storage.create_bucket ud_bucket_name, location: TEST_UNIVERSE_LOCATION - puts "ud_bucket: #{ud_bucket.inspect}" _(ud_bucket).wont_be_nil _(ud_bucket.name).must_equal ud_bucket_name @@ -54,14 +52,10 @@ ud_file = ud_bucket.create_file ud_payload, ud_file_name _(ud_file.name).must_equal ud_file_name - puts "ud_bucket file uploloaded: #{ud_file_name}" - # Read the file uploaded uploaded_ud_file = ud_bucket.file ud_file_name _(uploaded_ud_file.name).must_equal ud_file_name - puts "ud_bucket file Read done: #{ud_file_name}" - # Delete the object uploaded_ud_file.delete _(uploaded_ud_file).must_be_nil @@ -70,7 +64,5 @@ ud_bucket.delete _(ud_bucket).must_be_nil - puts "ud_bucket bucket supposed to be deleted" - end end