This repository has been archived by the owner on Feb 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 503
Add Sqlancer Test Type and Installation Requirements #1500
Open
dniu16
wants to merge
4
commits into
cmu-db:master
Choose a base branch
from
dniu16:sqlancer_test
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Sqlancer Testing | ||
This folder include the necessary files for running sqlancer testings. | ||
|
||
To run the sqlancer test, in terrier directory, run "PYTHONPATH=.. python3 -m script.testing.sqlancer" | ||
|
||
For detailed information about Sqlancer, go to https://github.com/sqlancer/sqlancer |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import sys | ||
import traceback | ||
|
||
from script.testing.sqlancer.test_sqlancer import TestSqlancer | ||
from ..util.constants import LOG, ErrorCode | ||
from .constants import (SQLANCER_TEST_CMD_ALL, SQLANCER_TEST_CMD_CWD) | ||
from .test_case_sqlancer import TestCaseSqlancer | ||
from .utils import parse_command_line_args | ||
|
||
|
||
def run_test(t_server, test_command, test_command_cwd): | ||
test_case = TestCaseSqlancer(args, test_command=test_command, test_command_cwd=test_command_cwd) | ||
ecode = ErrorCode.ERROR | ||
try: | ||
ecode = t_server.run([test_case]) | ||
except KeyboardInterrupt: | ||
LOG.error("KeyboardInterrupt received. Terminating.") | ||
raise | ||
except Exception as err: | ||
LOG.error(f'Exception trying to run {test_command}') | ||
LOG.error(err) | ||
LOG.error("================ Python Error Output ==================") | ||
traceback.print_exc(file=sys.stdout) | ||
return ecode | ||
|
||
|
||
if __name__ == "__main__": | ||
args = parse_command_line_args() | ||
errcode = 0 | ||
try: | ||
test_server = TestSqlancer(args) | ||
errcode = run_test(test_server, SQLANCER_TEST_CMD_ALL, SQLANCER_TEST_CMD_CWD) | ||
except: | ||
LOG.error("Exception trying to run Sqlancer tests.") | ||
traceback.print_exc(file=sys.stdout) | ||
|
||
# Compute the final exit code. | ||
LOG.info("Final Status => {}".format("FAIL" if errcode else "SUCCESS")) | ||
sys.exit(errcode) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import os | ||
|
||
from ..util.constants import DIR_TMP | ||
|
||
# git settings for sqlancer. | ||
SQLANCER_GIT_URL = "https://github.com/dniu16/sqlancer.git" | ||
SQLANCER_GIT_LOCAL_PATH = os.path.join(DIR_TMP, "sqlancer") | ||
SQLANCER_GIT_CLEAN_COMMAND = "rm -rf {}".format(SQLANCER_GIT_LOCAL_PATH) | ||
SQLANCER_GIT_CLONE_COMMAND = "git clone {} {}".format(SQLANCER_GIT_URL, | ||
SQLANCER_GIT_LOCAL_PATH) | ||
# command to run sqlancer | ||
SQLANCER_TEST_CMD_ALL = "java -jar sqlancer-1.1.0.jar --num-threads 1 --num-tries 10 noisepage --oracle NoREC" | ||
|
||
# directory to run sqlancer in | ||
SQLANCER_TEST_CMD_CWD = os.path.join(SQLANCER_GIT_LOCAL_PATH, "target") | ||
SQLANCER_OUTPUT_FILE = os.path.join(SQLANCER_GIT_LOCAL_PATH, "res.txt") | ||
|
||
# command to build sqlancer | ||
SQLANCER_BUILD_COMMAND = "mvn package -DskipTests" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from ..util.test_case import TestCase | ||
from . import constants | ||
|
||
class TestCaseSqlancer(TestCase): | ||
""" | ||
Class to run Sqlancer tests. | ||
""" | ||
def __init__(self, args, test_command=constants.SQLANCER_TEST_CMD_ALL, test_command_cwd=constants.SQLANCER_TEST_CMD_CWD): | ||
TestCase.__init__(self, args) | ||
self.test_command = test_command | ||
self.test_command_cwd = test_command_cwd | ||
self.test_output_file = self.args.get("db_output_file", constants.SQLANCER_OUTPUT_FILE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from ..util.common import expect_command | ||
from ..util.test_server import TestServer | ||
from . import constants | ||
|
||
|
||
class TestSqlancer(TestServer): | ||
""" | ||
TestSqlancer will build Sqlancer in the pre-suite. | ||
All other behavior is identical to TestServer. | ||
""" | ||
|
||
def __init__(self, args): | ||
super().__init__(args, quiet=False) | ||
|
||
def run_pre_suite(self): | ||
super().run_pre_suite() | ||
if not self.is_dry_run: | ||
self._clean_sqlancer() | ||
self._download_sqlancer() | ||
self._build_sqlancer() | ||
|
||
def _clean_sqlancer(self): | ||
""" | ||
Remove the Sqlancer directory from a hardcoded default location. | ||
Raises an exception if anything goes wrong. | ||
""" | ||
expect_command(constants.SQLANCER_GIT_CLEAN_COMMAND) | ||
|
||
def _download_sqlancer(self): | ||
""" | ||
Clone the Sqlancer directory to a hardcoded default location. | ||
Raises an exception if anything goes wrong. | ||
""" | ||
expect_command(constants.SQLANCER_GIT_CLONE_COMMAND) | ||
|
||
def _build_sqlancer(self): | ||
""" | ||
Build Sqlancer in its hardcoded default location. | ||
Raises an exception if anything goes wrong. | ||
Assumes that _download_sqlancer() has already been run. | ||
""" | ||
expect_command(constants.SQLANCER_BUILD_COMMAND, cwd=constants.SQLANCER_GIT_LOCAL_PATH) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import argparse | ||
|
||
from ..util.constants import PERFORMANCE_STORAGE_SERVICE_API | ||
|
||
|
||
def parse_command_line_args(): | ||
""" | ||
Parse the command line arguments accepted by the OLTPBench module. | ||
""" | ||
|
||
aparser = argparse.ArgumentParser(description="Sqlancer runner") | ||
|
||
aparser.add_argument("--db-host", help="DB Hostname.") | ||
aparser.add_argument("--db-port", type=int, help="DB Port.") | ||
aparser.add_argument("--db-output-file", help="DB output log file.") | ||
aparser.add_argument("--build-type", | ||
default="debug", | ||
choices=["debug", "release", "relwithdebinfo"], | ||
help="Build type (default: %(default)s") | ||
|
||
args = vars(aparser.parse_args()) | ||
|
||
return args |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to https://github.com/cmu-db/sqlancer