Skip to content

Commit

Permalink
move all internal changes external
Browse files Browse the repository at this point in the history
  • Loading branch information
lukewrites committed Dec 15, 2023
1 parent cedba4f commit e1635bc
Show file tree
Hide file tree
Showing 82 changed files with 1,739 additions and 489 deletions.
2 changes: 2 additions & 0 deletions tdvt/tdvt/config/registry/mac_arm.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[DatasourceRegistry]
all = *
2 changes: 1 addition & 1 deletion tdvt/tdvt/config/tdvt/tdvt.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[DEFAULT]
# Replace XXXX.X with the version of Tableau you have installed and wish to test (ie 2021.4)
# Replace XXXX.X with the version of Tablerau you have installed and wish to test (ie 2021.4)
TAB_CLI_EXE_X64 = C:/Program Files/Tableau/Tableau XXXX.X/bin/tabquerytool.exe
TAB_CLI_EXE_MAC = /Applications/Tableau XXXX.X.app/Contents/MacOS/tabquerytool
119 changes: 73 additions & 46 deletions tdvt/tdvt/config_gen/datasource_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ def print_configurations(ds_reg, dsname, verbose):
print_ds(ds, ds_reg)



def get_password_file(config):
return config.get('PasswordFile', '')

Expand Down Expand Up @@ -183,11 +182,12 @@ def load_test(config, test_dir=get_root_dir()):
run_time_config.set_tabquery_paths(
dsconfig.get('TabQueryPathLinux', ''),
dsconfig.get('TabQueryPathMac', ''),
dsconfig.get('TabQueryPathMacArm', ''),
dsconfig.get('TabQueryPathx64', '')
)
test_config = TestConfig(config_name, dsconfig['LogicalQueryFormat'], run_time_config)


logging.info("Loading test config for datasource: " + config_name)
# Add the standard test suites.
if standard_tests in config.sections():
try:
Expand All @@ -207,8 +207,9 @@ def load_test(config, test_dir=get_root_dir()):
get_expression_test_dir_path(standard, 'exprtests/standard/'),
test_dir, get_password_file(standard), get_expected_message(standard),
get_is_smoke_test(standard), get_is_test_enabled(standard), False)
logging.info("\tAdded standard tests.")
except KeyError as e:
logging.debug(e)
logging.error(e)
pass

# Add the optional LOD tests.
Expand All @@ -224,74 +225,83 @@ def load_test(config, test_dir=get_root_dir()):
get_expression_test_dir_path(lod, 'exprtests/lodcalcs/'), test_dir,
get_password_file(lod), get_expected_message(lod), get_is_smoke_test(lod),
get_is_test_enabled(lod), False)
logging.info("\tAdded LOD tests.")
except KeyError as e:
logging.debug(e)
logging.error(e)
pass

# Add the optional Staples data check test.
if staples_data_test in config.sections():
try:
staples_data = config[staples_data_test]
all_ini_sections.remove(staples_data_test)
test_config.add_expression_test('expression.staples.', STAPLES_TDS, '',
get_expression_test_dir_path(staples_data, 'exprtests/staples/'),
test_dir, get_password_file(staples_data),
get_expected_message(staples_data), get_is_smoke_test(staples_data),
get_is_test_enabled(staples_data), False)
test_config.add_expression_test(
'expression.staples.', STAPLES_TDS, '', get_expression_test_dir_path(staples_data, 'exprtests/staples/'),
test_dir, get_password_file(staples_data), get_expected_message(staples_data),
get_is_smoke_test(staples_data), get_is_test_enabled(staples_data), False
)
logging.info("\tAdded Staples data check test.")
except KeyError as e:
logging.debug(e)
logging.error(e)
pass

