Example #1
0
 def setUp(self):
     self.gitObj = GitUtils()
     self.settingObj = Settings()
     self.base_dir = self.settingObj.getCliDir()
     self.configs_dir = self.base_dir + "/tests/configs"
     self.work_dir = self.base_dir + "/tests/work_dir"
     self.branch = "master"
 def setUp(self):
     self.gitObj = GitUtils()
     self.settingObj = Settings()
     self.base_dir = self.settingObj.getCliDir()
     self.configs_dir = self.base_dir + "/tests/configs"
     self.work_dir = self.base_dir + "/tests/work_dir"
     self.branch = "master"
Example #3
0
class TestInit(unittest.TestCase):
    def setUp(self):
        self.gitObj = GitUtils()
        self.settingObj = Settings()
        self.base_dir = self.settingObj.getCliDir()
        self.configs_dir = self.base_dir + "/tests/configs"
        self.work_dir = self.base_dir + "/tests/work_dir"
        self.branch = "master"

    @pytest.mark.skip
    def test_gitPull(self):
        config_file = "app.json"
        work_dir = self.work_dir
        branch = self.branch

        if not os.path.exists(self.work_dir):
            try:
                os.makedirs(self.work_dir)
            except OSError as exception:
                if exception.errno != errno.EEXIST:
                    raise
        os.chdir(self.work_dir)
        with open(self.configs_dir + '/{}'.format(config_file)) as config:
            config = json.load(config)
        repo = config['repo']
        return_code = self.gitObj.gitClone(repo, branch)
        assert return_code == 0
        exists = os.path.exists(work_dir)
        assert exists is True
        os.chdir("{}/{}".format(work_dir, repo))
        return_code = self.gitObj.gitPull(self.branch)
        assert return_code == 0
        assert exists is True
        exists = os.path.exists("{}/{}".format(work_dir, repo))
        assert exists is True
        exists = os.path.exists("{}/{}/ansible".format(work_dir, repo))
        assert exists is True
        shutil.rmtree(work_dir)
        pass

    @pytest.mark.skip
    def test_gitShallowClone(self):
        config_file = "app.json"
        work_dir = self.work_dir
        branch = self.branch

        if not os.path.exists(self.work_dir):
            try:
                os.makedirs(self.work_dir)
            except OSError as exception:
                if exception.errno != errno.EEXIST:
                    raise
        os.chdir(self.work_dir)
        with open(self.configs_dir + '/{}'.format(config_file)) as config:
            config = json.load(config)
        repo = config['repo']
        return_code = self.gitObj.gitShallowClone(repo, branch)
        assert return_code == 0
        exists = os.path.exists(work_dir)
        assert exists is True
        exists = os.path.exists("{}/{}".format(work_dir, repo))
        assert exists is True
        exists = os.path.exists("{}/{}/ansible".format(work_dir, repo))
        assert exists is True
        shutil.rmtree(work_dir)

    @pytest.mark.skip
    def test_gitClone(self):
        config_file = "app.json"
        work_dir = self.work_dir
        branch = self.branch

        if not os.path.exists(self.work_dir):
            try:
                os.makedirs(self.work_dir)
            except OSError as exception:
                if exception.errno != errno.EEXIST:
                    raise
        os.chdir(self.work_dir)
        with open(self.configs_dir + '/{}'.format(config_file)) as config:
            config = json.load(config)
        repo = config['repo']
        return_code = self.gitObj.gitClone(repo, branch)
        assert return_code == 0
        exists = os.path.exists(work_dir)
        assert exists is True
        exists = os.path.exists("{}/{}".format(work_dir, repo))
        assert exists is True
        exists = os.path.exists("{}/{}/ansible".format(work_dir, repo))
        assert exists is True
        shutil.rmtree(work_dir)

    def tearDown(self):
        pass
Example #4
0
                sc = self.utils.getStatsClient()
                if not hasattr(self, "identifier"):
                    self.identifier = self.utils.get_identifier(config_name, settingObj.getUser(), args.app_name)
                time_take_milliseonds = ((datetime.now() - function_execution_start_time).total_seconds() * 1000)
                input_metric = "roger-tools.rogeros_tools_exec_time," + "app_name=" + str(args.app_name) + ",event=gitpull" + ",identifier=" + str(self.identifier) + ",outcome=" + str(execution_result) + ",config_name=" + str(config_name) + ",env=" + str(environment) + ",user="******"The following error occurred: %s" %
                      e, file=sys.stderr)
                raise

