Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
c4a39f9c
Commit
c4a39f9c
authored
Mar 13, 2022
by
Tiffany Rea
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use Fog Google
parent
d14b5c3f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
32 deletions
+15
-32
qa/Gemfile
qa/Gemfile
+0
-1
qa/Gemfile.lock
qa/Gemfile.lock
+0
-15
qa/qa/tools/test_resources_handler.rb
qa/qa/tools/test_resources_handler.rb
+15
-16
No files found.
qa/Gemfile
View file @
c4a39f9c
...
...
@@ -29,7 +29,6 @@ gem 'influxdb-client', '~> 1.17'
gem
'terminal-table'
,
'~> 3.0.0'
,
require:
false
gem
'slack-notifier'
,
'~> 2.4'
,
require:
false
gem
'fog-google'
,
'~> 1.17'
,
require:
false
gem
'google-cloud-storage'
,
'~> 1.36'
,
require:
false
gem
'confiner'
,
'~> 0.2'
...
...
qa/Gemfile.lock
View file @
c4a39f9c
...
...
@@ -65,8 +65,6 @@ GEM
deprecation_toolkit (1.5.1)
activesupport (>= 4.2)
diff-lcs (1.3)
digest-crc (0.6.4)
rake (>= 12.0.0, < 14.0.0)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
equalizer (0.0.11)
...
...
@@ -152,20 +150,8 @@ GEM
google-apis-core (>= 0.4, < 2.a)
google-apis-storage_v1 (0.9.0)
google-apis-core (>= 0.4, < 2.a)
google-cloud-core (1.6.0)
google-cloud-env (~> 1.0)
google-cloud-errors (~> 1.0)
google-cloud-env (1.5.0)
faraday (>= 0.17.3, < 2.0)
google-cloud-errors (1.2.0)
google-cloud-storage (1.36.1)
addressable (~> 2.8)
digest-crc (~> 0.4)
google-apis-iamcredentials_v1 (~> 0.1)
google-apis-storage_v1 (~> 0.1)
google-cloud-core (~> 1.6)
googleauth (>= 0.16.2, < 2.a)
mini_mime (~> 1.0)
googleauth (1.1.0)
faraday (>= 0.17.3, < 2.0)
jwt (>= 1.4, < 3.0)
...
...
@@ -382,7 +368,6 @@ DEPENDENCIES
faker (~> 2.19, >= 2.19.0)
fog-google (~> 1.17)
gitlab-qa
google-cloud-storage (~> 1.36)
influxdb-client (~> 1.17)
knapsack (~> 4.0)
octokit (~> 4.21)
...
...
qa/qa/tools/test_resources_handler.rb
View file @
c4a39f9c
# frozen_string_literal: true
require
"
google/cloud/storag
e"
require
"
fog/googl
e"
# This script handles resources created during E2E test runs
#
...
...
@@ -67,7 +67,7 @@ module QA
files
.
each
do
|
file
|
file_name
=
"
#{
environment_name
}
/
#{
file
.
split
(
'/'
).
last
}
"
Runtime
::
Logger
.
info
(
"Uploading
#{
file_name
}
..."
)
gcs_
bucket
.
create_file
(
file
,
file_name
)
gcs_
storage
.
put_object
(
BUCKET
,
file_name
,
File
.
read
(
file
)
)
end
puts
"
\n
Done"
...
...
@@ -76,17 +76,20 @@ module QA
# Download files from GCS bucket by environment name
# Delete the files afterward
def
download
(
environment_name
)
files_list
=
gcs_bucket
.
files
(
prefix:
"
#{
environment_name
}
"
)
files_list
=
gcs_storage
.
list_objects
(
BUCKET
,
prefix:
environment_name
).
items
.
each_with_object
([])
do
|
obj
,
arr
|
arr
<<
obj
.
name
end
return
puts
"
\n
Nothing to download!"
if
files_list
.
empty?
files_list
.
each
do
|
file
|
local_path
=
"tmp/
#{
file
.
name
.
split
(
'/'
).
last
}
"
Runtime
::
Logger
.
info
(
"Downloading
#{
file
.
name
}
to
#{
local_path
}
"
)
file
.
download
(
local_path
)
files_list
.
each
do
|
file_name
|
local_path
=
"tmp/
#{
file_name
.
split
(
'/'
).
last
}
"
Runtime
::
Logger
.
info
(
"Downloading
#{
file_name
}
to
#{
local_path
}
"
)
file
=
gcs_storage
.
get_object
(
BUCKET
,
file_name
)
File
.
write
(
local_path
,
file
[
:body
])
Runtime
::
Logger
.
info
(
"Deleting
#{
file
.
name
}
from bucket"
)
file
.
delete
Runtime
::
Logger
.
info
(
"Deleting
#{
file
_
name
}
from bucket"
)
gcs_storage
.
delete_object
(
BUCKET
,
file_name
)
end
puts
"
\n
Done"
...
...
@@ -158,18 +161,14 @@ module QA
end
def
gcs_storage
@gcs_storage
||=
Google
::
Cloud
::
Storag
e
.
new
(
project_id
:
PROJECT
,
credentials:
json_key
@gcs_storage
||=
Fog
::
Storage
::
Googl
e
.
new
(
google_project
:
PROJECT
,
**
(
File
.
exist?
(
json_key
)
?
{
google_json_key_location:
json_key
}
:
{
google_json_key_string:
json_key
})
)
rescue
StandardError
=>
e
abort
(
"
\n
There might be something wrong with the JSON key file - [ERROR]
#{
e
}
"
)
end
def
gcs_bucket
@gcs_bucket
||=
gcs_storage
.
bucket
(
BUCKET
,
skip_lookup:
true
)
end
# Path to GCS service account json key file
# Or the content of the key file as a hash
def
json_key
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment