Esempio n. 1
0
def test_tasklets():
  install_thermosrc = Process(name='install_thermosrc')
  setup_py3k = Process(name='setup_py3k')
  setup_ruby19 = Process(name='setup_ruby19')
  setup_php = Process(name='setup_php')
  recipe_py3k = SequentialTask(processes=[install_thermosrc, setup_py3k])
  recipe_ruby19 = SequentialTask(processes=[install_thermosrc, setup_ruby19])
  recipe_php = SequentialTask(processes=[install_thermosrc, setup_php])
  all_recipes = Tasks.combine(recipe_py3k, recipe_ruby19, recipe_php)
  my_task = Task(processes = [Process(name='my_process')])
  my_new_task = Tasks.concat(all_recipes, my_task)(name = 'my_task')

  # TODO(wickman) Probably should have Tasks.combine/concat do constraint
  # minimization since many constraints are redundant.
  for p in (install_thermosrc, setup_py3k, setup_ruby19, setup_php):
    assert p in my_new_task.processes()
Esempio n. 2
0
    def task(cls):
        setup_bashrc = Process(name="setup_bashrc",
                               cmdline=dedent("""
    mkdir -p .profile.d
    cat <<EOF > .thermos_profile
    for i in .profile.d/*.sh ; do
      if [ -r "\\$i" ]; then
        . \\$i
      fi
    done
    EOF
    """))

        setup_foo = Process(name="setup_foo",
                            cmdline=dedent("""
    cat <<EOF > .profile.d/setup_foo.sh
    export FOO=1
    EOF
    """))

        setup_bar = Process(name="setup_bar",
                            cmdline=dedent("""
    cat <<EOF > .profile.d/setup_bar.sh
    export BAR=2
    EOF
    """))

        foo_recipe = SequentialTask(processes=[setup_bashrc, setup_foo])
        bar_recipe = SequentialTask(processes=[setup_bashrc, setup_bar])
        all_recipes = Tasks.combine(foo_recipe, bar_recipe)

        run = Process(name="run",
                      cmdline=dedent("""
    echo $FOO $BAR > expected_output.txt
    """))

        my_task = Task(processes=[run],
                       resources=Resources(cpu=1.0,
                                           ram=16 * 1024 * 1024,
                                           disk=16 * 1024))
        return Tasks.concat(all_recipes, my_task, name="my_task")
  def task(cls):
    setup_bashrc = Process(name = "setup_bashrc", cmdline = dedent(
    """
    mkdir -p .profile.d
    cat <<EOF > .thermos_profile
    for i in .profile.d/*.sh ; do
      if [ -r "\\$i" ]; then
        . \\$i
      fi
    done
    EOF
    """))

    setup_foo = Process(name = "setup_foo", cmdline = dedent(
    """
    cat <<EOF > .profile.d/setup_foo.sh
    export FOO=1
    EOF
    """))

    setup_bar = Process(name = "setup_bar", cmdline = dedent(
    """
    cat <<EOF > .profile.d/setup_bar.sh
    export BAR=2
    EOF
    """))

    foo_recipe = SequentialTask(processes = [setup_bashrc, setup_foo])
    bar_recipe = SequentialTask(processes = [setup_bashrc, setup_bar])
    all_recipes = Tasks.combine(foo_recipe, bar_recipe)

    run = Process(name = "run", cmdline = dedent(
    """
    echo $FOO $BAR > expected_output.txt
    """
    ))

    my_task = Task(processes = [run],
                   resources = Resources(cpu = 1.0, ram = 16*1024*1024, disk = 16*1024))
    return Tasks.concat(all_recipes, my_task, name = "my_task")