Exemplo n.º 1
0
 def test_delete_a_project(self):
     team = TeamFactory.create()
     TeamFactory.add_projects(team, 1)
     project = team.projects[0]
     team.delete_project(project.name)
     retrieved = Team.objects.filter(name=team.name).first()
     expect(retrieved.projects).to_length(0)
Exemplo n.º 2
0
 def test_delete_a_project(self):
     team = TeamFactory.create()
     TeamFactory.add_projects(team, 1)
     project = team.projects[0]
     team.delete_project(project.name)
     retrieved = Team.objects.filter(name=team.name).first()
     expect(retrieved.projects).to_length(0)
Exemplo n.º 3
0
    def test_can_run_project(self):
        temp_path = mkdtemp()

        team = TeamFactory.create(name="teste")
        TeamFactory.add_projects(team, 1)
        user = team.owner
        project = team.projects[0]
        project.repository = "git://github.com/heynemann/wight.git"
        load_test = LoadTestFactory.add_to_project(1,
                                                   user=user,
                                                   team=team,
                                                   project=project,
                                                   base_url=self.base_url)

        runner = BenchRunner()
        runner.run_project_tests(temp_path, str(load_test.uuid), duration=1)

        loaded = LoadTest.objects(uuid=load_test.uuid).first()

        expect(loaded).not_to_be_null()
        expect(loaded.status).to_equal("Finished")

        expect(loaded.results).to_length(2)

        expect(loaded.results[0].log).not_to_be_null()
        expect(loaded.results[0].status).to_equal("Successful")
Exemplo n.º 4
0
    def test_can_run_simple_project(self):
        temp_path = mkdtemp()
        team = TeamFactory.create()
        TeamFactory.add_projects(team, 1)
        user = team.owner
        project = team.projects[0]
        load_test = LoadTestFactory.add_to_project(1,
                                                   user=user,
                                                   team=team,
                                                   project=project,
                                                   base_url="%s/healthcheck" %
                                                   self.base_url,
                                                   simple=True)

        runner = BenchRunner()
        runner.run_project_tests(temp_path, str(load_test.uuid), duration=1)

        loaded = LoadTest.objects(uuid=load_test.uuid).first()

        expect(loaded).not_to_be_null()
        expect(loaded.status).to_equal("Finished")

        expect(loaded.results).to_length(1)

        expect(loaded.results[0].log).not_to_be_null()
        expect(loaded.results[0].status).to_equal("Successful")
        expect(loaded.results[0].config.module).to_equal("test_simple")
        expect(loaded.results[0].config.class_name).to_equal("SimpleTestTest")
        expect(loaded.results[0].config.test_name).to_equal("test_simple")
Exemplo n.º 5
0
    def test_can_run_funkload(self):
        team = TeamFactory.create()
        TeamFactory.add_projects(team, 1)
        user = team.owner
        project = team.projects[0]
        load_test = LoadTestFactory.add_to_project(1, user=user, team=team, project=project)
        load_test.pressure = "small"

        conf = WightConfig.load(join(root_path, 'bench', 'wight.yml'))
        test = conf.tests[0]

        DEFAULT_CYCLES = {
            "small": [10, 20],
            "medium": [10, 20, 30],
            "large": [30, 75, 100],
        }

        fl_result = FunkLoadBenchRunner.run(root_path, test, self.base_url, cycles=DEFAULT_CYCLES, duration=5)

        expect(fl_result).not_to_be_null()
        expect(fl_result.exit_code).to_equal(0)

        expect(fl_result.text).to_include("SUCCESSFUL")

        expect(fl_result.log).to_be_empty()

        expect(fl_result.result).not_to_be_null()
        expect(fl_result.config).not_to_be_null()

        result = LoadTest.get_data_from_funkload_results(fl_result.config, fl_result.result)

        load_test.add_result(result, fl_result.text)

        expect(load_test.results).to_length(1)