# Add the optional Union test.
if union_test in config.sections():
try:
union = config[union_test]
all_ini_sections.remove(union_test)
test_config.add_logical_test('logical.union.', CALCS_TDS, '',
test_config.get_logical_test_path('logicaltests/setup/union/setup.*.'),
test_dir, get_password_file(union), get_expected_message(union),
get_is_smoke_test(union), get_is_test_enabled(union), False)
test_config.add_logical_test(
'logical.union.', CALCS_TDS, '',
test_config.get_logical_test_path('logicaltests/setup/union/setup.*.'), test_dir,
get_password_file(union), get_expected_message(union), get_is_smoke_test(union),
get_is_test_enabled(union), False
)
logging.info("\tAdded Union tests.")
except KeyError as e:
logging.debug(e)
logging.error(e)
pass

# Add the optional Regex test.
if regex_test in config.sections():
try:
regex = config[regex_test]
all_ini_sections.remove(regex_test)
test_config.add_expression_test('expression.regex.', CALCS_TDS, regex.get(KEY_EXCLUSIONS, ''),
get_expression_test_dir_path(regex, 'exprtests/regexcalcs/'), test_dir,
get_password_file(regex), get_expected_message(regex),
get_is_smoke_test(regex), get_is_test_enabled(regex), False)
test_config.add_expression_test(
'expression.regex.', CALCS_TDS, regex.get(KEY_EXCLUSIONS, ''),
get_expression_test_dir_path(regex, 'exprtests/regexcalcs/'), test_dir, get_password_file(regex),
get_expected_message(regex), get_is_smoke_test(regex), get_is_test_enabled(regex), False)
logging.info("\tAdded Regex tests.")
except KeyError as e:
logging.debug(e)
logging.error(e)
pass

# Add the optional Median test.
if median_test in config.sections():
try:
median = config[median_test]
all_ini_sections.remove(median_test)
test_config.add_expression_test('expression.median.', CALCS_TDS, median.get(KEY_EXCLUSIONS, ''),
get_expression_test_dir_path(median, 'exprtests/median/'), test_dir,
get_password_file(median), get_expected_message(median),
get_is_smoke_test(median), get_is_test_enabled(median), False)
test_config.add_expression_test(
'expression.median.', CALCS_TDS, median.get(KEY_EXCLUSIONS, ''),
get_expression_test_dir_path(median, 'exprtests/median/'), test_dir,
get_password_file(median), get_expected_message(median),
get_is_smoke_test(median), get_is_test_enabled(median), False)
logging.info("\tAdded Median tests.")
except KeyError as e:
logging.debug(e)
logging.error(e)
pass

# Add the optional Percentile test.
if percentile_test in config.sections():
try:
percentile = config[percentile_test]
all_ini_sections.remove(percentile_test)
test_config.add_expression_test('expression.percentile.', CALCS_TDS, percentile.get(KEY_EXCLUSIONS, ''),
'exprtests/percentile', test_dir, get_password_file(percentile),
get_expected_message(percentile), get_is_smoke_test(percentile),
get_is_test_enabled(percentile), False)
test_config.add_expression_test(
'expression.percentile.', CALCS_TDS, percentile.get(KEY_EXCLUSIONS, ''),
'exprtests/percentile', test_dir, get_password_file(percentile), get_expected_message(percentile),
get_is_smoke_test(percentile), get_is_test_enabled(percentile), False)
logging.info("\tAdded Percentile tests.")
except KeyError as e:
logging.debug(e)
logging.error(e)
pass

# Optional logical config settings.
Expand All @@ -308,8 +318,9 @@ def load_test(config, test_dir=get_root_dir()):
else:
cfg_data[name][k] = cfg[k]
test_config.add_logical_config(cfg_data)
logging.info("\tAdded logical config settings.")
except KeyError as e:
logging.debug(e)
logging.error(e)
pass

