Exemplo n.º 1
0
 def test_roster_domain(self):
     """Test that when roster_domain is configured, it will provide a default hostname
     in the roster of {filename}.{roster_domain}, so that users can use the minion
     id as the local hostname without having to supply the fqdn everywhere."""
     expected = EXPECTED['domain']
     ret = dir_.targets(expected.keys(), 'list', saltenv='')
     self._test_match(ret, expected)
Exemplo n.º 2
0
def test_roster_domain(expected, create_roster_files):
    """Test that when roster_domain is configured, it will provide a default hostname
    in the roster of {filename}.{roster_domain}, so that users can use the minion
    id as the local hostname without having to supply the fqdn everywhere."""
    expected = expected["domain"]
    ret = dir_.targets(expected.keys(), "list", saltenv="")
    _test_match(ret, expected)
Exemplo n.º 3
0
 def test_nomatch(self):
     """Test that no errors happen when no files match"""
     try:
         ret = dir_.targets('', saltenv='')
     except:
         self.fail('No files matched, which is OK, but we raised an exception and we should not have.')
         raise
     self.assertEqual(len(ret), 0, 'Expected empty target list to yield zero targets.')
Exemplo n.º 4
0
def test_nomatch(create_roster_files):
    """Test that no errors happen when no files match"""
    try:
        ret = dir_.targets("", saltenv="")
    except:  # pylint: disable=bare-except
        pytest.fail(
            "No files matched, which is OK, but we raised an exception and we should not have."
        )
    assert len(ret) == 0, "Expected empty target list to yield zero targets."
Exemplo n.º 5
0
def test_badfile_logging(caplog, create_roster_files):
    """Test error handling when we can't render a file"""
    with caplog.at_level(logging.WARNING, logger="salt.roster.dir"):
        dir_.targets("*badfile", saltenv="")
        assert "test1_us-east-2_test_badfile" in caplog.text
Exemplo n.º 6
0
def test_badfile(create_roster_files):
    """Test error handling when we can't render a file"""
    ret = dir_.targets("*badfile", saltenv="")
    assert len(ret) == 0
Exemplo n.º 7
0
def test_empty(expected, create_roster_files):
    """Test that an empty roster file matches its hostname"""
    expected = expected["empty"]
    ret = dir_.targets("*_empty", saltenv="")
    _test_match(ret, expected)
Exemplo n.º 8
0
def test_basic_list(expected, create_roster_files):
    """Test that minion files in the directory roster match and render."""
    expected = expected["basic"]
    ret = dir_.targets(expected.keys(), "list", saltenv="")
    _test_match(ret, expected)
Exemplo n.º 9
0
def test_basic_re(expected, create_roster_files):
    """Test that minion files in the directory roster match and render."""
    expected = expected["basic"]
    ret = dir_.targets(".*basic$", "pcre", saltenv="")
    _test_match(ret, expected)
Exemplo n.º 10
0
 def test_basic_glob(self):
     """Test that minion files in the directory roster match and render."""
     expected = EXPECTED['basic']
     ret = dir_.targets('*_basic', saltenv='')
     self._test_match(ret, expected)
Exemplo n.º 11
0
 def test_badfile_logging(self):
     """Test error handling when we can't render a file"""
     with self.assertLogs('salt.roster.dir', level='WARNING') as logged:
         dir_.targets('*badfile', saltenv='')
         self.assertIn('test1_us-east-2_test_badfile', logged.output[0])
Exemplo n.º 12
0
 def test_badfile(self):
     """Test error handling when we can't render a file"""
     ret = dir_.targets('*badfile', saltenv='')
     self.assertEqual(len(ret), 0)
Exemplo n.º 13
0
 def test_empty(self):
     """Test that an empty roster file matches its hostname"""
     expected = EXPECTED['empty']
     ret = dir_.targets('*_empty', saltenv='')
     self._test_match(ret, expected)