Exemplo n.º 1
0
def test_verify():
    log = core_logging.init()
    hnd = ListHandler()
    log.addHandler(hnd)
    assert core_logging.verify(hnd)
    log.info("message")
    assert core_logging.verify(hnd)
    assert not core_logging.verify(["this should fail"])
Exemplo n.º 2
0
def test_init():
    core_logging.init()
    logging.info("no tags")
    core_logging.init("test")
    logging.info("one tag")
    core_logging.init("test", "another test")
    logging.info("two tags")
Exemplo n.º 3
0
def test_record():
    record = core_logging.SkaLogRecord()
    assert str(record) == core_logging.DELIMITER * 7

    log = core_logging.init()
    hnd = ListHandler()
    log.addHandler(hnd)
    assert len(hnd.list) == 0
    log.info("info message")
    assert len(hnd.list) == 1
    log.debug("debug message")
    assert len(hnd.list) == 1

    record = core_logging.SkaLogRecord.from_string(hnd.list[0])
    assert str(record) == hnd.list[0]
    assert record.version == core_logging.VERSION
    assert record.msg == "info message"
    assert record.severity == 'INFO'
    assert record.tags[0] == 'test'
Exemplo n.º 4
0
import jsonschema
import ska_sdp_config
from ska_sdp_logging import core_logging

LOG_LEVEL = os.getenv('SDP_LOG_LEVEL', 'DEBUG')
WORKFLOWS_URL = os.getenv(
    'SDP_WORKFLOWS_URL',
    'https://gitlab.com/ska-telescope/sdp-prototype/raw/master/src/workflows/workflows.json'
)
WORKFLOWS_REFRESH = int(os.getenv('SDP_WORKFLOWS_REFRESH', '300'))

# Location of the schema file for validating the workflow definitions.

WORKFLOWS_SCHEMA = 'workflows_schema.json'

LOG = core_logging.init(name='processing_controller', level=LOG_LEVEL)


def get_environment_variables(var: list) -> dict:
    """Get values of environment variables and store them in a suitable
    form for passing to the workflow Helm chart.
    """
    values = {}
    for v in var:
        values['env.{}'.format(v)] = os.environ[v]
    return values


def update_workflow_definition(definition_url, schema_file):
    """Update workflow definitions."""
Exemplo n.º 5
0
# Load environment
HELM = shutil.which(os.getenv('SDP_HELM', 'helm'))
HELM_TIMEOUT = int(os.getenv('SDP_HELM_TIMEOUT', str(300)))
HELM_REPO = os.getenv('SDP_HELM_REPO')
HELM_REPO_CA = os.getenv('SDP_HELM_REPO_CA')
NAMESPACE = os.getenv('SDP_HELM_NAMESPACE', 'sdp')
LOG_LEVEL = os.getenv('SDP_LOG_LEVEL', 'DEBUG')

GIT = shutil.which(os.getenv("SDP_GIT", 'git'))
CHART_REPO = os.getenv('SDP_CHART_REPO', 'https://gitlab.com/ska-telescope/sdp-prototype.git')
CHART_REPO_REF = os.getenv('SDP_CHART_REPO_REF', 'master')
CHART_REPO_PATH = os.getenv('SDP_CHART_REPO_PATH', 'src/helm_deploy/charts')
CHART_REPO_REFRESH = int(os.getenv('SDP_CHART_REFRESH', '300'))

# Initialise logger
log = core_logging.init(name='helm_deploy', level=LOG_LEVEL)

# Where we are going to check out the charts
chart_base_path = 'chart-repo'
chart_path = os.path.join(chart_base_path, CHART_REPO_PATH)


def invoke(*cmd_line, cwd):
    """Invoke a command with the given command-line arguments

    :param cwd: Directory to run command in
    :returns: Output of the command
    :raises: `subprocess.CalledProcessError` if command returns an error status
    """
    # Perform call
    log.debug(" ".join(["$"] + list(cmd_line)))