Exemplo n.º 6
0
 def test_update_a_project_with_name(self):
     team = TeamFactory.create()
     TeamFactory.add_projects(team, 1)
     project = team.projects[0]
     team.update_project(project.name, "new-name")
     retrieved = Team.objects.filter(name=team.name).first()
     expect(retrieved.projects[0].name).to_equal("new-name")
     expect(retrieved.projects[0].repository).to_equal(project.repository)
Exemplo n.º 7
0
    def setUp(self):
        super(DeleteTeamProjectTest, self).setUp()

        self.user = UserFactory.create(with_token=True)
        self.team = TeamFactory.create(owner=self.user)
        TeamFactory.add_projects(self.team, 1)
        TeamFactory.add_members(self.team, 2)
        self.project = self.team.projects[0]
Exemplo n.º 8
0
 def test_update_a_project_with_repository(self):
     team = TeamFactory.create()
     TeamFactory.add_projects(team, 1)
     project = team.projects[0]
     team.update_project(project.name, new_repository="new-repository")
     retrieved = Team.objects.filter(name=team.name).first()
     expect(retrieved.projects[0].name).to_equal(project.name)
     expect(retrieved.projects[0].repository).to_equal("new-repository")
Exemplo n.º 9
0
    def setUp(self):
        super(DeleteTeamProjectTest, self).setUp()

        self.user = UserFactory.create(with_token=True)
        self.team = TeamFactory.create(owner=self.user)
        TeamFactory.add_projects(self.team, 1)
        TeamFactory.add_members(self.team, 2)
        self.project = self.team.projects[0]
Exemplo n.º 10
0
 def test_get_last_3_load_tests_for_all_projects_when_owner(self):
     LoadTestFactory.add_to_project(4, user=self.user, team=self.team, project=self.project)
     LoadTestFactory.add_to_project(4, user=self.user, team=self.team, project=self.team.projects[1])
     team = TeamFactory.create(owner=self.user)
     TeamFactory.add_projects(team, 1)
     LoadTestFactory.add_to_project(4, user=self.user, team=team, project=team.projects[0])
     LoadTestFactory.add_to_project(4, user=UserFactory.create())
     loaded_tests = list(LoadTest.get_by_user(self.user))
     expect(loaded_tests).to_length(9)
Exemplo n.º 11
0
 def test_get_project_by_team_should_be_a_equal_to_project_dict(self):
     TeamFactory.add_projects(self.team, 2)
     project = self.team.projects[1]
     response = self.fetch_with_headers("/teams/%s/projects/%s" % (self.team.name, project.name))
     expect(response.code).to_equal(200)
     obj = response.body
     if isinstance(obj, six.binary_type):
         obj = obj.decode('utf-8')
     expect(loads(obj)).to_be_like(project.to_dict())
Exemplo n.º 12
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]
Exemplo n.º 13
0
 def test_get_project_by_team_should_be_a_equal_to_project_dict(self):
     TeamFactory.add_projects(self.team, 2)
     project = self.team.projects[1]
     response = self.fetch_with_headers("/teams/%s/projects/%s" %
                                        (self.team.name, project.name))
     expect(response.code).to_equal(200)
     obj = response.body
     if isinstance(obj, six.binary_type):
         obj = obj.decode('utf-8')
     expect(loads(obj)).to_be_like(project.to_dict())
Exemplo n.º 14
0
 def setUp(self):
     super(ShowTestResultForTeamProjectAndTestTest, self).setUp()
     self.user = UserFactory.create(with_token=True)
     self.team = TeamFactory.create(owner=self.user)
     TeamFactory.add_projects(self.team, 2)
     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.save()
     self.config = TestConfigurationFactory.build()
     self.config2 = TestConfigurationFactory.build()
Exemplo n.º 15
0
 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]