if __name__ == "__main__":
    settingObj = Settings()
    appObj = AppConfig()
    gitObj = GitUtils()
    hooksObj = Hooks()
    roger_gitpull = RogerGitPull()
    roger_gitpull.parser = roger_gitpull.parse_args()
    args = roger_gitpull.parser.parse_args()
    roger_gitpull.main(settingObj, appObj, gitObj, hooksObj, args)
    version = roger_gitpull.utils.get_version()
    try:
        statsd_message_list = roger_gitpull.utils.append_arguments(roger_gitpull.statsd_message_list, tools_version=version)
        sc = roger_gitpull.utils.getStatsClient()
        for item in statsd_message_list:
            sc.timing(item[0], item[1])
    except (Exception) as e:
        print("The following error occurred: %s" %
              e, file=sys.stderr)
class TestInit(unittest.TestCase):

    def setUp(self):
        self.gitObj = GitUtils()
        self.settingObj = Settings()
        self.base_dir = self.settingObj.getCliDir()
        self.configs_dir = self.base_dir + "/tests/configs"
        self.work_dir = self.base_dir + "/tests/work_dir"
        self.branch = "master"

    @pytest.mark.skip
    def test_gitPull(self):
        config_file = "app.json"
        work_dir = self.work_dir
        branch = self.branch

        if not os.path.exists(self.work_dir):
            try:
                os.makedirs(self.work_dir)
            except OSError as exception:
                if exception.errno != errno.EEXIST:
                    raise
        os.chdir(self.work_dir)
        with open(self.configs_dir + '/{}'.format(config_file)) as config:
            config = json.load(config)
        repo = config['repo']
        return_code = self.gitObj.gitClone(repo, branch)
        assert return_code == 0
        exists = os.path.exists(work_dir)
        assert exists is True
        os.chdir("{}/{}".format(work_dir, repo))
        return_code = self.gitObj.gitPull(self.branch)
        assert return_code == 0
        assert exists is True
        exists = os.path.exists("{}/{}".format(work_dir, repo))
        assert exists is True
        exists = os.path.exists("{}/{}/ansible".format(work_dir, repo))
        assert exists is True
        shutil.rmtree(work_dir)
        pass

    @pytest.mark.skip
    def test_gitShallowClone(self):
        config_file = "app.json"
        work_dir = self.work_dir
        branch = self.branch

        if not os.path.exists(self.work_dir):
            try:
                os.makedirs(self.work_dir)
            except OSError as exception:
                if exception.errno != errno.EEXIST:
                    raise
        os.chdir(self.work_dir)
        with open(self.configs_dir + '/{}'.format(config_file)) as config:
            config = json.load(config)
        repo = config['repo']
        verbose_mode = False
        return_code = self.gitObj.gitShallowClone(repo, branch, verbose_mode)
        assert return_code == 0
        exists = os.path.exists(work_dir)
        assert exists is True
        exists = os.path.exists("{}/{}".format(work_dir, repo))
        assert exists is True
        exists = os.path.exists("{}/{}/ansible".format(work_dir, repo))
        assert exists is True
        shutil.rmtree(work_dir)

    @pytest.mark.skip
    def test_gitClone(self):
        config_file = "app.json"
        work_dir = self.work_dir
        branch = self.branch

        if not os.path.exists(self.work_dir):
            try:
                os.makedirs(self.work_dir)
            except OSError as exception:
                if exception.errno != errno.EEXIST:
                    raise
        os.chdir(self.work_dir)
        with open(self.configs_dir + '/{}'.format(config_file)) as config:
            config = json.load(config)
        repo = config['repo']
        return_code = self.gitObj.gitClone(repo, branch)
        assert return_code == 0
        exists = os.path.exists(work_dir)
        assert exists is True
        exists = os.path.exists("{}/{}".format(work_dir, repo))
        assert exists is True
        exists = os.path.exists("{}/{}/ansible".format(work_dir, repo))
        assert exists is True
        shutil.rmtree(work_dir)

    def tearDown(self):
        pass