Exemplo n.º 1
0
    def mainloop(self):
        if (self.inf_stats):
            s_nstats = "infinite"
        else:
            s_nstats = str(self.num_stats)

        qa_common.log("Collecting %s stats on %i second intervals" %
                      (s_nstats, self.interval))

        i = 0
        start_time = time.time()
        while True:
            qa_common.log("Trying to create an SSH client")
            try:
                with self.create_client() as client:
                    for m in self.__measurement_loop(client, start_time):
                        yield m

                        if (not self.inf_stats):
                            i += 1
                            if (i == self.num_stats):
                                return

            except paramiko.ssh_exception.NoValidConnectionsError:
                qa_common.error("No connection!")
                time.sleep(failed_connection_cooldown)
Exemplo n.º 2
0
def main():
    pidfile_path = os.path.join(qa_common.PLOTFASTER_PID_FILE_DIR,
                                qa_common.PLOTFASTER_PID_FILE_NAME)
    tests = {}
    pids = get_pids(pidfile_path)

    for pid in pids:
        try:
            test_name = get_test_name(pid)
            tests[test_name] = pid

        except NoTestNameError as e:
            qa_common.log(
                "Warning: No pid %i running, removing from pid list" % pid)
            unlist_pid(pidfile_path, pid)

    if (pids == []):
        qa_common.error(errmsg_no_pids)
        return 1

    try:
        pid = ask_which_test(tests)
        os.kill(pid, signal.SIGTERM)
        print("Ended test execution")
        return 0
    except EOFError:
        return 0

    except Exception as e:
        qa_common.error(errmsg_kill_fail % (pid, e))
        return 1
Exemplo n.º 3
0
def exec_stress(create_client, num_procs):
    clients = []
    if (num_procs > 0):
        qa_common.log("Creating %i stress processes" % num_procs)

    for _ in range(num_procs):
        client = create_client()
        client.exec_command(stress_script)
        clients.append(client)
    return clients
Exemplo n.º 4
0
def main():
    parse_args()
    if (not qa_common.test_connection(target_ip, user, passwd)):
        qa_common.error("Couldn't connect to %s" % target_ip)
        sys.exit(1)
    qa_common.log("Injecting credentials from file %s" % cred_file_local)
    inject_credentials(cred_file_local, cred_file_path, cred_file_name)

    dumps = get_coredumps(partition_roots, core_dir)
    packages = get_all_packages(dumps)
    if (len(packages) > 0):
        install_packages(packages)
    else:
        qa_common.log("No packages to be installed!")
Exemplo n.º 5
0
def install_packages(packages):
    qa_common.log("Installing %i debuginfo packages" % len(packages))
    qa_common.log("\n".join(packages))

    # Intended as immutable
    install_cmd_base = [
        "zypper", "--non-interactive", "--no-gpg-checks", "in", "-C"
    ]
    successful = 0
    for package in packages:
        try:
            # Copy the cmd base to be amended instead of modifying
            # the original
            install_cmd = install_cmd_base + [package]
            qa_common.remote_cmd(target_ip,
                                 user,
                                 passwd,
                                 install_cmd,
                                 get_stderr=True)

            successful += 1

        except subprocess.CalledProcessError as e:
            qa_common.log("Error message from remote:\n%s\n" % e.output)

    qa_common.log("Successfully installed %i packages" % successful)
Exemplo n.º 6
0
def main(argv):
    args = qa_common.parse_args(argv, cmdline_args)
    setup_sigterm_handler()
    detach_from_stdin()
    report = None

    # Apparently you cannot reconnect a failed client object, so let
    # reporter create its own clients whenever old one breaks down
    create_client = lambda: qa_common.create_ssh_client(
        args.target_ip, args.username, args.password)
    ofnames = generate_outfile_names(args.target_ip, args.report_path_format,
                                     args.outfile, args.log_to_stdout)

    report_file, qa_common.log_target, report_path, test_name = ofnames
    os.makedirs(report_path, exist_ok=True)
    try:
        stress_clients = exec_stress(create_client, args.stress_procs)

        qa_common.log("Switching to reporter, writing report to %s" %
                      report_file)

        try:
            my_reporter = reporter.Reporter(args.interval, create_client,
                                            args.num_stats, args.rss_threshold)

        except reporter.Reporter.NoConnectionError:
            qa_common.error("No connection to %s" % args.target_ip)
            return 1

        comp = BackupZlibCompressor(report_file)
        for measurement in my_reporter.mainloop():
            bdata = json.dumps(measurement).encode("utf-8") + b"\n"
            report = comp.add_data(bdata)

    # Exit gracefully without puking up a stack trace
    except (KeyboardInterrupt, SystemExit):
        pass

    finally:
        kill_clients(stress_clients)
        if (report is not None):
            qa_common.log("Exporting from %s to path %s" %
                          (report_file, report_path))

            exporter.export(report, report_path)

    return 0
Exemplo n.º 7
0
    def __measurement_loop(self, client, start_time):
        last_stat = start_time
        qa_common.log("Starting to record data")

        while (True):
            measurement = {}
            next_stat = last_stat + self.interval
            if (time.time() > next_stat):
                qa_common.warn(
                    "Gathering data took longer than the stat interval")

            measurement = self.do_measurement(client)
            if (measurement):
                rt = round(time.time() - start_time, 2)
                measurement["runtime"] = rt
                yield measurement
            else:
                qa_common.warn("Measurement failed!")
                return

            while (time.time() < next_stat):
                time.sleep(short_delay)

            last_stat = next_stat
Exemplo n.º 8
0
def get_all_packages(dumps):
    all_packages = []
    qa_common.log("Getting package lists for all core dumps...\n")

    for dump in dumps:
        binary = dump["binary"]
        corefile = dump["corefile"]

        qa_common.log(" " + corefile)
        gdb_output = invoke_gdb(gdb_path, binary, corefile)
        packages = get_package_list(gdb_output)
        all_packages.extend(packages)

    qa_common.log("\ndone.")
    return all_packages
Exemplo n.º 9
0
 def sigterm_handler(_signo, _stack_frame):
     qa_common.log("execute_test caught SIGTERM, exiting")
     raise SystemExit
Exemplo n.º 10
0
def kill_clients(clients):
    if (clients):
        qa_common.log("Killing %i stress processes" % len(clients))
    for client in clients:
        client.close()