From 96385900dd438af1ecfee93f50debb90f24e711a Mon Sep 17 00:00:00 2001 From: Shubhangi Singh Date: Thu, 23 Jul 2026 06:42:05 +0000 Subject: [PATCH 1/6] fixing test --- google-cloud-storage/samples/acceptance/files_test.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/google-cloud-storage/samples/acceptance/files_test.rb b/google-cloud-storage/samples/acceptance/files_test.rb index aa8bf1f10f49..2e481e85da62 100644 --- a/google-cloud-storage/samples/acceptance/files_test.rb +++ b/google-cloud-storage/samples/acceptance/files_test.rb @@ -334,11 +334,11 @@ def mock_cipher.random_key bucket.create_file local_file, remote_file_name+"2" set_object_contexts bucket_name: bucket.name, file_name: remote_file_name, custom_context_key: custom_context_key1, custom_context_value: custom_context_value1 - set_object_contexts bucket_name: bucket.name, file_name: remote_file_name, custom_context_key: custom_context_key2, custom_context_value: custom_context_value2 + set_object_contexts bucket_name: bucket.name, file_name: remote_file_name+"2", custom_context_key: custom_context_key2, custom_context_value: custom_context_value2 end - it "fetches all object contexts" do + it "fetches the object contexts" do - assert_output "Custom Contexts for #{remote_file_name} are:\nKey: #{custom_context_key1}, Value: #{custom_context_value1}\nKey: #{custom_context_key2}, Value: #{custom_context_value2}\n" do + assert_output "Custom Contexts for #{remote_file_name} are:\nKey: #{custom_context_key1}, Value: #{custom_context_value1}\n" do get_object_contexts bucket_name: bucket.name, file_name: remote_file_name end end From ebf8067de0dde7eab004899933a1cf53dc819c94 Mon Sep 17 00:00:00 2001 From: Shubhangi Singh Date: Thu, 23 Jul 2026 06:42:33 +0000 Subject: [PATCH 2/6] fix indentation --- google-cloud-storage/samples/acceptance/files_test.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/google-cloud-storage/samples/acceptance/files_test.rb b/google-cloud-storage/samples/acceptance/files_test.rb index 2e481e85da62..18a754ce488d 100644 --- a/google-cloud-storage/samples/acceptance/files_test.rb +++ b/google-cloud-storage/samples/acceptance/files_test.rb @@ -335,6 +335,7 @@ def mock_cipher.random_key set_object_contexts bucket_name: bucket.name, file_name: remote_file_name, custom_context_key: custom_context_key1, custom_context_value: custom_context_value1 set_object_contexts bucket_name: bucket.name, file_name: remote_file_name+"2", custom_context_key: custom_context_key2, custom_context_value: custom_context_value2 + end it "fetches the object contexts" do From 66769c002928bf10929752a5c8966d538089c72a Mon Sep 17 00:00:00 2001 From: Shubhangi Singh Date: Thu, 23 Jul 2026 08:03:08 +0000 Subject: [PATCH 3/6] fix list object flaky test --- google-cloud-storage/samples/acceptance/files_test.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/google-cloud-storage/samples/acceptance/files_test.rb b/google-cloud-storage/samples/acceptance/files_test.rb index 18a754ce488d..bb903740a399 100644 --- a/google-cloud-storage/samples/acceptance/files_test.rb +++ b/google-cloud-storage/samples/acceptance/files_test.rb @@ -328,17 +328,17 @@ def mock_cipher.random_key let(:custom_context_value1) { "my-custom-value" } let(:custom_context_key2) { "my-custom-key-2" } let(:custom_context_value2) { "my-custom-value-2" } + let(:remote_file_name2) { "path/file_name_#{SecureRandom.hex}.txt" } before(:each) do bucket.create_file local_file, remote_file_name - bucket.create_file local_file, remote_file_name+"2" + bucket.create_file local_file, remote_file_name2 set_object_contexts bucket_name: bucket.name, file_name: remote_file_name, custom_context_key: custom_context_key1, custom_context_value: custom_context_value1 - set_object_contexts bucket_name: bucket.name, file_name: remote_file_name+"2", custom_context_key: custom_context_key2, custom_context_value: custom_context_value2 + set_object_contexts bucket_name: bucket.name, file_name: remote_file_name2, custom_context_key: custom_context_key2, custom_context_value: custom_context_value2 end it "fetches the object contexts" do - assert_output "Custom Contexts for #{remote_file_name} are:\nKey: #{custom_context_key1}, Value: #{custom_context_value1}\n" do get_object_contexts bucket_name: bucket.name, file_name: remote_file_name end @@ -350,13 +350,14 @@ def mock_cipher.random_key let(:custom_context_value1) { "my-custom-value" } let(:custom_context_key2) { "my-custom-key-2" } let(:custom_context_value2) { "my-custom-value-2" } + let(:remote_file_name2) { "path/file_name_#{SecureRandom.hex}.txt" } before(:each) do bucket.create_file local_file, remote_file_name - bucket.create_file local_file, remote_file_name+"2" + bucket.create_file local_file, remote_file_name2 set_object_contexts bucket_name: bucket.name, file_name: remote_file_name, custom_context_key: custom_context_key1, custom_context_value: custom_context_value1 - set_object_contexts bucket_name: bucket.name, file_name: remote_file_name+"2", custom_context_key: custom_context_key2, custom_context_value: custom_context_value2 + set_object_contexts bucket_name: bucket.name, file_name: remote_file_name2, custom_context_key: custom_context_key2, custom_context_value: custom_context_value2 end it "filters out files on the basis of custom context key" do From 1e5651cf5f1d86f7ba27ef6adbe1376a38231c94 Mon Sep 17 00:00:00 2001 From: Shubhangi Singh Date: Thu, 23 Jul 2026 08:18:06 +0000 Subject: [PATCH 4/6] fix --- google-cloud-storage/samples/acceptance/files_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/google-cloud-storage/samples/acceptance/files_test.rb b/google-cloud-storage/samples/acceptance/files_test.rb index bb903740a399..ed0d2082021c 100644 --- a/google-cloud-storage/samples/acceptance/files_test.rb +++ b/google-cloud-storage/samples/acceptance/files_test.rb @@ -367,7 +367,7 @@ def mock_cipher.random_key end it "filters out files on the basis of custom context key and value" do - assert_output "File: #{remote_file_name+"2"} has context key: #{custom_context_key2}\n" do + assert_output "File: #{remote_file_name2} has context key: #{custom_context_key2}\n" do list_object_contexts bucket_name: bucket.name, custom_context_key: custom_context_key2, custom_context_value: custom_context_value2 end end From 0e5a3484b517b501351dba76acf55ec6f533a5fb Mon Sep 17 00:00:00 2001 From: Shubhangi Singh Date: Thu, 23 Jul 2026 08:34:03 +0000 Subject: [PATCH 5/6] blank commit --- google-cloud-storage/samples/acceptance/files_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/google-cloud-storage/samples/acceptance/files_test.rb b/google-cloud-storage/samples/acceptance/files_test.rb index ed0d2082021c..6c908638a73f 100644 --- a/google-cloud-storage/samples/acceptance/files_test.rb +++ b/google-cloud-storage/samples/acceptance/files_test.rb @@ -336,8 +336,8 @@ def mock_cipher.random_key set_object_contexts bucket_name: bucket.name, file_name: remote_file_name, custom_context_key: custom_context_key1, custom_context_value: custom_context_value1 set_object_contexts bucket_name: bucket.name, file_name: remote_file_name2, custom_context_key: custom_context_key2, custom_context_value: custom_context_value2 - end + it "fetches the object contexts" do assert_output "Custom Contexts for #{remote_file_name} are:\nKey: #{custom_context_key1}, Value: #{custom_context_value1}\n" do get_object_contexts bucket_name: bucket.name, file_name: remote_file_name From edc72d7b44dfd1bc0f4dc3678d9c89816796abf7 Mon Sep 17 00:00:00 2001 From: Shubhangi Singh Date: Thu, 23 Jul 2026 14:14:51 +0000 Subject: [PATCH 6/6] add retries for list_object_contexts --- .../samples/acceptance/files_test.rb | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/google-cloud-storage/samples/acceptance/files_test.rb b/google-cloud-storage/samples/acceptance/files_test.rb index 6c908638a73f..67f52208d310 100644 --- a/google-cloud-storage/samples/acceptance/files_test.rb +++ b/google-cloud-storage/samples/acceptance/files_test.rb @@ -328,18 +328,16 @@ def mock_cipher.random_key let(:custom_context_value1) { "my-custom-value" } let(:custom_context_key2) { "my-custom-key-2" } let(:custom_context_value2) { "my-custom-value-2" } - let(:remote_file_name2) { "path/file_name_#{SecureRandom.hex}.txt" } before(:each) do bucket.create_file local_file, remote_file_name - bucket.create_file local_file, remote_file_name2 set_object_contexts bucket_name: bucket.name, file_name: remote_file_name, custom_context_key: custom_context_key1, custom_context_value: custom_context_value1 - set_object_contexts bucket_name: bucket.name, file_name: remote_file_name2, custom_context_key: custom_context_key2, custom_context_value: custom_context_value2 + set_object_contexts bucket_name: bucket.name, file_name: remote_file_name, custom_context_key: custom_context_key2, custom_context_value: custom_context_value2 end + it "fetches all object contexts" do - it "fetches the object contexts" do - assert_output "Custom Contexts for #{remote_file_name} are:\nKey: #{custom_context_key1}, Value: #{custom_context_value1}\n" do + assert_output "Custom Contexts for #{remote_file_name} are:\nKey: #{custom_context_key1}, Value: #{custom_context_value1}\nKey: #{custom_context_key2}, Value: #{custom_context_value2}\n" do get_object_contexts bucket_name: bucket.name, file_name: remote_file_name end end @@ -360,16 +358,30 @@ def mock_cipher.random_key set_object_contexts bucket_name: bucket.name, file_name: remote_file_name2, custom_context_key: custom_context_key2, custom_context_value: custom_context_value2 end + it "filters out files on the basis of custom context key" do - assert_output "File: #{remote_file_name} has context key: #{custom_context_key1}\n" do - list_object_contexts bucket_name: bucket.name, custom_context_key: custom_context_key1 + out = nil + 5.times do + out, _err = capture_io do + list_object_contexts bucket_name: bucket.name, custom_context_key: custom_context_key1 + end + break unless out.empty? + sleep 1 end + assert_equal "File: #{remote_file_name} has context key: #{custom_context_key1}\n", out end + it "filters out files on the basis of custom context key and value" do - assert_output "File: #{remote_file_name2} has context key: #{custom_context_key2}\n" do - list_object_contexts bucket_name: bucket.name, custom_context_key: custom_context_key2, custom_context_value: custom_context_value2 + out = nil + 5.times do + out, _err = capture_io do + list_object_contexts bucket_name: bucket.name, custom_context_key: custom_context_key2, custom_context_value: custom_context_value2 + end + break unless out.empty? + sleep 1 end + assert_equal "File: #{remote_file_name2} has context key: #{custom_context_key2}\n", out end end