Exemplo n.º 16
0
    def test_list_load_tests_by_team_and_project(self):
        team = TeamFactory.create(owner=self.user)
        TeamFactory.add_projects(team, 1)
        project = team.projects[0]
        LoadTestFactory.add_to_project(25, user=self.user, team=team, project=project)

        load_tests = LoadTest.get_sliced_by_team_and_project_name(team, project.name, 20)
        uuids = _get_print_lines_for_load_tests(load_tests)

        result = self.execute("list", team=team.name, project=project.name)
        expect(result).to_be_like(BASE_LOAD_TESTS_TABLE_PRINT % (team.name, project.name, "".join(uuids)))
Exemplo n.º 17
0
    def test_can_git_clone_in_specific_branch(
        self, run_config_mock, load_config_mock, validate_mock, save_mock, clone_mock
    ):
        team = TeamFactory.create()
        TeamFactory.add_projects(team, 1)
        user = team.owner
        project = team.projects[0]
        load_test = LoadTestFactory.add_to_project(1, user=user, team=team, project=project, branch="test")

        runner = BenchRunner()
        runner.run_project_tests("some-path-doesnt-matter", str(load_test.uuid), duration=1)
        expect(clone_mock.call_args_list[0][1]["branch"]).to_be_like("test")
Exemplo n.º 18
0
    def test_can_git_clone_in_specific_branch(self, run_config_mock, load_config_mock, validate_mock, save_mock, clone_mock):
        team = TeamFactory.create()
        TeamFactory.add_projects(team, 1)
        user = team.owner
        project = team.projects[0]
        load_test = LoadTestFactory.add_to_project(1, user=user, team=team, project=project, branch="test")

        runner = BenchRunner()
        runner.run_project_tests("some-path-doesnt-matter", str(load_test.uuid), duration=1)
        expect(clone_mock.call_args_list[0][1]['branch']).to_be_like(
            "test"
        )
Exemplo n.º 19
0
 def test_get_project_by_team_should_be_a_json(self):
     TeamFactory.add_projects(self.team, 2)
     project = self.team.projects[1]
     response = self.fetch_with_headers("/teams/%s/projects/%s" % (self.team.name, project.name))
     expect(response.code).to_equal(200)
     obj = response.body
     if isinstance(obj, six.binary_type):
         obj = obj.decode('utf-8')
     try:
         loads(obj)
         assert True
     except ValueError:
         raise AssertionError("Should be possible to load a json from response")
Exemplo n.º 20
0
 def setUp(self):
     super(ShowTestResultForTeamProjectAndTestTest, self).setUp()
     self.user = UserFactory.create(with_token=True)
     self.team = TeamFactory.create(owner=self.user)
     TeamFactory.add_projects(self.team, 2)
     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.save()
     self.config = TestConfigurationFactory.build()
     self.config2 = TestConfigurationFactory.build()
Exemplo n.º 21
0
    def test_can_schedule_in_specific_branch(self):
        team = TeamFactory.create(owner=self.user)
        TeamFactory.add_projects(team, 2)
        project_name = team.projects[0].name

        result = self.execute("schedule", team=team.name, project=project_name, url="http://www.globo.com", branch="test-branch")
        expect(result).to_be_like(
            "Scheduled a new load test for project '%s' (branch '%s') in team '%s' at '%s' target." % (
                project_name, "test-branch", team.name, self.target
            )
        )

        load_test = LoadTest.objects.filter(team=team, project_name=project_name).first()
        expect(load_test).not_to_be_null()
        expect(load_test.git_branch).to_equal("test-branch")
Exemplo n.º 22
0
 def test_get_project_by_team_should_be_a_json(self):
     TeamFactory.add_projects(self.team, 2)
     project = self.team.projects[1]
     response = self.fetch_with_headers("/teams/%s/projects/%s" %
                                        (self.team.name, project.name))
     expect(response.code).to_equal(200)
     obj = response.body
     if isinstance(obj, six.binary_type):
         obj = obj.decode('utf-8')
     try:
         loads(obj)
         assert True
     except ValueError:
         raise AssertionError(
             "Should be possible to load a json from response")
