Skip to content

Commit b75b925

Browse files
try refreshing operation status
1 parent fd2cf75 commit b75b925

2 files changed

Lines changed: 98 additions & 2 deletions

File tree

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
require_relative "helper"
16+
require_relative "../storage_control_create_anywhere_cache"
17+
require_relative "../storage_control_list_anywhere_caches"
18+
require_relative "../storage_control_get_anywhere_cache"
19+
require_relative "../storage_control_update_anywhere_cache"
20+
require_relative "../storage_control_pause_anywhere_cache"
21+
require_relative "../storage_control_resume_anywhere_cache"
22+
require_relative "../storage_control_disable_anywhere_cache"
23+
24+
# require 'pry'
25+
26+
describe "Storage Control Anywhere Cache" do
27+
let(:bucket_name) { random_bucket_name }
28+
let(:storage_client) { Google::Cloud::Storage.new }
29+
let(:zone) {'us-east1-b'}
30+
# let(:zone) {@bucket.location}
31+
32+
before :all do
33+
@bucket= storage_client.bucket bucket_name
34+
@bucket = create_bucket_helper bucket_name
35+
end
36+
37+
# after do
38+
# delete_bucket_helper bucket_name
39+
# end
40+
41+
it "create Anywhere cache" do
42+
create_anywhere_cache bucket_name: bucket_name, zone: zone
43+
end
44+
45+
# it "list Anywhere cache" do
46+
# # create_anywhere_cache bucket_name: bucket_name, zone: zone
47+
48+
# out, _err = capture_io do
49+
# list_anywhere_caches bucket_name: bucket_name
50+
# end
51+
52+
# assert_includes out, "#{bucket_name}/anywhereCaches/#{zone}"
53+
# end
54+
55+
# it "Get Anywhere cache" do
56+
# out, _err = capture_io do
57+
# get_anywhere_cache bucket_name: bucket_name, anywhere_cache_id: zone
58+
# end
59+
# assert_includes out, "#{bucket_name}/anywhereCaches/#{zone}"
60+
# end
61+
62+
# it "Pause Anywhere cache" do
63+
# out, _err = capture_io do
64+
# pause_anywhere_cache bucket_name: bucket_name, anywhere_cache_id: zone
65+
# end
66+
# assert_includes out, "#{bucket_name}/anywhereCaches/#{zone} paused"
67+
# end
68+
69+
# it "Resume Anywhere cache" do
70+
# out, _err = capture_io do
71+
# resume_anywhere_cache bucket_name: bucket_name, anywhere_cache_id: zone
72+
# end
73+
# assert_includes out, "#{bucket_name}/anywhereCaches/#{zone} running"
74+
# end
75+
76+
# it "Disable Anywhere cache" do
77+
# out, _err = capture_io do
78+
# disable_anywhere_cache bucket_name: bucket_name, anywhere_cache_id: zone
79+
# end
80+
# assert_includes out, "#{bucket_name}/anywhereCaches/#{zone} disabled"
81+
# end
82+
83+
# it "Update Anywhere cache" do
84+
# out, _err = capture_io do
85+
# update_anywhere_cache bucket_name: bucket_name, anywhere_cache_id: zone
86+
# end
87+
# assert_includes out, "#{bucket_name}/anywhereCaches/#{zone}"
88+
# end
89+
end

google-cloud-storage-control/samples/storage_control_create_anywhere_cache.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,15 @@ def create_anywhere_cache bucket_name:, zone:
3939
# The request creates a new cache in the specified zone.
4040
# The cache is created in the specified bucket.
4141
begin
42-
result = storage_control_client.create_anywhere_cache request
43-
puts "AnywhereCache created - #{result.name}"
42+
operation = storage_control_client.create_anywhere_cache request
43+
44+
puts "********************AnywhereCache operation created - #{operation.name}"
45+
while !operation.done?
46+
sleep 3600 # Wait for 1 hour before checking again
47+
operation.refresh!
48+
end
49+
puts "********************AnywhereCache create operation completed - #{operation.name}"
50+
4451
rescue StandardError => e
4552
puts "Error creating AnywhereCache: #{e.message}"
4653
end

0 commit comments

Comments
 (0)