Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating big query tables for perf tests - 3 #1450

Merged
merged 64 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from 62 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
a01390d
Fix DiffFiles utility function
gargnitingoogle Sep 13, 2023
7f16488
Copying logs on kokoro artifacts incase of integration test failure. …
Tulsishah Sep 28, 2023
d38a7f1
Upgrading go version from 1.21.0 to 1.21.1 (#1401)
raj-prince Sep 29, 2023
bf09c7c
Updating semantics docs (#1407)
raj-prince Sep 29, 2023
241e4c1
Print stack-trace on crash
gargnitingoogle Sep 14, 2023
14736a2
Throw error in case of unexpected fields (#1416)
sethiay Oct 4, 2023
f11347a
Upgraded the fuse library (#1419)
raj-prince Oct 4, 2023
5fba84e
add "create-empty-file: true" tests to run_tests_mounted_directory.sh…
ashmeenkaur Oct 5, 2023
7448f21
Upgrade golang from 1.21.1 to 1.21.2 (#1431)
gargnitingoogle Oct 12, 2023
0ae1b1f
Update yaml package version from v2 to v3 in integration tests (#1434)
ashmeenkaur Oct 12, 2023
1a5db44
Passing gcsfuse flags from build.sh to mount the test bucket for perf…
Tulsishah Oct 13, 2023
8ac2103
adding big query table setup
Tulsishah Oct 17, 2023
7a7afbd
changes for small pr
Tulsishah Oct 17, 2023
ebb0d61
adding requirements and setup scripts
Tulsishah Oct 17, 2023
cd50167
indentation fix
Tulsishah Oct 18, 2023
5e988ea
removing unnecessary changes
Tulsishah Oct 18, 2023
62d439b
adding start build time
Tulsishah Oct 18, 2023
caab8cb
adding requirements and setup scripts
Tulsishah Oct 17, 2023
2953cb7
python file changes
Tulsishah Oct 18, 2023
1f9d7d4
small fix
Tulsishah Oct 18, 2023
59d321d
testing
Tulsishah Oct 18, 2023
bc02e85
testing gsheet upload
Tulsishah Oct 18, 2023
628e303
perfmetrics/scripts/ls_metrics/listing_benchmark.py
Tulsishah Oct 18, 2023
1f7f219
testing
Tulsishah Oct 18, 2023
7bbf477
removing unnecessary changes
Tulsishah Oct 18, 2023
791ba58
Creating big query tables for perf tests - 1 (#1444)
Tulsishah Oct 19, 2023
5587485
Merge branch 'nov_2023_release' into create_big_query_tables_2
Tulsishah Oct 19, 2023
53ee6be
changes for small pr
Tulsishah Oct 17, 2023
9b5753b
indentation fix
Tulsishah Oct 18, 2023
47cef50
removing unnecessary changes
Tulsishah Oct 18, 2023
d9fbbdf
adding requirements and setup scripts
Tulsishah Oct 17, 2023
7bee459
merge with parent
Tulsishah Oct 19, 2023
4d5861f
testing
Tulsishah Oct 18, 2023
c503213
testing gsheet upload
Tulsishah Oct 18, 2023
c4c415e
merge with parent
Tulsishah Oct 19, 2023
b9a7d2d
removing unnecessary changes
Tulsishah Oct 18, 2023
1fb946b
merge
Tulsishah Oct 19, 2023
618c570
fixing requirements.in
Tulsishah Oct 19, 2023
1629dd2
merge with parent
Tulsishah Oct 19, 2023
157af46
Creating big query tables for perf tests - 2 (#1445)
Tulsishah Oct 19, 2023
826634d
merge
Tulsishah Oct 19, 2023
60c5654
merge
Tulsishah Oct 19, 2023
e219dc0
Merge branch 'nov_2023_release' into create_big_query_tables_3
Tulsishah Oct 19, 2023
5d893e9
small fixes
Tulsishah Oct 20, 2023
0e648bf
small fixes
Tulsishah Oct 20, 2023
e2a999e
small fix
Tulsishah Oct 20, 2023
d7305a2
undo testing changes
Tulsishah Oct 20, 2023
da0b7ab
formating
Tulsishah Oct 20, 2023
2f1b768
testing changes
Tulsishah Oct 20, 2023
31c45df
undo testing changes
Tulsishah Oct 20, 2023
41e62b1
remove unnecessary functions
Tulsishah Oct 20, 2023
f743ad2
fixing indentation
Tulsishah Oct 20, 2023
6b324af
small fix
Tulsishah Oct 20, 2023
cbb88c7
Merge branch 'master' into create_big_query_tables_3
Tulsishah Oct 26, 2023
f7de439
adding testing changes
Tulsishah Oct 26, 2023
93166fa
small fix
Tulsishah Oct 26, 2023
3497883
undo testing changes
Tulsishah Oct 26, 2023
fb9f165
formating
Tulsishah Oct 26, 2023
794118b
fixing unit tests
Tulsishah Oct 26, 2023
cd03358
formatting
Tulsishah Oct 26, 2023
fbdad0d
merge with master
Tulsishah Oct 27, 2023
c26b6cc
merge with master
Tulsishah Oct 27, 2023
6e4a05e
fixing commets and adding test changes
Tulsishah Oct 30, 2023
48367ad
undo testing changes
Tulsishah Oct 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions perfmetrics/scripts/bigquery/experiments_gcsfuse_bq.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ def setup_dataset_and_tables(self):
CREATE TABLE IF NOT EXISTS {}.{}.{}(
configuration_id STRING,
start_time_build INT64,
mount_type STRING,
Tulsishah marked this conversation as resolved.
Show resolved Hide resolved
test_description string,
command STRING,
num_files INT64,
Expand Down
3 changes: 3 additions & 0 deletions perfmetrics/scripts/continuous_test/gcp_ubuntu/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ chmod +x perfmetrics/scripts/build_and_install_gcsfuse.sh
# Mounting gcs bucket
cd "./perfmetrics/scripts/"

echo Installing requirements..
Tulsishah marked this conversation as resolved.
Show resolved Hide resolved
pip install --require-hashes -r bigquery/requirements.txt --user

# Upload data to the gsheet only when it runs through kokoro.
UPLOAD_FLAGS=""
if [ "${KOKORO_JOB_TYPE}" == "RELEASE" ] || [ "${KOKORO_JOB_TYPE}" == "CONTINUOUS_INTEGRATION" ] || [ "${KOKORO_JOB_TYPE}" == "PRESUBMIT_GITHUB" ];
Expand Down
58 changes: 54 additions & 4 deletions perfmetrics/scripts/fetch_metrics.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2023 Google Inc. All Rights Reserved.
#
# 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.

"""Executes fio_metrics.py and vm_metrics.py by passing appropriate arguments.
"""
import socket
Expand All @@ -7,6 +21,8 @@
from fio import fio_metrics
from vm_metrics import vm_metrics
from gsheet import gsheet
from bigquery import constants
from bigquery import experiments_gcsfuse_bq

INSTANCE = socket.gethostname()
PERIOD_SEC = 120
Expand Down Expand Up @@ -40,6 +56,27 @@ def _parse_arguments(argv):
default=False,
required=False,
)
parser.add_argument(
'--upload_bq',
help='Upload the results to the BigQuery.',
action='store_true',
default=False,
required=False,
)
parser.add_argument(
'--config_id',
help='Configuration ID of the experiment.',
action='store',
nargs=1,
required=False,
)
parser.add_argument(
'--start_time_build',
help='Start time of the build.',
action='store',
nargs=1,
required=False,
)
return parser.parse_args(argv[1:])


Expand All @@ -51,15 +88,22 @@ def _parse_arguments(argv):

args = _parse_arguments(argv)

temp = fio_metrics_obj.get_metrics(args.fio_json_output_path)
metrics_data = fio_metrics_obj.get_values_to_upload(temp)

if args.upload_gs:
temp = fio_metrics_obj.get_metrics(args.fio_json_output_path, FIO_WORKSHEET_NAME)
else:
temp = fio_metrics_obj.get_metrics(args.fio_json_output_path)
gsheet.write_to_google_sheet(FIO_WORKSHEET_NAME,metrics_data)

if args.upload_bq:
if not args.config_id or not args.start_time_build:
raise Exception("Pass required arguments experiments configuration ID and start time of build for uploading to BigQuery")
bigquery_obj = experiments_gcsfuse_bq.ExperimentsGCSFuseBQ(constants.PROJECT_ID, constants.DATASET_ID)
fio_metrics_obj.upload_metrics_to_bigquery(metrics_data, args.config_id[0], args.start_time_build[0], constants.FIO_TABLE_ID)
Tulsishah marked this conversation as resolved.
Show resolved Hide resolved

print('Waiting for 360 seconds for metrics to be updated on VM...')
# It takes up to 240 seconds for sampled data to be visible on the VM metrics graph
# So, waiting for 360 seconds to ensure the returned metrics are not empty.
# Intermittenly custom metrics are not available after 240 seconds, hence
# Intermittently custom metrics are not available after 240 seconds, hence
# waiting for 360 secs instead of 240 secs
time.sleep(360)

Expand Down Expand Up @@ -96,3 +140,9 @@ def _parse_arguments(argv):

if args.upload_gs:
gsheet.write_to_google_sheet(VM_WORKSHEET_NAME, vm_metrics_data)

if args.upload_bq:
if not args.config_id or not args.start_time_build:
raise Exception("Pass required arguments experiments configuration ID and start time of build for uploading to BigQuery")
bigquery_obj = experiments_gcsfuse_bq.ExperimentsGCSFuseBQ(constants.PROJECT_ID, constants.DATASET_ID)
bigquery_obj.upload_metrics_to_table(constants.VM_TABLE_ID, args.config_id[0], args.start_time_build[0], vm_metrics_data)
62 changes: 40 additions & 22 deletions perfmetrics/scripts/fio/fio_metrics.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2023 Google Inc. All Rights Reserved.
#
# 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.

"""Extracts required metrics from fio output file and writes to google sheet.

Takes fio output json filepath as command-line input
Expand All @@ -18,14 +32,17 @@
from fio import constants as consts
from gsheet import gsheet

from bigquery import constants
from bigquery import experiments_gcsfuse_bq


@dataclass(frozen=True)
class JobParam:
"""Dataclass for a FIO job parameter.

name: Can be any suitable value, it refers to the output dictionary key for
the parameter. To be used when creating parameter dict for each job.
json_name: Must match the FIO job specification key. Key for parameter inside
json_name: Must match the FIO job specification key. Key for parameter inside
'global options'/'job options' dictionary
Ex: For output json = {"global options": {"filesize":"50M"}, "jobs": [
"job options": {"rw": "read"}]}
Expand All @@ -48,7 +65,7 @@ class JobParam:
class JobMetric:
"""Dataclass for a FIO job metric.

name: Can be any suitable value, it is used as key for the metric
name: Can be any suitable value, it is used as key for the metric
when creating metric dict for each job
levels: Keys for the metric inside 'read'/'write' dictionary in each job.
Each value in the list must match the key in the FIO output JSON
Expand Down Expand Up @@ -403,12 +420,13 @@ def _extract_metrics(self, fio_out) -> List[Dict[str, Any]]:

return all_jobs

def _add_to_gsheet(self, jobs, worksheet_name):
"""Add the metric values to respective columns in a google sheet.
def get_values_to_upload(self, jobs):
"""Get the metrics values in a list to export to Google Spreadsheet and BigQuery.

Args:
jobs: list of dicts, contains required metrics for each job
worksheet_name: str, worksheet where job metrics should be written.
jobs: List of dicts, contains required metrics for each job
Returns:
list: A 2-d list consisting of metrics values for each job
"""

values = []
Expand All @@ -422,31 +440,32 @@ def _add_to_gsheet(self, jobs, worksheet_name):
for metric_val in job[consts.METRICS].values():
row.append(metric_val)
values.append(row)
return values

gsheet.write_to_google_sheet(worksheet_name, values)

def get_metrics(self,
filepath,
worksheet_name=None) -> List[Dict[str, Any]]:
"""Returns job metrics obtained from given filepath and writes to gsheets.
def get_metrics(self, filepath) -> List[Dict[str, Any]]:
"""Returns job metrics obtained from given filepath.

Args:
filepath : str
Path of the json file to be parsed
worksheet_name: str, optional, default:None
Worksheet where job metrics should be written.
Pass '' or None to skip writing to Google sheets
filepath (str): Path of the json file to be parsed

Returns:
List of dicts, contains list of jobs and required metrics for each job
"""
fio_out = self._load_file_dict(filepath)
job_metrics = self._extract_metrics(fio_out)
if worksheet_name:
self._add_to_gsheet(job_metrics, worksheet_name)

return job_metrics

def upload_metrics_to_bigquery(self, metrics_data, config_id, start_time_build, table_id_bq):
Tulsishah marked this conversation as resolved.
Show resolved Hide resolved
"""Uploads metrics data for load tests to Google Spreadsheets
Args:
metrics_data (list): List of metric values for each job
config_id (str): configuration ID of the experiment
start_time_build (int): Start time of the build
table_id_bq (str): ID of table in BigQuery to which metrics data will be uploaded
"""
bigquery_obj = experiments_gcsfuse_bq.ExperimentsGCSFuseBQ(constants.PROJECT_ID, constants.DATASET_ID)
bigquery_obj.upload_metrics_to_table(table_id_bq, config_id, start_time_build, metrics_data)

if __name__ == '__main__':
argv = sys.argv
if len(argv) != 2:
Expand All @@ -455,6 +474,5 @@ def get_metrics(self,
'python3 -m fio.fio_metrics <fio output json filepath>')

fio_metrics_obj = FioMetrics()
temp = fio_metrics_obj.get_metrics(argv[1], 'fio_metrics_expt')
temp = fio_metrics_obj.get_metrics(argv[1])
print(temp)