Ejemplo n.º 1
0
def test_get_config_announces():
    for good_config in (MESOS_CONFIG_WITH_ANNOUNCE_1,
                        MESOS_CONFIG_WITH_ANNOUNCE_2,
                        MESOS_CONFIG_WITHOUT_ANNOUNCE):

        bio = BytesIO(good_config)
        get_aurora_config('hello_world', bio).job()
Ejemplo n.º 2
0
def test_get_config_announces():
  for good_config in (
      MESOS_CONFIG_WITH_ANNOUNCE_1,
      MESOS_CONFIG_WITH_ANNOUNCE_2,
      MESOS_CONFIG_WITHOUT_ANNOUNCE):

    bio = BytesIO(good_config)
    get_aurora_config('hello_world', bio).job()
Ejemplo n.º 3
0
def test_get_config_with_broken_subscopes():
    bad_config = MESOS_CONFIG_BASE % {
        'cmdline': 'echo {{hello[{{thermos.ports[http]}}]}}',
        'announce': '',
    }
    bio = BytesIO(bad_config)
    with pytest.raises(AuroraConfig.InvalidConfig) as cm:
        get_aurora_config('hello_world', bio).job()
    assert 'Unexpected unbound refs' in str(cm.value.message)
Ejemplo n.º 4
0
def test_get_config_with_broken_subscopes():
  bad_config = MESOS_CONFIG_BASE % {
      'cmdline': 'echo {{hello[{{thermos.ports[http]}}]}}',
      'announce': '',
  }
  bio = BytesIO(bad_config)
  with pytest.raises(AuroraConfig.InvalidConfig) as cm:
    get_aurora_config('hello_world', bio).job()
  assert 'Unexpected unbound refs' in str(cm.value.message)
Ejemplo n.º 5
0
def test_get_config_mapped_primary_port(capsys):
  config_mapped_primary_port = MESOS_CONFIG_BASE % {
    'cmdline': 'echo {{thermos.ports[custom]}}',
    'announce': 'announce = Announcer(primary_port = "http", portmap = {"http": "custom"}),'
  }
  get_aurora_config('hello_world', BytesIO(config_mapped_primary_port)).job()
  out, err = capsys.readouterr()

  assert err == ""  # No warning about unbound primary port
  assert out == ""
Ejemplo n.º 6
0
def test_get_config_primary_port_warning(capsys):
  config_unbound_primary_port = MESOS_CONFIG_BASE % {
    'cmdline': 'echo {{thermos.ports[http]}}',
    'announce': 'announce = Announcer(primary_port = "custom", portmap = {}),'
  }
  get_aurora_config('hello_world', BytesIO(config_unbound_primary_port)).job()
  _, err = capsys.readouterr()

  msg = "Announcer specified primary port as 'custom' but no processes have bound that port"
  assert msg in err
Ejemplo n.º 7
0
def test_get_config_primary_port_warning(capsys):
    config_unbound_primary_port = MESOS_CONFIG_BASE % {
        'cmdline': 'echo {{thermos.ports[http]}}',
        'announce':
        'announce = Announcer(primary_port = "custom", portmap = {}),'
    }
    get_aurora_config('hello_world',
                      BytesIO(config_unbound_primary_port)).job()
    _, err = capsys.readouterr()

    msg = "Announcer specified primary port as 'custom' but no processes have bound that port"
    assert msg in err
Ejemplo n.º 8
0
def test_get_config_mapped_primary_port(capsys):
    config_mapped_primary_port = MESOS_CONFIG_BASE % {
        'cmdline':
        'echo {{thermos.ports[custom]}}',
        'announce':
        'announce = Announcer(primary_port = "http", portmap = {"http": "custom"}),'
    }
    get_aurora_config('hello_world', BytesIO(config_mapped_primary_port)).job()
    out, err = capsys.readouterr()

    assert err == ""  # No warning about unbound primary port
    assert out == ""
