Esempio n. 1
0
    def test_serve_daemon(self):
        """Test serving a galaxy tool via a daemon Galaxy process."""
        port = network_util.get_free_port()
        cat_path = os.path.join(TEST_REPOS_DIR, "single_tool", "cat.xml")
        config = galaxy_serve(
            self.test_context,
            [for_path(cat_path)],
            install_galaxy=True,
            port=port,
            daemon=True,
            no_dependency_resolution=True,
        )

        assert network_util.wait_net_service(
            "localhost",
            config.port,
            timeout=.1,
        )
        config_dict = config.gi.config.get_config()
        assert "allow_user_dataset_purge" in config_dict
        config.kill()
        assert not network_util.wait_net_service(
            "localhost",
            config.port,
            timeout=.1,
        )
Esempio n. 2
0
    def test_serve_daemon(self):
        """Test serving a galaxy tool via a daemon Galaxy process."""
        port = network_util.get_free_port()
        cat_path = os.path.join(TEST_REPOS_DIR, "single_tool", "cat.xml")
        config = galaxy_serve(
            self.test_context,
            [for_path(cat_path)],
            install_galaxy=True,
            port=port,
            daemon=True,
            no_dependency_resolution=True,
        )

        assert network_util.wait_net_service(
            "localhost",
            config.port,
            timeout=.1,
        )
        config_dict = config.gi.config.get_config()
        assert "allow_user_dataset_purge" in config_dict
        config.kill()
        assert not network_util.wait_net_service(
            "localhost",
            config.port,
            timeout=.1,
        )
 def test_serve(self):
     port = network_util.get_free_port()
     serve = functools.partial(self._run, port)
     t = threading.Thread(target=serve)
     t.daemon = True
     t.start()
     time.sleep(15)
     assert network_util.wait_net_service("127.0.0.1", port)
Esempio n. 4
0
 def test_serve(self):
     port = network_util.get_free_port()
     serve = functools.partial(self._run, port)
     t = threading.Thread(target=serve)
     t.daemon = True
     t.start()
     time.sleep(15)
     assert network_util.wait_net_service("127.0.0.1", port)
Esempio n. 5
0
 def test_serve_daemon(self):
     port = network_util.get_free_port()
     pid_file = os.path.join(self._home, "test.pid")
     extra_args = ["--daemon", "--pid_file", pid_file]
     serve = functools.partial(self._run, port, extra_args)
     self._launch_thread_and_wait(serve, port)
     admin_gi = api.gi(port)
     user_api_key = api.user_api_key(admin_gi)
     user_gi = api.gi(port, user_api_key)
     assert len(user_gi.histories.get_histories(name=TEST_HISTORY_NAME)) == 0
     user_gi.histories.create_history(TEST_HISTORY_NAME)
Esempio n. 6
0
 def test_serve_daemon(self):
     port = network_util.get_free_port()
     pid_file = os.path.join(self._home, "test.pid")
     extra_args = ["--daemon", "--pid_file", pid_file]
     serve = functools.partial(self._run, port, extra_args)
     self._launch_thread_and_wait(serve, port)
     admin_gi = api.gi(port)
     user_api_key = api.user_api_key(admin_gi)
     user_gi = api.gi(port, user_api_key)
     assert len(
         user_gi.histories.get_histories(name=TEST_HISTORY_NAME)) == 0
     user_gi.histories.create_history(TEST_HISTORY_NAME)
Esempio n. 7
0
 def test_serve_daemon(self):
     """Test serving a galaxy tool via a daemon Galaxy process."""
     port = network_util.get_free_port()
     cat_path = os.path.join(TEST_REPOS_DIR, "single_tool", "cat.xml")
     config = galaxy_serve(
         self.test_context,
         [for_path(cat_path)],
         install_galaxy=True,
         galaxy_branch=target_galaxy_branch(),
         port=port,
         daemon=True,
         no_dependency_resolution=True,
     )
     _assert_service_up(config)
     config.kill()
     _assert_service_down(config)
Esempio n. 8
0
def _serve(ctx, runnables, **kwds):
    engine = kwds.get("engine", "galaxy")
    if engine == "docker_galaxy":
        kwds["dockerize"] = True

    daemon = kwds.get("daemon", False)
    if daemon:
        kwds["no_cleanup"] = True

    port = kwds.get("port", None)
    if port is None:
        port = network_util.get_free_port()
        kwds["port"] = port

    with galaxy_config(ctx, runnables, **kwds) as config:
        cmd = config.startup_command(ctx, **kwds)
        action = "Starting galaxy"
        exit_code = run_galaxy_command(
            ctx,
            cmd,
            config.env,
            action,
        )
        if exit_code:
            message = "Problem running Galaxy command [%s]." % config.log_contents
            io.warn(message)
            raise Exception(message)
        host = kwds.get("host", "127.0.0.1")
        timeout = 500
        galaxy_url = "http://%s:%s" % (host, port)
        ctx.vlog("Waiting for service on (%s, %s)" % (host, port))
        assert network_util.wait_http_service(galaxy_url, timeout=timeout)
        time.sleep(.1)
        ctx.vlog("Waiting for service on (%s, %s)" % (host, port))
        assert network_util.wait_http_service(galaxy_url)
        time.sleep(5)
        ctx.vlog("Waiting for service on (%s, %s)" % (host, port))
        assert network_util.wait_http_service(galaxy_url)
        config.install_workflows()
        if kwds.get("pid_file"):
            real_pid_file = config.pid_file
            if os.path.exists(config.pid_file):
                os.symlink(real_pid_file, kwds["pid_file"])
            else:
                io.warn("Can't find Galaxy pid file [%s] to link" % real_pid_file)
        return config
