Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(storage): add integration test for universe domain #27384

Open
wants to merge 40 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
b902004
adding universe domain tests+ ENV vars
shubhangi-google Sep 27, 2024
59266ac
removing unwanted change
shubhangi-google Sep 30, 2024
cef3000
removing test specific env vars from common file
shubhangi-google Sep 30, 2024
9726809
adding system env vars
shubhangi-google Sep 30, 2024
a331bbd
adding system env vars to test file
shubhangi-google Sep 30, 2024
9eb76ae
try initiating bucket
shubhangi-google Sep 30, 2024
b749474
try skipping location check
shubhangi-google Sep 30, 2024
60e87d5
putting sytem vars in integration.sh
shubhangi-google Sep 30, 2024
567c9ce
undo
shubhangi-google Sep 30, 2024
538a75b
trying env vars
shubhangi-google Oct 1, 2024
1b5b7b9
trying read secrets
shubhangi-google Oct 1, 2024
8a73629
fix syntax
shubhangi-google Oct 1, 2024
94a0e39
trying env vars
shubhangi-google Oct 1, 2024
2758666
try env vars
shubhangi-google Oct 1, 2024
7b5800d
try removing things from integration.sh
shubhangi-google Oct 1, 2024
7bcf1fb
undo
shubhangi-google Oct 1, 2024
159b7af
rubocop thing
shubhangi-google Oct 1, 2024
7f281f0
try
shubhangi-google Oct 1, 2024
b416e24
moving back to setting system env vars from ruby file
shubhangi-google Oct 1, 2024
fe89c5d
resolving rubocop issue
shubhangi-google Oct 1, 2024
cd86904
Fetch all secrets using populate-screts
bajajneha27 Oct 1, 2024
1480fb3
debug mode ON
bajajneha27 Oct 1, 2024
5c188b3
Rewrite the universe domain test
bajajneha27 Oct 1, 2024
6e16b14
futher debugging
bajajneha27 Oct 1, 2024
784c5e5
debug failure
bajajneha27 Oct 1, 2024
1fbb1d8
fix typo and other stuff
bajajneha27 Oct 1, 2024
606a72a
Make sure bucket is deleted after test runs
bajajneha27 Oct 1, 2024
b6d9596
change method name
bajajneha27 Oct 1, 2024
c0dcc85
revert the generate_bucket_names method
bajajneha27 Oct 1, 2024
050c188
fix
bajajneha27 Oct 1, 2024
564b469
debugging
bajajneha27 Oct 1, 2024
334dbd6
try debuging
shubhangi-google Oct 3, 2024
29cf0d3
try debugging
shubhangi-google Oct 3, 2024
36fa4f8
try
shubhangi-google Oct 3, 2024
685277a
try
shubhangi-google Oct 3, 2024
4e50db8
try
shubhangi-google Oct 3, 2024
68915e8
try
shubhangi-google Oct 3, 2024
b28de58
try
shubhangi-google Oct 3, 2024
cd18f24
try
shubhangi-google Oct 3, 2024
b6ccf6e
removing loggers
shubhangi-google Oct 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .kokoro/presubmit/acceptance.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ env_vars: {

env_vars: {
key: "SECRET_MANAGER_KEYS"
value: ""
value: "client-library-test-universe-domain-credential"
}

env_vars: {
Expand Down
79 changes: 79 additions & 0 deletions google-cloud-storage/acceptance/storage/universe_domain_test.rb
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions google-cloud-storage/acceptance/storage_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
shubhangi-google marked this conversation as resolved.
Show resolved Hide resolved
$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
Expand Down
Loading