Exemplo n.º 23
0
    def test_to_dict(self):
        team = TeamFactory.create()
        TeamFactory.add_members(team, 2)
        TeamFactory.add_projects(team, 2)

        expect(team.to_dict()).to_be_like({
            "name": team.name,
            "owner": team.owner.email,
            "members": [
                team.members[0].email,
                team.members[1].email,
            ],
            "projects": [
                team.projects[0].to_dict(),
                team.projects[1].to_dict(),
            ]
        })
Exemplo n.º 24
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)
Exemplo n.º 25
0
    def test_can_schedule_with_default_project(self):
        team = TeamFactory.create(owner=self.user)
        TeamFactory.add_projects(team, 2)
        project_name = team.projects[0].name
        self.execute("default-set", project=project_name)
        result = self.execute("schedule", team=team.name, url="http://www.globo.com")
        expect(result).to_be_like(
            "Scheduled a new load test for project '%s' in team '%s' at '%s' target." % (
                project_name, team.name, self.target
            )
        )

        load_test = LoadTest.objects.filter(team=team, project_name=project_name).first()
        expect(load_test).not_to_be_null()

        expect(load_test.team.id).to_equal(team.id)
        expect(load_test.project_name).to_equal(project_name)
        expect(load_test.created_by.id).to_equal(self.user.id)
Exemplo n.º 26
0
    def test_list_load_tests_by_user_only(self):
        team1 = TeamFactory.create(owner=self.user)
        team2 = TeamFactory.create(owner=self.user)
        TeamFactory.add_projects(team1, 2)
        TeamFactory.add_projects(team2, 3)

        project1 = team1.projects[0]
        project2 = team1.projects[1]

        project3 = team2.projects[0]
        project4 = team2.projects[1]
        project5 = team2.projects[2]

        LoadTestFactory.add_to_project(4, user=self.user, team=team1, project=project1)
        LoadTestFactory.add_to_project(4, user=self.user, team=team1, project=project2)

        LoadTestFactory.add_to_project(4, user=self.user, team=team2, project=project3)
        LoadTestFactory.add_to_project(4, user=self.user, team=team2, project=project4)
        LoadTestFactory.add_to_project(4, user=self.user, team=team2, project=project5)

        load_tests1 = LoadTest.get_sliced_by_team_and_project_name(team1, project1.name, 3)
        load_tests2 = LoadTest.get_sliced_by_team_and_project_name(team1, project2.name, 3)

        load_tests3 = LoadTest.get_sliced_by_team_and_project_name(team2, project3.name, 3)
        load_tests4 = LoadTest.get_sliced_by_team_and_project_name(team2, project4.name, 3)
        load_tests5 = LoadTest.get_sliced_by_team_and_project_name(team2, project5.name, 3)

        uuids1 = _get_print_lines_for_load_tests(load_tests1)
        uuids2 = _get_print_lines_for_load_tests(load_tests2)

        uuids3 = _get_print_lines_for_load_tests(load_tests3)
        uuids4 = _get_print_lines_for_load_tests(load_tests4)
        uuids5 = _get_print_lines_for_load_tests(load_tests5)

        result = self.execute("list")

        expect(result).to_be_like((BASE_LOAD_TESTS_TABLE_PRINT * 5) % (
            team1.name, project1.name, "".join(uuids1),
            team1.name, project2.name, "".join(uuids2),
            team2.name, project3.name, "".join(uuids3),
            team2.name, project4.name, "".join(uuids4),
            team2.name, project5.name, "".join(uuids5)
        ))
Exemplo n.º 27
0
    def test_to_dict(self):
        team = TeamFactory.create()
        TeamFactory.add_members(team, 2)
        TeamFactory.add_projects(team, 2)

        expect(team.to_dict()).to_be_like({
            "name":
            team.name,
            "owner":
            team.owner.email,
            "members": [
                team.members[0].email,
                team.members[1].email,
            ],
            "projects": [
                team.projects[0].to_dict(),
                team.projects[1].to_dict(),
            ]
        })
