forked from googleapis/google-cloud-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbatch_job_test.rb
More file actions
68 lines (58 loc) · 2.34 KB
/
batch_job_test.rb
File metadata and controls
68 lines (58 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Copyright 2025 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
#
# http://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_relative "helper"
require_relative "../storage_batch_create_job"
require_relative "../storage_batch_delete_job"
require_relative "../storage_batch_cancel_job"
require_relative "../storage_batch_list_jobs"
require_relative "../storage_batch_get_job"
describe "Storage Batch Operations" do
let(:bucket_name) { random_bucket_name }
let(:project_id) { storage_client.project }
let(:file_content) { "some content" }
let(:remote_file_name) { "ruby_file_#{SecureRandom.hex}" }
let(:job_name_prefix) { "projects/#{project_id}/locations/global/jobs/" }
before :all do
bucket = create_bucket_helper bucket_name
bucket.create_file StringIO.new(file_content), remote_file_name
end
after :all do
delete_bucket_helper bucket_name
end
it "handles Storage batch operation lifecycle in sequence" do
job_id = "ruby-sbo-job-#{SecureRandom.hex}"
job_name = "#{job_name_prefix}#{job_id}"
# Create job
assert_output(/Storage Batch Operations job #{job_name} is created./) do
create_job bucket_name: bucket_name, prefix: "ruby_file", job_id: job_id, project_id: project_id
end
# List jobs
assert_output(/Job name: #{job_name} present in the list/) do
list_jobs project_id: project_id
end
# Get job details
assert_output(/Storage Batch Operations job Found - #{job_name}, job_status- /) do
get_job project_id: project_id, job_id: job_id
end
# Cancel job
expected_output_pattern = /Storage Batch Operations job #{job_name} (is canceled|was already completed)\./
assert_output expected_output_pattern do
cancel_job project_id: project_id, job_id: job_id
end
# Delete job
assert_output "The #{job_id} is deleted.\n" do
delete_job project_id: project_id, job_id: job_id
end
end
end