Esempio n. 9
0
def setup_mock_shed():
    port = network_util.get_free_port()
    directory = mkdtemp()
    model = mock_model(directory)

    def run():
        app.debug = True
        app.config["model"] = model
        run_simple('localhost',
                   port,
                   app,
                   use_reloader=False,
                   use_debugger=True)

    t = threading.Thread(target=run)
    t.start()
    network_util.wait_net_service("localhost", port, DEFAULT_OP_TIMEOUT)
    return MockShed("http://localhost:%d" % port, directory, t, model)
Esempio n. 10
0
 def test_shed_serve_daemon(self):
     """Test serving FASTQC from the tool shed via a daemon Galaxy process."""
     port = network_util.get_free_port()
     fastqc_path = os.path.join(TEST_REPOS_DIR, "fastqc")
     ctx = self.test_context
     install_args_list = shed.install_arg_lists(
         ctx,
         [fastqc_path],
         shed_target="toolshed",
     )
     with shed_serve(
             ctx,
             install_args_list,
             port=port,
             skip_dependencies=True,
             install_galaxy=True,
             galaxy_branch=target_galaxy_branch(),
     ) as config:
         _assert_service_up(config)
Esempio n. 11
0
 def test_serve_workflow(self):
     """Test serving a galaxy workflow via a daemon Galaxy process."""
     port = network_util.get_free_port()
     random_lines = os.path.join(PROJECT_TEMPLATES_DIR, "demo", "randomlines.xml")
     cat = os.path.join(PROJECT_TEMPLATES_DIR, "demo", "cat.xml")
     worklfow = os.path.join(TEST_DATA_DIR, "wf1.gxwf.yml")
     extra_tools = [random_lines, cat]
     config = galaxy_serve(
         self.test_context,
         [for_path(worklfow)],
         install_galaxy=True,
         port=port,
         daemon=True,
         extra_tools=extra_tools,
     )
     user_gi = config.user_gi
     assert user_gi.tools.get_tools(tool_id="random_lines1")
     assert len(user_gi.workflows.get_workflows()) == 1
     config.kill()
Esempio n. 12
0
 def test_shed_serve_daemon(self):
     port = network_util.get_free_port()
     fastqc_path = os.path.join(TEST_REPOS_DIR, "fastqc")
     ctx = self.test_context
     install_args_list = shed.install_arg_lists(
         ctx, [fastqc_path],
         shed_target="toolshed",
     )
     with shed_serve(
         ctx, install_args_list,
         port=port,
         skip_dependencies=True,
         install_galaxy=True,
     ) as config:
         assert network_util.wait_net_service(
             "localhost",
             config.port,
             timeout=.1,
         )
Esempio n. 13
0
def _serve(ctx, runnables, **kwds):
    engine = kwds.get("engine", "galaxy")
    if engine == "docker_galaxy":
        kwds["dockerize"] = True

    daemon = kwds.get("daemon", False)
    if daemon:
        kwds["no_cleanup"] = True

    port = kwds.get("port", None)
    if port is None:
        port = network_util.get_free_port()
        kwds["port"] = port

    with galaxy_config(ctx, runnables, **kwds) as config:
        cmd = config.startup_command(ctx, **kwds)
        action = "Starting Galaxy"
        exit_code = run_galaxy_command(
            ctx,
            cmd,
            config.env,
            action,
        )
        if exit_code:
            message = "Problem running Galaxy command [%s]." % config.log_contents
            io.warn(message)
            raise Exception(message)
        host = kwds.get("host", "127.0.0.1")

        timeout = 500
        galaxy_url = "http://%s:%s" % (host, port)
        galaxy_alive = sleep(galaxy_url, verbose=ctx.verbose, timeout=timeout)
        if not galaxy_alive:
            raise Exception("Attempted to serve Galaxy at %s, but it failed to start in %d seconds." % (galaxy_url, timeout))
        config.install_workflows()
        if kwds.get("pid_file"):
            real_pid_file = config.pid_file
            if os.path.exists(config.pid_file):
                os.symlink(real_pid_file, kwds["pid_file"])
            else:
                io.warn("Can't find Galaxy pid file [%s] to link" % real_pid_file)
        return config