Ejemplo n.º 9
0
def test_get_config_select():
    bio = BytesIO(MESOS_CONFIG_WITHOUT_ANNOUNCE)

    get_aurora_config(
        "hello_world", bio, select_env="test", select_role="john_doe", select_cluster="test-cluster"
    ).job()

    bio.seek(0)

    with pytest.raises(ValueError) as cm:
        get_aurora_config(
            "hello_world", bio, select_env="staging42", select_role="moua", select_cluster="test-cluster"
        ).job()

    assert "test-cluster/john_doe/test/hello_world" in str(cm.value.message)
Ejemplo n.º 10
0
def test_include():
    with temporary_dir() as dir:
        hello_mesos_fname = "hello_world.mesos"
        hello_mesos_path = os.path.join(dir, hello_mesos_fname)
        with open(os.path.join(dir, hello_mesos_path), "wb") as hello_world_mesos:
            hello_world_mesos.write(MESOS_CONFIG_WITHOUT_ANNOUNCE)
            hello_world_mesos.flush()

            hello_include_fname_path = os.path.join(dir, "hello_include_fname.mesos")
            with open(hello_include_fname_path, "wb+") as hello_include_fname_fp:
                hello_include_fname_fp.write(MESOS_CONFIG_WITH_INCLUDE % ("", """'%s'""" % hello_mesos_fname))
                hello_include_fname_fp.flush()

                get_aurora_config("hello_world", hello_include_fname_path)

                hello_include_fname_fp.seek(0)
                with pytest.raises(AuroraConfigLoader.InvalidConfigError):
                    get_aurora_config("hello_world", hello_include_fname_fp)
Ejemplo n.º 11
0
def test_get_config_select():
    bio = BytesIO(MESOS_CONFIG_WITHOUT_ANNOUNCE)

    get_aurora_config('hello_world',
                      bio,
                      select_env='test',
                      select_role='john_doe',
                      select_cluster='test-cluster').job()

    bio.seek(0)

    with pytest.raises(ValueError) as cm:
        get_aurora_config('hello_world',
                          bio,
                          select_env='staging42',
                          select_role='moua',
                          select_cluster='test-cluster').job()

    assert 'test-cluster/john_doe/test/hello_world' in str(cm.value.message)
Ejemplo n.º 12
0
def test_get_config_select():
  bio = BytesIO(MESOS_CONFIG_WITHOUT_ANNOUNCE)

  get_aurora_config(
      'hello_world',
      bio,
      select_env='test',
      select_role='john_doe',
      select_cluster='test-cluster').job()

  bio.seek(0)

  with pytest.raises(ValueError) as cm:
    get_aurora_config(
        'hello_world',
        bio,
        select_env='staging42',
        select_role='moua',
        select_cluster='test-cluster').job()

  assert 'test-cluster/john_doe/test/hello_world' in str(cm.value.message)
Ejemplo n.º 13
0
def test_include():
    with temporary_dir() as dir:
        hello_mesos_fname = "hello_world.mesos"
        hello_mesos_path = os.path.join(dir, hello_mesos_fname)
        with open(os.path.join(dir, hello_mesos_path),
                  "wb") as hello_world_mesos:
            hello_world_mesos.write(MESOS_CONFIG_WITHOUT_ANNOUNCE)
            hello_world_mesos.flush()

            hello_include_fname_path = os.path.join(
                dir, "hello_include_fname.mesos")
            with open(hello_include_fname_path,
                      "wb+") as hello_include_fname_fp:
                hello_include_fname_fp.write(
                    MESOS_CONFIG_WITH_INCLUDE %
                    ("", """'%s'""" % hello_mesos_fname))
                hello_include_fname_fp.flush()

                get_aurora_config('hello_world', hello_include_fname_path)

                hello_include_fname_fp.seek(0)
                with pytest.raises(AuroraConfigLoader.InvalidConfigError):
                    get_aurora_config('hello_world', hello_include_fname_fp)
Ejemplo n.º 14
0
def test_get_config_with_broken_subscopes():
    bad_config = MESOS_CONFIG_BASE % {"cmdline": "echo {{hello[{{thermos.ports[http]}}]}}", "announce": ""}
    bio = BytesIO(bad_config)
    with pytest.raises(AuroraConfig.InvalidConfig) as cm:
        get_aurora_config("hello_world", bio).job()
    assert "Unexpected unbound refs" in str(cm.value.message)