Esempio n. 1
0
    def __init__(self, config):
        '''
        Constructor
        '''
        self.config = config
        self.directory = os.path.join(self.config.fwroot, "results",
                                      self.config.timestamp)
        try:
            os.makedirs(self.directory)
        except OSError:
            pass
        self.file = os.path.join(self.directory, "results.json")

        self.uuid = str(uuid.uuid4())
        self.name = datetime.now().strftime(self.config.results_name)
        self.environmentDescription = self.config.results_environment
        try:
            self.git = dict()
            self.git['commitId'] = self.__get_git_commit_id()
            self.git['repositoryUrl'] = self.__get_git_repository_url()
            self.git['branchName'] = self.__get_git_branch_name()
        except Exception:
            #Could not read local git repository, which is fine.
            self.git = None
        self.startTime = int(round(time.time() * 1000))
        self.completionTime = None
        self.concurrencyLevels = self.config.concurrency_levels
        self.pipelineConcurrencyLevels = self.config.pipeline_concurrency_levels
        self.queryIntervals = self.config.query_levels
        self.cachedQueryIntervals = self.config.cached_query_levels
        self.frameworks = [
            t.name for t in gather_remaining_tests(self.config, self)
        ]
        self.duration = self.config.duration
        self.rawData = dict()
        self.rawData['json'] = dict()
        self.rawData['db'] = dict()
        self.rawData['query'] = dict()
        self.rawData['fortune'] = dict()
        self.rawData['update'] = dict()
        self.rawData['plaintext'] = dict()
        self.rawData['cached_query'] = dict()
        self.completed = dict()
        self.succeeded = dict()
        self.succeeded['json'] = []
        self.succeeded['db'] = []
        self.succeeded['query'] = []
        self.succeeded['fortune'] = []
        self.succeeded['update'] = []
        self.succeeded['plaintext'] = []
        self.succeeded['cached_query'] = []
        self.failed = dict()
        self.failed['json'] = []
        self.failed['db'] = []
        self.failed['query'] = []
        self.failed['fortune'] = []
        self.failed['update'] = []
        self.failed['plaintext'] = []
        self.failed['cached_query'] = []
        self.verify = dict()
Esempio n. 2
0
    def finish(self):
        '''
        Finishes these results.
        '''
        if not self.config.parse:
            tests = gather_remaining_tests(self.config, self)
            # Normally you don't have to use Fore.BLUE before each line, but
            # Travis-CI seems to reset color codes on newline (see travis-ci/travis-ci#2692)
            # or stream flush, so we have to ensure that the color code is printed repeatedly
            log(
                "Verification Summary", border='=', border_bottom='-', color=Fore.CYAN)
            for test in tests:
                log(Fore.CYAN + "| {!s}".format(test.name))
                if test.name in self.verify.keys():
                    for test_type, result in self.verify[
                            test.name].iteritems():
                        if result.upper() == "PASS":
                            color = Fore.GREEN
                        elif result.upper() == "WARN":
                            color = Fore.YELLOW
                        else:
                            color = Fore.RED
                        log(Fore.CYAN + "|       " + test_type.ljust(13) +
                            ' : ' + color + result.upper())
                else:
                    log(Fore.CYAN + "|      " + Fore.RED +
                        "NO RESULTS (Did framework launch?)")
            log('', border='=', border_bottom='', color=Fore.CYAN)

        log("%sTime to complete: %s seconds" %
            (Style.RESET_ALL, str(int(time.time() - self.config.start_time))))
        log("Results are saved in " + self.directory)
    def run(self):
        '''
        This process involves setting up the client/server machines
        with any necessary change. Then going through each test,
        running their docker build and run, verifying the URLs, and
        running benchmarks against them.
        '''
        # Generate metadata
        self.__run_list_test_metadata()

        # Get a list of all known  tests that we can run.
        all_tests = gather_remaining_tests(self.config, self.results)

        # Run tests
        success = True
        log("Running Tests...", border='=')
        with open(os.path.join(self.results.directory, 'benchmark.log'),
                  'w') as benchmark_log:
            for test in all_tests:
                log("Running Test: %s" % test.name, border='-')
                with self.config.quiet_out.enable():
                    success = self.__run_test(test, benchmark_log) and success
                # Load intermediate result from child process
                self.results.load()

        # Parse results
        if self.config.mode == "benchmark":
            log("Parsing Results ...", border='=')
            self.results.parse(all_tests)

        self.results.set_completion_time()
        self.results.upload()
        self.results.finish()

        return success