Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
d14c0ea1
Commit
d14c0ea1
authored
7 years ago
by
Matt Kwong
Browse files
Options
Downloads
Patches
Plain Diff
Upload Jenkins tests results to a partitioned BQ table
parent
1f7103a4
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tools/gcp/utils/big_query_utils.py
+22
-1
22 additions, 1 deletion
tools/gcp/utils/big_query_utils.py
tools/run_tests/python_utils/upload_test_results.py
+5
-1
5 additions, 1 deletion
tools/run_tests/python_utils/upload_test_results.py
with
27 additions
and
2 deletions
tools/gcp/utils/big_query_utils.py
+
22
−
1
View file @
d14c0ea1
...
@@ -37,6 +37,8 @@ from apiclient import discovery
...
@@ -37,6 +37,8 @@ from apiclient import discovery
from
apiclient.errors
import
HttpError
from
apiclient.errors
import
HttpError
from
oauth2client.client
import
GoogleCredentials
from
oauth2client.client
import
GoogleCredentials
# 30 days in milliseconds
_EXPIRATION_MS
=
30
*
24
*
60
*
60
*
1000
NUM_RETRIES
=
3
NUM_RETRIES
=
3
...
@@ -79,8 +81,21 @@ def create_table(big_query, project_id, dataset_id, table_id, table_schema,
...
@@ -79,8 +81,21 @@ def create_table(big_query, project_id, dataset_id, table_id, table_schema,
fields
,
description
)
fields
,
description
)
def
create_partitioned_table
(
big_query
,
project_id
,
dataset_id
,
table_id
,
table_schema
,
description
,
partition_type
=
'
DAY
'
,
expiration_ms
=
_EXPIRATION_MS
):
"""
Creates a partitioned table. By default, a date-paritioned table is created with
each partition lasting 30 days after it was last modified.
"""
fields
=
[{
'
name
'
:
field_name
,
'
type
'
:
field_type
,
'
description
'
:
field_description
}
for
(
field_name
,
field_type
,
field_description
)
in
table_schema
]
return
create_table2
(
big_query
,
project_id
,
dataset_id
,
table_id
,
fields
,
description
,
partition_type
,
expiration_ms
)
def
create_table2
(
big_query
,
project_id
,
dataset_id
,
table_id
,
fields_schema
,
def
create_table2
(
big_query
,
project_id
,
dataset_id
,
table_id
,
fields_schema
,
description
):
description
,
partition_type
=
None
,
expiration_ms
=
None
):
is_success
=
True
is_success
=
True
body
=
{
body
=
{
...
@@ -95,6 +110,12 @@ def create_table2(big_query, project_id, dataset_id, table_id, fields_schema,
...
@@ -95,6 +110,12 @@ def create_table2(big_query, project_id, dataset_id, table_id, fields_schema,
}
}
}
}
if
partition_type
and
expiration_ms
:
body
[
"
timePartitioning
"
]
=
{
"
type
"
:
partition_type
,
"
expirationMs
"
:
expiration_ms
}
try
:
try
:
table_req
=
big_query
.
tables
().
insert
(
projectId
=
project_id
,
table_req
=
big_query
.
tables
().
insert
(
projectId
=
project_id
,
datasetId
=
dataset_id
,
datasetId
=
dataset_id
,
...
...
This diff is collapsed.
Click to expand it.
tools/run_tests/python_utils/upload_test_results.py
+
5
−
1
View file @
d14c0ea1
...
@@ -45,6 +45,9 @@ import big_query_utils
...
@@ -45,6 +45,9 @@ import big_query_utils
_DATASET_ID
=
'
jenkins_test_results
'
_DATASET_ID
=
'
jenkins_test_results
'
_DESCRIPTION
=
'
Test results from master job run on Jenkins
'
_DESCRIPTION
=
'
Test results from master job run on Jenkins
'
# 90 days in milliseconds
_EXPIRATION_MS
=
90
*
24
*
60
*
60
*
1000
_PARTITION_TYPE
=
'
DAY
'
_PROJECT_ID
=
'
grpc-testing
'
_PROJECT_ID
=
'
grpc-testing
'
_RESULTS_SCHEMA
=
[
_RESULTS_SCHEMA
=
[
(
'
job_name
'
,
'
STRING
'
,
'
Name of Jenkins job
'
),
(
'
job_name
'
,
'
STRING
'
,
'
Name of Jenkins job
'
),
...
@@ -87,7 +90,8 @@ def upload_results_to_bq(resultset, bq_table, args, platform):
...
@@ -87,7 +90,8 @@ def upload_results_to_bq(resultset, bq_table, args, platform):
platform: string name of platform tests were run on
platform: string name of platform tests were run on
"""
"""
bq
=
big_query_utils
.
create_big_query
()
bq
=
big_query_utils
.
create_big_query
()
big_query_utils
.
create_table
(
bq
,
_PROJECT_ID
,
_DATASET_ID
,
bq_table
,
_RESULTS_SCHEMA
,
_DESCRIPTION
)
big_query_utils
.
create_partitioned_table
(
bq
,
_PROJECT_ID
,
_DATASET_ID
,
bq_table
,
_RESULTS_SCHEMA
,
_DESCRIPTION
,
partition_type
=
_PARTITION_TYPE
,
expiration_ms
=
_EXPIRATION_MS
)
for
shortname
,
results
in
six
.
iteritems
(
resultset
):
for
shortname
,
results
in
six
.
iteritems
(
resultset
):
for
result
in
results
:
for
result
in
results
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment