Exemple #1
0
    def test_load_test_instance(self):
        team = TeamFactory.create(owner=self.user)
        project = team.add_project("load-test-instace-acc-1", "repo", self.user)
        load_test = LoadTestFactory.create(created_by=team.owner, team=team, project_name=project.name)
        result1 = TestResultFactory.build()
        result2 = TestResultFactory.build()
        load_test.results.append(result1)
        load_test.results.append(result2)
        load_test.save()

        result = self.execute("show", load_test.uuid)
        expected_text = [
            result1.config.title,
            result1.cycles[-1].concurrent_users,
            result1.cycles[-1].request.successful_requests_per_second,
            result1.cycles[-1].request.p95,
            result1.cycles[-1].request.failed_requests,
            result1.uuid,

            result2.config.title,
            result2.cycles[-1].concurrent_users,
            result2.cycles[-1].request.successful_requests_per_second,
            result2.cycles[-1].request.p95,
            result2.cycles[-1].request.failed_requests,
            result2.uuid,
            load_test.uuid,
            load_test.status
        ]

        for expected in expected_text:
            expect(result).to_include(expected)
 def _add_results_for_last(self):
     config = TestConfigurationFactory.build()
     self.load_test.results.append(TestResultFactory.build(config=config))
     self.load_test.results.append(TestResultFactory.build())
     self.load_test.save()
     self.load_test2 = LoadTestFactory.add_to_project(1, user=self.user, team=self.team, project=self.project, status="Finished")
     self.load_test2.results.append(TestResultFactory.build())
     self.load_test2.results.append(TestResultFactory.build(config=config))
     self.load_test2.save()
Exemple #3
0
 def _add_results_for_last(self):
     config = TestConfigurationFactory.build()
     self.load_test.results.append(TestResultFactory.build(config=config))
     self.load_test.results.append(TestResultFactory.build())
     self.load_test.save()
     self.load_test2 = LoadTestFactory.add_to_project(1,
                                                      user=self.user,
                                                      team=self.team,
                                                      project=self.project,
                                                      status="Finished")
     self.load_test2.results.append(TestResultFactory.build())
     self.load_test2.results.append(TestResultFactory.build(config=config))
     self.load_test2.save()
    def test_get_instance_load_test(self):
        result1 = TestResultFactory.build()
        result2 = TestResultFactory.build()
        self.load_test.results.append(result1)
        self.load_test.results.append(result2)
        self.load_test.save()

        url = '/load_tests/%s' % self.load_test.uuid

        response = self.fetch_with_headers(url)
        expect(response.code).to_equal(200)

        obj = response.body
        if isinstance(obj, six.binary_type):
            obj = obj.decode('utf-8')

        obj = loads(obj)

        result1_last_cycle = result1.cycles[-1]
        result2_last_cycle = result2.cycles[-1]

        expect(obj['uuid']).to_equal(str(self.load_test.uuid))
        expect(obj['status']).to_equal(self.load_test.status)
        expect(obj['baseUrl']).to_equal(self.load_test.base_url)
        expect(obj['teamName']).to_equal(self.team.name)
        expect(obj['projectName']).to_equal(self.project.name)
        expect(obj['createdBy']).to_equal(self.user.email)
        expect(obj['repository']).to_equal(self.project.repository)

        expect(obj['results'][0]['uuid']).to_equal(str(result1.uuid))
        expect(obj['results'][0]['concurrent_users']).to_equal(
            result1_last_cycle.concurrent_users)
        expect(obj['results'][0]['title']).to_equal(result1.config.title)
        expect(obj['results'][0]['requests_per_second']).to_equal(
            result1_last_cycle.request.successful_requests_per_second)
        expect(obj['results'][0]['failed_requests']).to_equal(
            result1_last_cycle.request.failed_requests)
        expect(obj['results'][0]['p95']).to_equal(
            result1_last_cycle.request.p95)

        expect(obj['results'][1]['uuid']).to_equal(str(result2.uuid))
        expect(obj['results'][1]['concurrent_users']).to_equal(
            result2_last_cycle.concurrent_users)
        expect(obj['results'][1]['title']).to_equal(result2.config.title)
        expect(obj['results'][1]['requests_per_second']).to_equal(
            result2_last_cycle.request.successful_requests_per_second)
        expect(obj['results'][1]['failed_requests']).to_equal(
            result2_last_cycle.request.failed_requests)
        expect(obj['results'][1]['p95']).to_equal(
            result2_last_cycle.request.p95)
    def test_get_last_result_for_diff(self):
        config = TestConfigurationFactory.build()
        self.load_test.results.append(TestResultFactory.build(config=config))
        self.load_test.results.append(TestResultFactory.build())
        self.load_test.save()
        load_test2 = LoadTestFactory.add_to_project(1, user=self.user, team=self.team, project=self.project, status="Finished")
        load_test2.results.append(TestResultFactory.build())
        load_test2.results.append(TestResultFactory.build(config=config))
        load_test2.save()

        result1 = self.load_test.results[0]
        result2 = load_test2.results[1]

        test_result = LoadTest.get_last_result_for(str(result2.uuid))
        expect(str(test_result.uuid)).to_equal(str(result1.uuid))
 def test_can_get_load_test_by_test_result_uuid(self):
     self.load_test.results.append(TestResultFactory.build())
     self.load_test.save()
     result = self.load_test.results[0]
     load_test, test_result = LoadTest.get_test_result(str(result.uuid))
     expect(str(test_result.uuid)).to_equal(str(result.uuid))
     expect(str(load_test.uuid)).to_equal(str(self.load_test.uuid))
Exemple #7
0
def main(args=None):
    if args is None:
        args = sys.argv[1:]

    parser = argparse.ArgumentParser()
    parser.add_argument('--conf', '-c', default=DEFAULT_CONFIG_PATH, help="Path to configuration file.")
    options = parser.parse_args(args)

    config = Config.load(path=options.conf, conf_name=split(options.conf)[-1], lookup_paths=[
        os.curdir,
        expanduser('~'),
        '/etc/',
    ])

    connect(
        config.MONGO_DB,
        host=config.MONGO_HOST,
        port=config.MONGO_PORT,
        username=config.MONGO_USER,
        password=config.MONGO_PASS
    )

    user = UserFactory.create()
    team = TeamFactory.create(owner=user)
    TeamFactory.add_projects(team, 1)
    project = team.projects[0]
    config = TestConfigurationFactory.build()
    load_test1 = LoadTestFactory.add_to_project(1, user=user, team=team, project=project)
    load_test1.results.append(TestResultFactory.build(config=config))
    load_test1.save()
    print "load test 1: %s" % load_test1.uuid
    print "test result for load test 1: %s" % load_test1.results[0].uuid
    load_test2 = LoadTestFactory.add_to_project(1, user=user, team=team, project=project)
    load_test2.results.append(TestResultFactory.build(config=config))
    load_test2.results.append(TestResultFactory.build())
    load_test2.save()
    load_test3 = LoadTestFactory.add_to_project(1, user=user, team=team, project=project)
    load_test3.results.append(TestResultFactory.build(config=config))
    load_test3.save()
    load_test4 = LoadTestFactory.add_to_project(1, user=user, team=team, project=project)
    load_test4.results.append(TestResultFactory.build(config=config))
    load_test4.save()
    print "load test 2: %s" % load_test2.uuid
    print "test result 1 for load test 2: %s" % load_test2.results[0].uuid
    print "test result 2 for load test 2: %s" % load_test2.results[1].uuid
    print "url for trend: %s/%s/%s/%s/%s/" % (team.name, project.name, config.module, config.class_name, config.test_name)
