Skip to content

Commit

Permalink
Merge pull request #177 from hagertnl/nick-refactor-influxdb-backend
Browse files Browse the repository at this point in the history
Separate the InfluxDB logging into its own class
  • Loading branch information
ddietz89 authored Sep 26, 2024
2 parents 21448c5 + d58a906 commit 816d6a7
Show file tree
Hide file tree
Showing 21 changed files with 1,926 additions and 1,761 deletions.
6 changes: 2 additions & 4 deletions harness/bin/runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def get_main_logger():
"""

PERMITTED_HARNESS_TASKS=('checkout','start','stop','status','influx_log')
PERMITTED_HARNESS_TASKS=('checkout','start','stop','status')
"""
A tuple of the permitted harness tasks.
Expand All @@ -157,7 +157,6 @@ def get_main_logger():
* start - Starts the application-test(s).
* stop - Stops an application-test(s).
* status - Prints to std out the status of the application-test(s).
* influx_log - Log application-test(s) to InfluxDB.
Specifying an unsupported task will result in the harness aborting with
an error.
Expand Down Expand Up @@ -308,8 +307,7 @@ def create_parser():
" 'checkout' - checkout application tests listed in input file\n"
" 'start' - start application tests listed in input file\n"
" 'stop' - stop application tests listed in input file\n"
" 'status' - check status of application tests listed in input file\n"
" 'influx_log' - attempt to log application tests listed in input file to InfluxDB\n")
" 'status' - check status of application tests listed in input file\n")
parser.add_argument('-m', '--mode',
required=False,
help=mode_help,
Expand Down
5 changes: 1 addition & 4 deletions harness/bin/test_harness_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,7 @@ def auto_generated_scripts(harness_config,
jstatus.log_event(status_file.StatusFile.EVENT_CHECK_START)
check_exit_value = mymachine.check_executable()
mymachine.start_report_executable()
influx_reported = mymachine.log_to_influx()
if not influx_reported:
message = f"{messloc} results not logged to InfluxDB."
a_logger.doCriticalLogging(message)
mymachine.log_to_db()
else:
message = f"{messloc} check error, failed to retrieve the job id."
a_logger.doCriticalLogging(message)
Expand Down
395 changes: 97 additions & 298 deletions harness/libraries/apptest.py

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions harness/libraries/input_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ def __init__(self,
runmodetask = ["stop_tests",None,None]
elif modetask == "status":
runmodetask = ["display_tests",None,None]
elif modetask == "influx_log":
runmodetask = ["influx_log",None,None]
else:
runmodetask = None
print("Found invalid task in the command line: ", modetask)
Expand Down
1 change: 0 additions & 1 deletion harness/libraries/regression_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class Harness:
starttest = "start_tests"
stoptest = "stop_tests"
displaystatus = "display_status"
influx_log = "influx_log"
summarize_results = "summarize_results"

# Defines the harness log file name.
Expand Down
1 change: 1 addition & 0 deletions harness/libraries/rgt_database_loggers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__all__ = [ 'rgt_database_logger' ]
108 changes: 108 additions & 0 deletions harness/libraries/rgt_database_loggers/db_backends/base_db.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
#! /usr/bin/env python3

from abc import ABC, abstractmethod, ABCMeta
import os
from datetime import datetime

class BaseDBLogger(ABC):

"""
An abstract base class that implements the database logging interface.
"""
__metaclass__ = ABCMeta

#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
# @
# Special methods @
# @
#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

def __init__(self):
return

#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
# @
# End of special methods @
# @
#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@


#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
# @
# Public methods. @
# @
#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

# The name of the dot-file that disables this backend
@property
@abstractmethod
def disable_file_name(self):
return

# This environment variable name set to 1 disables this backend
@property
@abstractmethod
def disable_envvar_name(self):
return

# The name of the dot-file that indicates successful, completed logging
@property
@abstractmethod
def successful_file_name(self):
return

@property
@abstractmethod
def name(self):
return

@abstractmethod
def send_event(self, event_dict : dict):
return

@abstractmethod
def send_metrics(self, test_info_dict : dict, metrics_dict : dict):
return

@abstractmethod
def send_node_health_results(self, test_info_dict : dict, node_health_dict : dict):
return

@abstractmethod
def send_external_metrics(self, table : str, tags : dict, values : dict, log_time : str):
return

@abstractmethod
def is_alive(self):
return

@abstractmethod
def query(self, query):
return

#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
# @
# End of public methods. @
# @
#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

# Raised when there is an initialization error
class DatabaseInitError(Exception):
""" An exception to indicate a database initialization failure """
def __init__(self, message: str) -> None:
super().__init__(message)
return

# Raised when there is an data error
class DatabaseDataError(Exception):
""" An exception to indicate a problem in the data provided by the harness to log to a database """
def __init__(self, message: str) -> None:
super().__init__(message)
return

# Raised when there is an environment variable-related error
class DatabaseEnvironmentError(Exception):
""" An exception to indicate a problem with the RGT_ environment variables """
def __init__(self, message: str) -> None:
super().__init__(message)
return
Loading

0 comments on commit 816d6a7

Please sign in to comment.