Exemplo n.º 28
0
    def test_can_run_funkload(self):
        team = TeamFactory.create()
        TeamFactory.add_projects(team, 1)
        user = team.owner
        project = team.projects[0]
        load_test = LoadTestFactory.add_to_project(1,
                                                   user=user,
                                                   team=team,
                                                   project=project)
        load_test.pressure = "small"

        conf = WightConfig.load(join(root_path, 'bench', 'wight.yml'))
        test = conf.tests[0]

        DEFAULT_CYCLES = {
            "small": [10, 20],
            "medium": [10, 20, 30],
            "large": [30, 75, 100],
        }

        fl_result = FunkLoadBenchRunner.run(root_path,
                                            test,
                                            self.base_url,
                                            cycles=DEFAULT_CYCLES,
                                            duration=5)

        expect(fl_result).not_to_be_null()
        expect(fl_result.exit_code).to_equal(0)

        expect(fl_result.text).to_include("SUCCESSFUL")

        expect(fl_result.log).to_be_empty()

        expect(fl_result.result).not_to_be_null()
        expect(fl_result.config).not_to_be_null()

        result = LoadTest.get_data_from_funkload_results(
            fl_result.config, fl_result.result)

        load_test.add_result(result, fl_result.text)

        expect(load_test.results).to_length(1)
Exemplo n.º 29
0
    def test_list_load_tests_by_team_only(self):
        team = TeamFactory.create(owner=self.user)
        TeamFactory.add_projects(team, 2)
        project1 = team.projects[0]
        project2 = team.projects[1]
        LoadTestFactory.add_to_project(7, user=self.user, team=team, project=project1)
        LoadTestFactory.add_to_project(7, user=self.user, team=team, project=project2)

        load_tests1 = LoadTest.get_sliced_by_team_and_project_name(team, project1.name, 5)
        load_tests2 = LoadTest.get_sliced_by_team_and_project_name(team, project2.name, 5)

        uuids1 = _get_print_lines_for_load_tests(load_tests1)
        uuids2 = _get_print_lines_for_load_tests(load_tests2)

        result = self.execute("list", team=team.name)

        expect(result).to_be_like((BASE_LOAD_TESTS_TABLE_PRINT * 2) % (
            team.name, project1.name, "".join(uuids1),
            team.name, project2.name, "".join(uuids2)
        ))
Exemplo n.º 30
0
    def test_can_run_project(self):
        temp_path = mkdtemp()

        team = TeamFactory.create()
        TeamFactory.add_projects(team, 1)
        user = team.owner
        project = team.projects[0]
        project.repository = "git://github.com/heynemann/wight.git"
        load_test = LoadTestFactory.add_to_project(1, user=user, team=team, project=project, base_url=self.base_url)

        runner = BenchRunner()
        runner.run_project_tests(temp_path, str(load_test.uuid), duration=1)

        loaded = LoadTest.objects(uuid=load_test.uuid).first()

        expect(loaded).not_to_be_null()
        expect(loaded.status).to_equal("Finished")

        expect(loaded.results).to_length(1)

        expect(loaded.results[0].log).not_to_be_null()
        expect(loaded.results[0].status).to_equal("Successful")
Exemplo n.º 31
0
    def test_can_run_simple_project(self):
        temp_path = mkdtemp()
        team = TeamFactory.create()
        TeamFactory.add_projects(team, 1)
        user = team.owner
        project = team.projects[0]
        load_test = LoadTestFactory.add_to_project(1, user=user, team=team, project=project, base_url="%s/healthcheck" % self.base_url, simple=True)

        runner = BenchRunner()
        runner.run_project_tests(temp_path, str(load_test.uuid), duration=1)

        loaded = LoadTest.objects(uuid=load_test.uuid).first()

        expect(loaded).not_to_be_null()
        expect(loaded.status).to_equal("Finished")

        expect(loaded.results).to_length(1)

        expect(loaded.results[0].log).not_to_be_null()
        expect(loaded.results[0].status).to_equal("Successful")
        expect(loaded.results[0].config.module).to_equal("test_simple")
        expect(loaded.results[0].config.class_name).to_equal("SimpleTestTest")
        expect(loaded.results[0].config.test_name).to_equal("test_simple")
