Skip to content

Commit 75e7bea

Browse files
ScottLinnncopybara-github
authored andcommitted
code style improvement
PiperOrigin-RevId: 835279942
1 parent 2391eb0 commit 75e7bea

File tree

4 files changed

+31
-15
lines changed

4 files changed

+31
-15
lines changed

perfkitbenchmarker/linux_benchmarks/benchbase_benchmark.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,22 @@
2626
from perfkitbenchmarker import configs
2727
from perfkitbenchmarker import sample
2828
from perfkitbenchmarker.linux_packages import benchbase
29+
# Needed in order to register spec:
30+
from perfkitbenchmarker.providers.aws import aws_aurora_dsql_db # pylint: disable=unused-import
2931

3032
BENCHMARK_NAME: str = 'benchbase'
3133
BENCHMARK_CONFIG: str = """
3234
benchbase:
3335
description: Runs Benchbase benchmark.
3436
relational_db:
35-
cloud: GCP
36-
engine: spanner-postgres
37+
cloud: AWS
38+
engine: aurora-dsql-postgres
3739
db_spec:
3840
GCP:
3941
machine_type: db-n1-standard-16
4042
zone: us-central1-f
4143
AWS:
42-
machine_type: db.m4.4xlarge
4344
zone: us-east-1a
44-
db_disk_spec:
45-
GCP:
46-
disk_size: 2048
47-
disk_type: pd-ssd
48-
AWS: # not actually used by it's a required spec so fill random values
49-
disk_size: 6144
50-
disk_type: gp2
5145
vm_groups:
5246
clients:
5347
vm_spec:

perfkitbenchmarker/providers/aws/aws_aurora_dsql_db.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919
from absl import flags
2020
from absl import logging
2121
from perfkitbenchmarker import errors
22+
from perfkitbenchmarker import relational_db_spec
2223
from perfkitbenchmarker import sql_engine_utils
2324
from perfkitbenchmarker import vm_util
25+
from perfkitbenchmarker.configs import spec
2426
from perfkitbenchmarker.providers.aws import aws_relational_db
2527
from perfkitbenchmarker.providers.aws import util
2628

@@ -40,6 +42,23 @@
4042
sql_engine_utils.AURORA_DSQL_POSTGRES,
4143
]
4244

45+
_NONE_OK = {'default': None, 'none_ok': True}
46+
47+
48+
class AwsAuroraDsqlSpec(relational_db_spec.RelationalDbSpec):
49+
"""Configurable options for AWS Aurora DSQL."""
50+
51+
SERVICE_TYPE = 'aurora-dsql'
52+
db_disk_spec = None
53+
54+
@classmethod
55+
def _GetOptionDecoderConstructions(cls):
56+
result = super()._GetOptionDecoderConstructions()
57+
result.update({
58+
'db_disk_spec': (spec.PerCloudConfigDecoder, _NONE_OK),
59+
})
60+
return result
61+
4362

4463
class AwsAuroraDsqlRelationalDb(aws_relational_db.BaseAwsRelationalDb):
4564
"""Implements the aurora DSQL database for AWS."""
@@ -48,8 +67,8 @@ class AwsAuroraDsqlRelationalDb(aws_relational_db.BaseAwsRelationalDb):
4867
IS_MANAGED = True
4968
ENGINE = _AURORA_DSQL_ENGINES
5069

51-
def __init__(self, relational_db_spec):
52-
super().__init__(relational_db_spec)
70+
def __init__(self, dsql_spec: AwsAuroraDsqlSpec):
71+
super().__init__(dsql_spec)
5372
self.cluster_id = None
5473

5574
# DSQL has different format for tags:
@@ -162,6 +181,8 @@ def GetDefaultEngineVersion(engine) -> str:
162181
return _MAP_ENGINE_TO_DEFAULT_VERSION[engine]
163182

164183
def GetResourceMetadata(self) -> dict[str, Any]:
165-
metadata = super().GetResourceMetadata()
166-
metadata['dsql_cluster_id'] = self.cluster_id
184+
"""Returns useful metadata about the instance."""
185+
metadata = {
186+
'dsql_cluster_id': self.cluster_id,
187+
}
167188
return metadata

perfkitbenchmarker/relational_db_spec.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ def GetRelationalDbSpecClass(engine):
3939
sql_engine_utils.SPANNER_POSTGRES,
4040
]:
4141
return spec.GetSpecClass(RelationalDbSpec, SERVICE_TYPE='spanner')
42+
if engine == sql_engine_utils.AURORA_DSQL_POSTGRES:
43+
return spec.GetSpecClass(RelationalDbSpec, SERVICE_TYPE='aurora-dsql')
4244
return RelationalDbSpec
4345

4446

tests/providers/aws/aws_aurora_dsql_db_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ def CreateMockSpec(self):
6767
'database_name': 'fakedbname',
6868
'database_password': 'fakepassword',
6969
'db_spec': mock.MagicMock(),
70-
'db_disk_spec': mock.MagicMock(disk_type='gp2'),
7170
'enable_freeze_restore': False,
7271
'create_on_restore_error': False,
7372
'delete_on_freeze_error': False,

0 commit comments

Comments
 (0)