Exemple #8
0
 def _add_results(self):
     self.load_test.results.append(TestResultFactory.build())
     self.load_test.results.append(
         TestResultFactory.build(config=self.config))
     self.load_test.results.append(TestResultFactory.build())
     self.load_test.save()
     self.load_test2 = LoadTestFactory.add_to_project(1,
                                                      user=self.user,
                                                      team=self.team,
                                                      project=self.project,
                                                      status="Finished")
     self.load_test2.results.append(TestResultFactory.build())
     self.load_test2.results.append(
         TestResultFactory.build(config=self.config))
     self.load_test2.save()
     self.load_test3 = LoadTestFactory.add_to_project(
         1,
         user=self.user,
         team=self.team,
         project=self.team.projects[1],
         status="Finished")
     self.load_test3.results.append(TestResultFactory.build())
     self.load_test3.results.append(
         TestResultFactory.build(config=self.config))
     self.load_test3.save()
 def setUp(self):
     super(ShowLoadLastTestResultTest, self).setUp()
     self.user = UserFactory.create(with_token=True)
     self.team = TeamFactory.create(owner=self.user)
     TeamFactory.add_projects(self.team, 1)
     self.project = self.team.projects[0]
     self.load_test = LoadTestFactory.create(created_by=self.user, team=self.team, project_name=self.project.name, status="Finished")
     self.load_test.results.append(TestResultFactory.build())
     self.load_test.save()
     self.result = self.load_test.results[0]
 def setUp(self):
     super(ShowAuthLoadTestResultTest, self).setUp()
     self.user = UserFactory.create(with_token=True)
     self.team = TeamFactory.create(owner=self.user)
     TeamFactory.add_projects(self.team, 1)
     self.project = self.team.projects[0]
     self.load_test = LoadTestFactory.create(created_by=self.user, team=self.team, project_name=self.project.name)
     self.load_test.results.append(TestResultFactory.build())
     self.load_test.save()
     self.result = self.load_test.results[0]
    def test_get_instance_load_test(self):
        result1 = TestResultFactory.build()
        result2 = TestResultFactory.build()
        self.load_test.results.append(result1)
        self.load_test.results.append(result2)
        self.load_test.save()

        url = '/load_tests/%s' % self.load_test.uuid

        response = self.fetch_with_headers(url)
        expect(response.code).to_equal(200)

        obj = response.body
        if isinstance(obj, six.binary_type):
            obj = obj.decode('utf-8')

        obj = loads(obj)

        result1_last_cycle = result1.cycles[-1]
        result2_last_cycle = result2.cycles[-1]

        expect(obj['uuid']).to_equal(str(self.load_test.uuid))
        expect(obj['status']).to_equal(self.load_test.status)
        expect(obj['baseUrl']).to_equal(self.load_test.base_url)
        expect(obj['teamName']).to_equal(self.team.name)
        expect(obj['projectName']).to_equal(self.project.name)
        expect(obj['createdBy']).to_equal(self.user.email)
        expect(obj['repository']).to_equal(self.project.repository)

        expect(obj['results'][0]['uuid']).to_equal(str(result1.uuid))
        expect(obj['results'][0]['concurrent_users']).to_equal(result1_last_cycle.concurrent_users)
        expect(obj['results'][0]['title']).to_equal(result1.config.title)
        expect(obj['results'][0]['requests_per_second']).to_equal(result1_last_cycle.request.successful_requests_per_second)
        expect(obj['results'][0]['failed_requests']).to_equal(result1_last_cycle.request.failed_requests)
        expect(obj['results'][0]['p95']).to_equal(result1_last_cycle.request.p95)

        expect(obj['results'][1]['uuid']).to_equal(str(result2.uuid))
        expect(obj['results'][1]['concurrent_users']).to_equal(result2_last_cycle.concurrent_users)
        expect(obj['results'][1]['title']).to_equal(result2.config.title)
        expect(obj['results'][1]['requests_per_second']).to_equal(result2_last_cycle.request.successful_requests_per_second)
        expect(obj['results'][1]['failed_requests']).to_equal(result2_last_cycle.request.failed_requests)
        expect(obj['results'][1]['p95']).to_equal(result2_last_cycle.request.p95)
 def _add_results(self):
     self.load_test.results.append(TestResultFactory.build())
     self.load_test.results.append(TestResultFactory.build(config=self.config))
     self.load_test.results.append(TestResultFactory.build())
     self.load_test.save()
     self.load_test2 = LoadTestFactory.add_to_project(1, user=self.user, team=self.team, project=self.project, status="Finished")
     self.load_test2.results.append(TestResultFactory.build())
     self.load_test2.results.append(TestResultFactory.build(config=self.config))
     self.load_test2.save()
     self.load_test3 = LoadTestFactory.add_to_project(1, user=self.user, team=self.team, project=self.team.projects[1], status="Finished")
     self.load_test3.results.append(TestResultFactory.build())
     self.load_test3.results.append(TestResultFactory.build(config=self.config))
     self.load_test3.save()
    def test_get_results_for_team_project_and_test_get_finished_only(self):
        config = TestConfigurationFactory.build()
        self.load_test.results.append(TestResultFactory.build(config=config))
        self.load_test.results.append(TestResultFactory.build())
        self.load_test.results.append(TestResultFactory.build(config=config))
        self.load_test.save()
        load_test2 = LoadTestFactory.add_to_project(1, user=self.user, team=self.team, project=self.project, status="Failed")
        load_test2.results.append(TestResultFactory.build())
        load_test2.results.append(TestResultFactory.build(config=config))
        load_test2.save()
        load_test3 = LoadTestFactory.add_to_project(1, user=self.user, team=self.team, project=self.project)
        load_test3.results.append(TestResultFactory.build())
        load_test3.results.append(TestResultFactory.build(config=config))
        load_test3.save()

        results = [str(result.uuid) for result in LoadTest.get_same_results_for_all_load_tests_from_project(self.team, self.project.name, config.module, config.class_name, config.test_name)]

        expected_results = [
            str(self.load_test.results[0].uuid),
            str(self.load_test.results[2].uuid),
        ]

        expect(results).to_be_like(expected_results)