Exemplo n.º 32
0
    def test_can_run_project_with_two_test(self, build_mock):
        simple_test_content = """
import unittest
from funkload.FunkLoadTestCase import FunkLoadTestCase


class SimpleTestTest(FunkLoadTestCase):
    def setUp(self):
        self.server_url = '%s/healthcheck' % (self.conf_get('main', 'url').rstrip('/'),)

    def test_simple(self):
        self.get(self.server_url, description='Get url')

if __name__ == '__main__':
    unittest.main()

"""

        healthcheck_content = """
import unittest
from funkload.FunkLoadTestCase import FunkLoadTestCase


class HealthCheckTest(FunkLoadTestCase):
    def setUp(self):
        self.server_url = '%s/healthcheck' % (self.conf_get('main', 'url').rstrip('/'),)

    def test_healthcheck(self):
        self.get(self.server_url, description='Get url')

if __name__ == '__main__':
    unittest.main()

"""
        cfg_text = """
tests:
  -
    module: test_healthcheck.py
    class: HealthCheckTest
    test: test_healthcheck
  -
    module: test_simple.py
    class: SimpleTestTest
    test: test_simple
"""

        build_mock.return_value = WightConfig(cfg_text)

        team = TeamFactory.create()
        TeamFactory.add_projects(team, 1)
        user = team.owner
        project = team.projects[0]
        load_test = LoadTestFactory.add_to_project(1, user=user, team=team, project=project, base_url=self.base_url, simple=True)

        temp_path = mkdtemp()

        mkdir(join(temp_path, "bench"))
        init_file = open(join(temp_path, "bench/__init__.py"), "w")
        init_file.close()
        wight_file = open(join(temp_path, "bench/wight.yml"), "w")
        wight_file.write(cfg_text)
        wight_file.close()

        simple_file = open(join(temp_path, "bench/test_simple.py"), "w")
        simple_file.write(simple_test_content)
        simple_file.close()

        healthcheck_file = open(join(temp_path, "bench/test_healthcheck.py"), "w")
        healthcheck_file.write(healthcheck_content)
        healthcheck_file.close()

        runner = BenchRunner()
        runner.run_project_tests(temp_path, str(load_test.uuid), duration=1)

        loaded = LoadTest.objects(uuid=load_test.uuid).first()
        expect(loaded).not_to_be_null()
        expect(loaded.status).to_equal("Finished")

        expect(loaded.results).to_length(2)

        expect(loaded.results[0].log).not_to_be_null()
        expect(loaded.results[0].status).to_equal("Successful")
        expect(loaded.results[0].config.module).to_equal("test_healthcheck")

        expect(loaded.results[1].log).not_to_be_null()
        expect(loaded.results[1].status).to_equal("Successful")
        expect(loaded.results[1].config.module).to_equal("test_simple")
Exemplo n.º 33
0
 def setUp(self):
     self.user = UserFactory.create()
     self.team = TeamFactory.create(owner=self.user)
     TeamFactory.add_projects(self.team, 2)
     self.project = self.team.projects[0]
     self.load_test = LoadTestFactory.add_to_project(1, user=self.user, team=self.team, project=self.project, status="Finished")
Exemplo n.º 34
0
 def setUp(self):
     super(TestDeleteProject, self).setUp()
     self.team = TeamFactory.create(owner=self.user)
     TeamFactory.add_projects(self.team, 1)
     self.project = self.team.projects[0]
