import os
import sys
sys.path.append(sys.path[0] + '/../99_helpers/')
from test_helpers import get_process_output, run_remote_test  # noqa # pylint: disable=import-error
from test_helpers import set_log_length, print_log, print_check, print_crit_check  # noqa # pylint: disable=import-error
from test_helpers import print_test_summary  # noqa # pylint: disable=import-error

# Set the test_log length to 50 chars
set_log_length(50)


def check_hdds_size():
    def get_block_device_size(dev):
        # Get block device size in bytes
        out = get_process_output("lsblk -brno SIZE /dev/{}".format(dev))
        # Convert from bytes to GiB
        return int(out.splitlines()[0]) / (2**30)

    # Get all block devices in fileserver-pool
    out = get_process_output("zpool status -L fileserver-pool")
    out = out[out.find('config:'):out.find('errors:')]
    devs = [l[5:8] for l in out.splitlines() if l.startswith('\t    ')]
    # Check whether we have the right number of them
    print_log("Checking correct number of block devices")
    print_check(len(devs) == 7)
    # Check whether no block device is larger than 2GiB
    print_log("Checking block devices sizes")
    print_check(all(map(lambda x: x <= 2, map(get_block_device_size, devs))))


def check_fileserver_size_mount():
示例#2
0
import sys

sys.path.append(sys.path[0] + '/../99_helpers/')
from test_helpers import get_page, get_process_returncode, Cursor  # noqa # pylint: disable=import-error
from test_helpers import print_log, print_check, run_remote_test  # noqa # pylint: disable=import-error
from test_helpers import set_log_length, print_test_summary  # noqa # pylint: disable=import-error

set_log_length(65)

print_log("Checking testrunner active")
rc = get_process_returncode("systemctl is-active --quiet dash-testrunner")
print_check(rc == 0)

print_log("Checking server active")
rc = get_process_returncode("systemctl is-active --quiet dash-server")
print_check(rc == 0)

print_log("Checking nginx proxy active")
rc = get_process_returncode("systemctl is-active --quiet nginx")
print_check(rc == 0)

print_log("Checking website online")
page = get_page('localhost')
print_check("<title>Status app</title>" in page)

print_log("Checking all tests executed at least once in last hour")
with Cursor() as c:
    sql = ('''select test, vm from run_on where not exists '''
           '''( select * from test_results '''
           '''where test_results.test = run_on.test '''
           '''and test_results.vm = run_on.vm '''
#!/usr/bin/env python3.7

import sys
import pymysql
from os import listdir
from datetime import datetime, timedelta
sys.path.append(sys.path[0] + '/../99_helpers/')
from test_helpers import get_process_returncode, read_config  # noqa # pylint: disable=import-error
from test_helpers import set_log_length, print_log, print_check, print_crit_check  # noqa # pylint: disable=import-error
from test_helpers import print_test_summary  # noqa # pylint: disable=import-error


set_log_length(70)
readonly_user = '******'
readonly_pwd = read_config('database-readonly-pw')
test_db = 'test_db1'
test_table = 'test_table'


def sql_query(c, sql, args=()):
    c.execute(sql, args)
    return [tup[0] for tup in c.fetchall()]


# Get the test_token
if len(sys.argv) == 1 and len(sys.argv[1]) != 48:
    print_log("Test token specified")
    print_crit_check(False)
test_token = sys.argv[1]