# This is for custom tables with custom schema
Expand All @@ -336,12 +347,13 @@ def load_test(config, test_dir=get_root_dir()):
if new_expression_test in section or sect.get('Type', '') == 'expression':
try:
all_ini_sections.remove(section)
test_config.add_expression_test(sect.get('Name', ''), tds_name, sect.get(KEY_EXCLUSIONS, ''),
sect.get('TestPath', ''), test_dir, get_password_file(sect),
get_expected_message(sect), get_is_smoke_test(sect),
get_is_test_enabled(sect), False)
test_config.add_expression_test(
sect.get('Name', ''), tds_name, sect.get(KEY_EXCLUSIONS, ''), sect.get('TestPath', ''), test_dir,
get_password_file(sect), get_expected_message(sect), get_is_smoke_test(sect),
get_is_test_enabled(sect), False)
logging.info("\tAdded extra expression test: " + sect.get('Name', ''))
except KeyError as e:
logging.debug(e)
logging.error(e)
pass

# Add any extra logical tests.
Expand All @@ -352,29 +364,34 @@ def load_test(config, test_dir=get_root_dir()):
sect.get('TestPath', ''), test_dir, get_password_file(sect),
get_expected_message(sect), get_is_smoke_test(sect),
get_is_test_enabled(sect), False)
logging.info("\tAdded extra logical test: " + sect.get('Name', ''))
except KeyError as e:
logging.debug(e)
logging.error(e)
pass
# Add smoke tests
elif connection_test in section:
try:
all_ini_sections.remove(section)
test_config.add_logical_test('StaplesConnectionTest', STAPLES_TDS, sect.get(KEY_EXCLUSIONS, ''),
test_config.get_logical_test_path('logicaltests/setup/connection_test/setup.staples.*.'), # noqa: E501
test_config.get_logical_test_path(
'logicaltests/setup/connection_test/setup.staples.*.'), # noqa: E501
test_dir, get_password_file(sect), get_expected_message(sect), True,
get_is_test_enabled(sect, 'StaplesTestEnabled'), False)
test_config.add_expression_test('CastCalcsConnectionTest', CALCS_TDS, sect.get(KEY_EXCLUSIONS, ''),
get_expression_test_dir_path(sect, 'exprtests/pretest/connection_tests/calcs/'), # noqa: E501
get_expression_test_dir_path(sect,
'exprtests/pretest/connection_tests/calcs/'),
# noqa: E501
test_dir, get_password_file(sect), get_expected_message(sect), True,
get_is_test_enabled(sect, 'CastCalcsTestEnabled'), False)
logging.info("\tAdded connection tests.")
except KeyError as e:
logging.debug(e)
logging.error(e)
pass

if all_ini_sections:
logging.debug("Found unparsed sections in the ini file.")
logging.error("Found unparsed sections in the ini file.")
for section in all_ini_sections:
logging.debug("Unparsed section: {0}".format(section))
logging.error("Unparsed section: {0}".format(section))

logging.debug(test_config)
return test_config
Expand All @@ -390,14 +407,14 @@ def __init__(self, ini_file):
# Read all the datasource ini files and load the test configuration.
ini_files = get_all_ini_files_local_first('config')
for f in ini_files:
logging.debug("Reading ini file [{}]".format(f))
logging.info("Reading ini file [{}]".format(f))
config = configparser.ConfigParser()
# Preserve the case of elements.
config.optionxform = str
try:
config.read(f)
except configparser.ParsingError as e:
logging.debug(e)
logging.error(e)
continue

self.add_test(load_test(config))
Expand All @@ -407,7 +424,7 @@ def __init__(self, ini_file):
def load_ini_file(self, ini_file):
# Create the test suites (groups of datasources to test)
registry_ini_file = get_ini_path_local_first('config/registry', ini_file)
logging.debug("Reading registry ini file [{}]".format(registry_ini_file))
logging.info("Reading registry ini file [{}]".format(registry_ini_file))
self.load_registry(registry_ini_file)

def load_registry(self, registry_ini_file):
Expand All @@ -417,7 +434,10 @@ def load_registry(self, registry_ini_file):
ds = config['DatasourceRegistry']