Exemplo n.º 35
0
 def test_get_project_by_team_and_name_return_200_if_no_errors(self):
     TeamFactory.add_projects(self.team, 2)
     project = self.team.projects[1]
     response = self.fetch_with_headers("/teams/%s/projects/%s" % (self.team.name, project.name))
     expect(response.code).to_equal(200)
Exemplo n.º 36
0
 def test_get_project_by_team_and_name_return_200_if_no_errors(self):
     TeamFactory.add_projects(self.team, 2)
     project = self.team.projects[1]
     response = self.fetch_with_headers("/teams/%s/projects/%s" %
                                        (self.team.name, project.name))
     expect(response.code).to_equal(200)
Exemplo n.º 37
0
 def setUp(self):
     self.user = UserFactory.create()
     self.team = TeamFactory.create(owner=self.user)
     TeamFactory.add_projects(self.team, 2)
     self.project = self.team.projects[0]
Exemplo n.º 38
0
    def test_can_run_project_with_two_test(self, build_mock):
        simple_test_content = """
import unittest
from funkload.FunkLoadTestCase import FunkLoadTestCase


class SimpleTestTest(FunkLoadTestCase):
    def setUp(self):
        self.server_url = '%s/healthcheck' % (self.conf_get('main', 'url').rstrip('/'),)

    def test_simple(self):
        self.get(self.server_url, description='Get url')

if __name__ == '__main__':
    unittest.main()

"""

        healthcheck_content = """
import unittest
from funkload.FunkLoadTestCase import FunkLoadTestCase


class HealthCheckTest(FunkLoadTestCase):
    def setUp(self):
        self.server_url = '%s/healthcheck' % (self.conf_get('main', 'url').rstrip('/'),)

    def test_healthcheck(self):
        self.get(self.server_url, description='Get url')

if __name__ == '__main__':
    unittest.main()

"""
        cfg_text = """
tests:
  -
    module: test_healthcheck.py
    class: HealthCheckTest
    test: test_healthcheck
  -
    module: test_simple.py
    class: SimpleTestTest
    test: test_simple
"""

        build_mock.return_value = WightConfig(cfg_text)

        team = TeamFactory.create()
        TeamFactory.add_projects(team, 1)
        user = team.owner
        project = team.projects[0]
        load_test = LoadTestFactory.add_to_project(1,
                                                   user=user,
                                                   team=team,
                                                   project=project,
                                                   base_url=self.base_url,
                                                   simple=True)

        temp_path = mkdtemp()

        mkdir(join(temp_path, "bench"))
        init_file = open(join(temp_path, "bench/__init__.py"), "w")
        init_file.close()
        wight_file = open(join(temp_path, "bench/wight.yml"), "w")
        wight_file.write(cfg_text)
        wight_file.close()

        simple_file = open(join(temp_path, "bench/test_simple.py"), "w")
        simple_file.write(simple_test_content)
        simple_file.close()

        healthcheck_file = open(join(temp_path, "bench/test_healthcheck.py"),
                                "w")
        healthcheck_file.write(healthcheck_content)
        healthcheck_file.close()

        runner = BenchRunner()
        runner.run_project_tests(temp_path, str(load_test.uuid), duration=1)

        loaded = LoadTest.objects(uuid=load_test.uuid).first()
        expect(loaded).not_to_be_null()
        expect(loaded.status).to_equal("Finished")

        expect(loaded.results).to_length(2)

        expect(loaded.results[0].log).not_to_be_null()
        expect(loaded.results[0].status).to_equal("Successful")
        expect(loaded.results[0].config.module).to_equal("test_healthcheck")

        expect(loaded.results[1].log).not_to_be_null()
        expect(loaded.results[1].status).to_equal("Successful")
        expect(loaded.results[1].config.module).to_equal("test_simple")
Exemplo n.º 39
0
 def setUp(self):
     super(TestDeleteProject, self).setUp()
     self.team = TeamFactory.create(owner=self.user)
     TeamFactory.add_projects(self.team, 1)
     self.project = self.team.projects[0]