Example #1
0
    def test_write_new_file_env_procfile_path(self):
        os.environ["PROCFILE_PATH"] = self.procfile_path + "2"

        def clean():
            del os.environ["PROCFILE_PATH"]
        expected_file = u"""
[watcher:web]
cmd = python run_their_app.py -p 8888
copy_env = True
uid = ubuntu
gid = ubuntu
working_dir = /home/application/current
stdout_stream.class = tsuru.stream.Stream
stdout_stream.watcher_name = web
stderr_stream.class = tsuru.stream.Stream
stderr_stream.watcher_name = web

[watcher:worker]
cmd = python run_their_worker.py
copy_env = True
uid = ubuntu
gid = ubuntu
working_dir = /home/application/current
stdout_stream.class = tsuru.stream.Stream
stdout_stream.watcher_name = worker
stderr_stream.class = tsuru.stream.Stream
stderr_stream.watcher_name = worker
"""
        conf_path = self.conf_path + ".new"
        write_circus_conf(conf_path=conf_path, envs={"PORT": "8888"})
        self.addCleanup(os.remove, conf_path)
        got_file = open(conf_path).read()
        self.assertEqual(expected_file, got_file)
Example #2
0
    def test_write_new_file_env_procfile_path(self):
        os.environ["PROCFILE_PATH"] = self.procfile_path + "2"

        def clean():
            del os.environ["PROCFILE_PATH"]

        expected_file = u"""
[watcher:web]
cmd = python run_their_app.py -p 8888
copy_env = True
uid = ubuntu
gid = ubuntu
working_dir = /home/application/current
stdout_stream.class = tsuru.stream.Stream
stdout_stream.watcher_name = web
stderr_stream.class = tsuru.stream.Stream
stderr_stream.watcher_name = web

[watcher:worker]
cmd = python run_their_worker.py
copy_env = True
uid = ubuntu
gid = ubuntu
working_dir = /home/application/current
stdout_stream.class = tsuru.stream.Stream
stdout_stream.watcher_name = worker
stderr_stream.class = tsuru.stream.Stream
stderr_stream.watcher_name = worker
"""
        conf_path = self.conf_path + ".new"
        write_circus_conf(conf_path=conf_path, envs={"PORT": "8888"})
        self.addCleanup(os.remove, conf_path)
        got_file = open(conf_path).read()
        self.assertEqual(expected_file, got_file)
Example #3
0
    def test_write_new_file_env_working_dir(self):
        os.environ["APP_WORKING_DIR"] = "/tmp/app"

        def clean():
            del os.environ["APP_WORKING_DIR"]
        self.addCleanup(clean)
        expected_file = u"""
[watcher:web]
cmd = python run_my_app.py -p 8888 -l 8989
copy_env = True
uid = ubuntu
gid = ubuntu
working_dir = /tmp/app
stdout_stream.class = tsuru.stream.Stream
stdout_stream.watcher_name = web
stderr_stream.class = tsuru.stream.Stream
stderr_stream.watcher_name = web

[watcher:worker]
cmd = python run_my_worker.py
copy_env = True
uid = ubuntu
gid = ubuntu
working_dir = /tmp/app
stdout_stream.class = tsuru.stream.Stream
stdout_stream.watcher_name = worker
stderr_stream.class = tsuru.stream.Stream
stderr_stream.watcher_name = worker
"""
        conf_path = self.conf_path + ".new"
        write_circus_conf(procfile_path=self.procfile_path,
                          conf_path=conf_path, envs={"PORT": "8888"})
        self.addCleanup(os.remove, conf_path)
        got_file = open(conf_path).read()
        self.assertEqual(expected_file, got_file)
Example #4
0
    def test_write_file(self):
        expected_file = open(self.conf_path).read()
        expected_file += u"""
[watcher:web]
cmd = python run_my_app.py -p 8888 -l 8989
copy_env = True
uid = ubuntu
gid = ubuntu
working_dir = /home/application/current
stdout_stream.class = tsuru.stream.Stream
stdout_stream.watcher_name = web
stderr_stream.class = tsuru.stream.Stream
stderr_stream.watcher_name = web

[watcher:worker]
cmd = python run_my_worker.py
copy_env = True
uid = ubuntu
gid = ubuntu
working_dir = /home/application/current
stdout_stream.class = tsuru.stream.Stream
stdout_stream.watcher_name = worker
stderr_stream.class = tsuru.stream.Stream
stderr_stream.watcher_name = worker
"""
        write_circus_conf(procfile_path=self.procfile_path, conf_path=self.conf_path,
                          envs={"PORT": "8888"})
        got_file = open(self.conf_path).read()
        self.assertEqual(expected_file, got_file)
Example #5
0
    def test_write_file(self):
        expected_file = open(self.conf_path).read()
        expected_file += u"""
[watcher:web]
cmd = python run_my_app.py -p 8888 -l 8989
copy_env = True
uid = ubuntu
gid = ubuntu
working_dir = /home/application/current
stdout_stream.class = tsuru.stream.Stream
stdout_stream.watcher_name = web
stderr_stream.class = tsuru.stream.Stream
stderr_stream.watcher_name = web

[watcher:worker]
cmd = python run_my_worker.py
copy_env = True
uid = ubuntu
gid = ubuntu
working_dir = /home/application/current
stdout_stream.class = tsuru.stream.Stream
stdout_stream.watcher_name = worker
stderr_stream.class = tsuru.stream.Stream
stderr_stream.watcher_name = worker
"""
        write_circus_conf(procfile_path=self.procfile_path,
                          conf_path=self.conf_path,
                          envs={"PORT": "8888"})
        got_file = open(self.conf_path).read()
        self.assertEqual(expected_file, got_file)
Example #6
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)
Example #7
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)
Example #8
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)
Example #9
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()
Example #10
0
    def test_write_new_file_env_working_dir(self):
        os.environ["APP_WORKING_DIR"] = "/tmp/app"

        def clean():
            del os.environ["APP_WORKING_DIR"]

        self.addCleanup(clean)
        expected_file = u"""
[watcher:web]
cmd = python run_my_app.py -p 8888 -l 8989
copy_env = True
uid = ubuntu
gid = ubuntu
working_dir = /tmp/app
stdout_stream.class = tsuru.stream.Stream
stdout_stream.watcher_name = web
stderr_stream.class = tsuru.stream.Stream
stderr_stream.watcher_name = web

[watcher:worker]
cmd = python run_my_worker.py
copy_env = True
uid = ubuntu
gid = ubuntu
working_dir = /tmp/app
stdout_stream.class = tsuru.stream.Stream
stdout_stream.watcher_name = worker
stderr_stream.class = tsuru.stream.Stream
stderr_stream.watcher_name = worker
"""
        conf_path = self.conf_path + ".new"
        write_circus_conf(procfile_path=self.procfile_path,
                          conf_path=conf_path,
                          envs={"PORT": "8888"})
        self.addCleanup(os.remove, conf_path)
        got_file = open(conf_path).read()
        self.assertEqual(expected_file, got_file)
Example #11
0
 def test_write_file_no_watchers(self):
     expected_file = open(self.conf_path).read()
     write_circus_conf(procfile_path=self.procfile_path + ".empty",
                       conf_path=self.conf_path)
     got_file = open(self.conf_path).read()
     self.assertEqual(expected_file, got_file)
Example #12
0
 def test_write_file_no_watchers(self):
     expected_file = open(self.conf_path).read()
     write_circus_conf(procfile_path=self.procfile_path + ".empty",
                       conf_path=self.conf_path)
     got_file = open(self.conf_path).read()
     self.assertEqual(expected_file, got_file)