for suite_name in ds:
self.suite_map[suite_name] = [x.strip() for x in self.interpret_ds_list(ds[suite_name], False).split(',')]
self.suite_map[suite_name] = [
x.strip() for x in
self.interpret_ds_list(ds[suite_name], False).split(',')
]

except KeyError:
# Create a simple default.
Expand Down Expand Up @@ -466,6 +486,13 @@ def __init__(self):
super(MacRegistry, self).__init__('mac')


class MacArmRegistry(TestRegistry):
"""Mac ARM specific test suites."""

def __init__(self):
super(MacArmRegistry, self).__init__('mac_arm')


class LinuxRegistry(TestRegistry):
"""Linux specific test suites."""

Expand Down
15 changes: 8 additions & 7 deletions tdvt/tdvt/config_gen/gentests.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@
import os
import re
import shutil

from string import Template
from typing import Dict, List, Tuple

from .templates import template_attributes
from ..constants import CALCS_FIELDS, STAPLES_FIELDS


debug = False
from .templates import *



def get_logical_config_templates(ds_registry):
Expand Down Expand Up @@ -129,22 +131,21 @@ def get_modified_line(line, attrs, fields, field_name_map):
new_line = new_line.replace('$Staples$', staples_table_name)
return new_line



def process_test_file(filename, ds_registry, output_dir, col_names: List[List[str]]):
if debug:
print("Processing " + filename)
logging.debug("Processing " + filename)

input_file = open(filename, 'r', encoding='utf-8')
base_name = os.path.basename(filename)
if debug:
print("base_name " + base_name)
logging.debug("base_name " + base_name)
match = re.search('setup\.(.*)\.xml', base_name)
if match:
test_name = match.group(1)
else:
test_name = os.path.splitext(base_name)[0]

if debug:
print("Test " + test_name)
logging.debug("Test " + test_name)

fields = []
for table in col_names:
Expand Down
11 changes: 8 additions & 3 deletions tdvt/tdvt/config_gen/tdvtconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def __init__(self, from_args=None, from_json=None, test_config: TestConfig = Non
self.iteration: int = 0
self.generate_expected = False
self.schema_name: Optional[str] = None
self.loose_comparison = False

if from_args:
self.init_from_args(from_args)
Expand Down Expand Up @@ -71,6 +72,8 @@ def init_from_args(self, args):
self.iteration = args.perf_iteration
if args.generate_expected:
self.generate_expected = True
if args.loose_comparison:
self.loose_comparison = True


def init_from_json(self, json):
Expand All @@ -90,12 +93,13 @@ def init_from_json(self, json):
rtt.set_tabquery_path_from_array(self.tabquery_path)
self.tested_run_time_config = rtt
self.thread_count = json.get('thread_count', self.thread_count)
self.loose_comparison = json.get('loose_comparison', self.loose_comparison)

def __str__(self):
return ("suite [{}]: tested sql [{}]: tested tuples [{}]: tested error [{}]: output dir [{}]: " +
"logical [{}]: config file [{}]: override [{}]: tds [{}]: thread [{}]").format(
"logical [{}]: config file [{}]: override [{}]: tds [{}]: thread [{}], loose comparison [{}]").format(
self.suite_name, self.tested_sql, self.tested_tuples, self.tested_error, self.output_dir,
self.logical, self.config_file, self.d_override, self.tds, self.thread_count)
self.logical, self.config_file, self.d_override, self.tds, self.thread_count, self.loose_comparison)

def __json__(self):
return {
Expand All @@ -111,7 +115,8 @@ def __json__(self):
'tds': self.tds,
'noheader': self.noheader,
'tabquery_path': self.tabquery_path,
'thread_count': self.thread_count}
'thread_count': self.thread_count,
'loose_comparison': self.loose_comparison}

def __eq__(self, other):
if isinstance(other, self.__class__):
Expand Down
Loading

0 comments on commit e1635bc

Please sign in to comment.