Esempio n. 14
0
def setup_mock_shed():
    port = network_util.get_free_port()
    directory = mkdtemp()
    model = mock_model(directory)

    def run():
        app.debug = True
        app.config["model"] = model
        run_simple(
            'localhost',
            port,
            app,
            use_reloader=False,
            use_debugger=True
        )

    t = threading.Thread(target=run)
    t.start()
    network_util.wait_net_service("localhost", port, DEFAULT_OP_TIMEOUT)
    return MockShed("http://localhost:%d" % port, directory, t, model)
Esempio n. 15
0
def _serve(ctx, runnables, **kwds):
    engine = kwds.get("engine", "galaxy")
    if engine == "docker_galaxy":
        kwds["dockerize"] = True

    daemon = kwds.get("daemon", False)
    if daemon:
        kwds["no_cleanup"] = True

    with galaxy_config(ctx, runnables, **kwds) as config:
        cmd = config.startup_command(ctx, **kwds)
        action = "Starting galaxy"
        exit_code = run_galaxy_command(
            ctx,
            cmd,
            config.env,
            action,
        )
        if exit_code:
            message = "Problem running Galaxy command [%s]." % config.log_contents
            io.warn(message)
            raise Exception(message)
        host = kwds.get("host", "127.0.0.1")
        port = kwds.get("port", None)
        if port is None:
            port = network_util.get_free_port()

        ctx.vlog("Waiting for service on (%s, %s)" % (host, port))
        assert network_util.wait_net_service(host, port)
        time.sleep(.1)
        ctx.vlog("Waiting for service on (%s, %s)" % (host, port))
        assert network_util.wait_net_service(host, port)
        time.sleep(5)
        ctx.vlog("Waiting for service on (%s, %s)" % (host, port))
        assert network_util.wait_net_service(host, port)
        config.install_workflows()
        return config
Esempio n. 16
0
def _serve(ctx, runnables, **kwds):
    engine = kwds.get("engine", "galaxy")
    if engine == "docker_galaxy":
        kwds["dockerize"] = True

    daemon = kwds.get("daemon", False)
    if daemon:
        kwds["no_cleanup"] = True

    with galaxy_config(ctx, runnables, **kwds) as config:
        cmd = config.startup_command(ctx, **kwds)
        action = "Starting galaxy"
        exit_code = run_galaxy_command(
            ctx,
            cmd,
            config.env,
            action,
        )
        if exit_code:
            message = "Problem running Galaxy command [%s]." % config.log_contents
            io.warn(message)
            raise Exception(message)
        host = kwds.get("host", "127.0.0.1")
        port = kwds.get("port", None)
        if port is None:
            port = network_util.get_free_port()

        ctx.vlog("Waiting for service on (%s, %s)" % (host, port))
        assert network_util.wait_net_service(host, port)
        time.sleep(.1)
        ctx.vlog("Waiting for service on (%s, %s)" % (host, port))
        assert network_util.wait_net_service(host, port)
        time.sleep(5)
        ctx.vlog("Waiting for service on (%s, %s)" % (host, port))
        assert network_util.wait_net_service(host, port)
        config.install_workflows()
        return config
Esempio n. 17
0
    def test_serve_daemon(self):
        port = network_util.get_free_port()
        cat_path = os.path.join(TEST_REPOS_DIR, "single_tool", "cat.xml")
        config = galaxy_serve(
            self.test_context,
            cat_path,
            install_galaxy=True,
            port=port,
            daemon=True,
        )

        assert network_util.wait_net_service(
            "localhost",
            config.port,
            timeout=.1,
        )
        config_dict = config.gi.config.get_config()
        assert "allow_user_dataset_purge" in config_dict
        config.kill()
        assert not network_util.wait_net_service(
            "localhost",
            config.port,
            timeout=.1,
        )
Esempio n. 18
0
 def setUp(self):
     super(ServeTestCase, self).setUp()
     self._port = network_util.get_free_port()
     self._pid_file = os.path.join(self._home, "test.pid")
     self._serve_artifact = os.path.join(TEST_REPOS_DIR, "single_tool",
                                         "cat.xml")
Esempio n. 19
0
 def setUp(self):
     super(CmdsWithWorkflowIdTestCase, self).setUp()
     self._port = network_util.get_free_port()
     self._pid_file = os.path.join(self._home, "test.pid")
Esempio n. 20
0
 def test_serve(self):
     port = network_util.get_free_port()
     serve = functools.partial(self._run, port)
     self._launch_thread_and_wait(serve, port)
Esempio n. 21
0
 def test_serve(self):
     port = network_util.get_free_port()
     serve = functools.partial(self._run, port)
     self._launch_thread_and_wait(serve, port)
Esempio n. 22
0
 def setUp(self):
     super(ServeTestCase, self).setUp()
     self._port = network_util.get_free_port()
     self._pid_file = os.path.join(self._home, "test.pid")
     self._serve_artifact = os.path.join(TEST_REPOS_DIR, "single_tool", "cat.xml")