Support adding custom target objectives to the website/db/*/target_objective.py modules

This commit is contained in:
Dana Van Aken
2019-10-08 19:26:38 -04:00
parent f68c23e975
commit 01b4ec3f53
18 changed files with 304 additions and 203 deletions

View File

@@ -7,8 +7,7 @@
from abc import ABCMeta, abstractmethod
import mock
from django.test import TestCase
from website.db import parser
# from website.db.parser.postgres import PostgresParser
from website.db import parser, target_objectives
from website.types import BooleanType, DBMSType, VarType, KnobUnitType, MetricType
from website.models import DBMSCatalog, KnobCatalog
@@ -254,18 +253,23 @@ class PostgresParserTests(BaseParserTests, TestCase):
def test_convert_dbms_metrics(self):
super().test_convert_dbms_metrics()
target_obj = target_objectives.THROUGHPUT
target_obj_instance = target_objectives.get_target_objective_instance(
self.test_dbms.dbms_id, target_obj)
txns_counter = target_obj_instance.transactions_counter
test_metrics = {}
for key in list(self.test_dbms.numeric_metric_catalog_.keys()):
test_metrics[key] = 2
test_metrics['pg_stat_database.xact_commit'] = 10
test_metrics[txns_counter] = 10
test_metrics['pg_FAKE_METRIC'] = 0
self.assertEqual(test_metrics.get('throughput_txn_per_sec'), None)
self.assertEqual(test_metrics.get(target_obj), None)
test_convert_metrics = self.test_dbms.convert_dbms_metrics(test_metrics, 0.1)
test_convert_metrics = self.test_dbms.convert_dbms_metrics(test_metrics, 0.1, target_obj)
for key, metadata in list(self.test_dbms.numeric_metric_catalog_.items()):
if (key == self.test_dbms.transactions_counter):
if key == txns_counter:
self.assertEqual(test_convert_metrics[key], 10 / 0.1)
continue
if metadata.metric_type == MetricType.COUNTER:
@@ -273,12 +277,9 @@ class PostgresParserTests(BaseParserTests, TestCase):
else: # MetricType.STATISTICS
self.assertEqual(test_convert_metrics[key], 2)
self.assertEqual(test_convert_metrics['throughput_txn_per_sec'], 100)
self.assertEqual(test_convert_metrics[target_obj], 100)
self.assertEqual(test_convert_metrics.get('pg_FAKE_METRIC'), None)
def test_properties(self):
self.assertEqual(self.test_dbms.transactions_counter, 'pg_stat_database.xact_commit')
def test_parse_version_string(self):
self.assertTrue(self.test_dbms.parse_version_string("9.6.1"), "9.6")
self.assertTrue(self.test_dbms.parse_version_string("9.6.3"), "9.6")

View File

@@ -14,6 +14,7 @@ from django.core.urlresolvers import reverse
from django.test import TestCase
from .utils import (TEST_BASIC_SESSION_ID, TEST_PASSWORD, TEST_PROJECT_ID, TEST_USERNAME)
from website.db import target_objectives
class UserAuthViewTests(TestCase):
@@ -142,6 +143,7 @@ class SessionViewsTests(TestCase):
'name': 'test_create_basic_session',
'description': 'testing create basic session...',
'tuning_session': 'no_tuning_session',
'target_objective': target_objectives.get_default_target_objective(),
'algorithm': 1,
'cpu': '2',
'memory': '16',