예제 #1
0
    def test_load_app_yaml(self):
        filenames = ["tsuru.yaml", "tsuru.yml", "app.yaml", "app.yml"]
        for name in filenames:
            with open(os.path.join(self.working_dir, name), "w") as f:
                f.write(self.data.format(name))

        for name in filenames:
            data = load_app_yaml(self.working_dir)
            self.assertEqual(data, {"hooks": {"build": ["{}_1".format(name),
                                                        "{}_2".format(name)]}})
            os.remove(os.path.join(self.working_dir, name))
예제 #2
0
    def test_load_broken_yaml(self):
        broken_yaml = '''
hooks:
\tbuild:
\t\t- foo_1
\t\t- bar_2
        '''
        with open(os.path.join(self.working_dir, "tsuru.yaml"), "w") as f:
            f.write(broken_yaml)
        data = load_app_yaml(self.working_dir)
        self.assertEqual(data, {})
        os.remove(os.path.join(self.working_dir, "tsuru.yaml"))
예제 #3
0
def deploy_action(args):
    heartbeat.StderrHeartbeat().start()
    client = Client(args.url, args.token)
    envs = client.register_unit(args.app_name)
    tasks.save_apprc_file(envs)
    tasks.execute_start_script(args.start_cmd)
    yaml_data = tasks.load_app_yaml()
    yaml_data["procfile"] = tasks.load_procfile()
    client.register_unit(args.app_name, yaml_data)
    client.post_app_yaml(args.app_name, yaml_data)
    tasks.run_build_hooks(yaml_data, envs=envs)
    tasks.write_circus_conf(envs=envs)
예제 #4
0
    def test_load_broken_yaml(self):
        broken_yaml = '''
hooks:
\tbuild:
\t\t- foo_1
\t\t- bar_2
        '''
        with open(os.path.join(self.working_dir, "tsuru.yaml"), "w") as f:
            f.write(broken_yaml)
        data = load_app_yaml(self.working_dir)
        self.assertEqual(data, {})
        os.remove(os.path.join(self.working_dir, "tsuru.yaml"))
예제 #5
0
def run_action(args):
    client = Client(args.url, args.token)
    envs = None
    try:
        envs = client.register_unit(args.app_name)
        tasks.save_apprc_file(envs)
    except ConnectionError:
        envs = tasks.parse_apprc_file()
    yaml_data = tasks.load_app_yaml()
    tasks.write_circus_conf(envs=envs)
    tasks.run_restart_hooks('before', yaml_data, envs=envs)
    tasks.execute_start_script(args.start_cmd, envs=envs, with_shell=False)
    tasks.run_restart_hooks('after', yaml_data, envs=envs)
예제 #6
0
    def test_load_app_yaml(self):
        filenames = ["tsuru.yaml", "tsuru.yml", "app.yaml", "app.yml"]
        for name in filenames:
            with open(os.path.join(self.working_dir, name), "w") as f:
                f.write(self.data.format(name))

        for name in filenames:
            data = load_app_yaml(self.working_dir)
            self.assertEqual(data, {
                "hooks": {
                    "build": ["{}_1".format(name), "{}_2".format(name)]
                }
            })
            os.remove(os.path.join(self.working_dir, name))
예제 #7
0
def deploy_action(args):
    heartbeat.StderrHeartbeat().start()
    client = Client(args.url, args.token)
    envs, supported_tsuru = client.register_unit(args.app_name)
    save_apprc_file(envs, supported_tsuru)
    tasks.execute_start_script(args.start_cmd)
    yaml_data = tasks.load_app_yaml()
    client.post_app_yaml(args.app_name, yaml_data)
    tasks.run_build_hooks(yaml_data, envs=envs)
    remove_temp_env_file()
    yaml_data["procfile"] = tasks.load_procfile()
    yaml_data["processes"] = tasks.parse_procfile()
    client.register_unit(args.app_name, yaml_data)
    tasks.write_circus_conf(envs=envs)
예제 #8
0
def run_action(args):
    client = Client(args.url, args.token)
    envs = None
    try:
        envs, supported_tsuru = client.register_unit(args.app_name)
        save_apprc_file(envs, supported_tsuru)
    except ConnectionError:
        envs = tasks.parse_apprc_file()
    yaml_data = tasks.load_app_yaml()
    tasks.write_circus_conf(envs=envs)
    tasks.run_restart_hooks('before', yaml_data, envs=envs)
    tasks.execute_start_script(args.start_cmd, envs=envs, with_shell=False)
    tasks.run_restart_hooks('after', yaml_data, envs=envs)
    remove_temp_env_file()
예제 #9
0
 def test_load_yaml_encoding(self):
     data = load_app_yaml(os.path.join(self.working_dir, "fixtures/iso88591"))
     self.assertEqual(data, {"key": "x"})
     data = load_app_yaml(os.path.join(self.working_dir, "fixtures/utf-8"))
     self.assertEqual(data, {"key": u"áéíãôüx"})
예제 #10
0
 def test_load_with_empty_yaml(self):
     with open(os.path.join(self.working_dir, "tsuru.yaml"), "w") as f:
         f.write("")
     data = load_app_yaml(self.working_dir)
     self.assertEqual(data, {})
     os.remove(os.path.join(self.working_dir, "tsuru.yaml"))
예제 #11
0
 def test_load_without_app_files(self):
     data = load_app_yaml(self.working_dir)
     self.assertEqual(data, {})
예제 #12
0
 def test_load_yaml_encoding(self):
     data = load_app_yaml(
         os.path.join(self.working_dir, "fixtures/iso88591"))
     self.assertEqual(data, {"key": "x"})
     data = load_app_yaml(os.path.join(self.working_dir, "fixtures/utf-8"))
     self.assertEqual(data, {"key": u"áéíãôüx"})
예제 #13
0
 def test_load_with_empty_yaml(self):
     with open(os.path.join(self.working_dir, "tsuru.yaml"), "w") as f:
         f.write("")
     data = load_app_yaml(self.working_dir)
     self.assertEqual(data, {})
     os.remove(os.path.join(self.working_dir, "tsuru.yaml"))
예제 #14
0
 def test_load_without_app_files(self):
     data = load_app_yaml(self.working_dir)
     self.assertEqual(data, {})