Exemplo n.º 1
0
    def test_when_not_passed_start_event_grains(self):
        mock_opts = self.get_config("minion", from_scratch=True)
        io_loop = salt.ext.tornado.ioloop.IOLoop()
        io_loop.make_current()
        minion = salt.minion.Minion(mock_opts, io_loop=io_loop)
        try:
            minion.tok = MagicMock()
            minion._send_req_sync = MagicMock()
            minion._fire_master("Minion has started", "minion_start")
            load = minion._send_req_sync.call_args[0][0]

            self.assertTrue("grains" not in load)
        finally:
            minion.destroy()
Exemplo n.º 2
0
def test_when_not_passed_start_event_grains():
    mock_opts = salt.config.DEFAULT_MINION_OPTS.copy()
    io_loop = salt.ext.tornado.ioloop.IOLoop()
    io_loop.make_current()
    minion = salt.minion.Minion(mock_opts, io_loop=io_loop)
    try:
        minion.tok = MagicMock()
        minion._send_req_sync = MagicMock()
        minion._fire_master("Minion has started", "minion_start")
        load = minion._send_req_sync.call_args[0][0]

        assert "grains" not in load
    finally:
        minion.destroy()
Exemplo n.º 3
0
    def test_when_other_events_fired_and_start_event_grains_are_set(self):
        mock_opts = self.get_config("minion", from_scratch=True)
        mock_opts["start_event_grains"] = ["os"]
        io_loop = salt.ext.tornado.ioloop.IOLoop()
        io_loop.make_current()
        minion = salt.minion.Minion(mock_opts, io_loop=io_loop)
        try:
            minion.tok = MagicMock()
            minion._send_req_sync = MagicMock()
            minion._fire_master("Custm_event_fired", "custom_event")
            load = minion._send_req_sync.call_args[0][0]

            self.assertTrue("grains" not in load)
        finally:
            minion.destroy()
Exemplo n.º 4
0
def test_when_other_events_fired_and_start_event_grains_are_set():
    mock_opts = salt.config.DEFAULT_MINION_OPTS.copy()
    mock_opts["start_event_grains"] = ["os"]
    io_loop = salt.ext.tornado.ioloop.IOLoop()
    io_loop.make_current()
    minion = salt.minion.Minion(mock_opts, io_loop=io_loop)
    try:
        minion.tok = MagicMock()
        minion._send_req_sync = MagicMock()
        minion._fire_master("Custm_event_fired", "custom_event")
        load = minion._send_req_sync.call_args[0][0]

        assert "grains" not in load
    finally:
        minion.destroy()
Exemplo n.º 5
0
    def test_when_passed_start_event_grains(self):
        mock_opts = self.get_config('minion', from_scratch=True)
        mock_opts['start_event_grains'] = ["os"]
        io_loop = tornado.ioloop.IOLoop()
        io_loop.make_current()
        minion = salt.minion.Minion(mock_opts, io_loop=io_loop)
        try:
            minion.tok = MagicMock()
            minion._send_req_sync = MagicMock()
            minion._fire_master('Minion has started', 'minion_start')
            load = minion._send_req_sync.call_args[0][0]

            self.assertTrue('grains' in load)
            self.assertTrue('os' in load['grains'])
        finally:
            minion.destroy()
Exemplo n.º 6
0
def test_when_passed_start_event_grains():
    mock_opts = salt.config.DEFAULT_MINION_OPTS.copy()
    # provide mock opts an os grain since we'll look for it later.
    mock_opts["grains"]["os"] = "linux"
    mock_opts["start_event_grains"] = ["os"]
    io_loop = salt.ext.tornado.ioloop.IOLoop()
    io_loop.make_current()
    minion = salt.minion.Minion(mock_opts, io_loop=io_loop)
    try:
        minion.tok = MagicMock()
        minion._send_req_sync = MagicMock()
        minion._fire_master("Minion has started",
                            "minion_start",
                            include_startup_grains=True)
        load = minion._send_req_sync.call_args[0][0]

        assert "grains" in load
        assert "os" in load["grains"]
    finally:
        minion.destroy()
Exemplo n.º 7
0
    def test_when_passed_start_event_grains(self):
        mock_opts = self.get_config("minion", from_scratch=True)
        # provide mock opts an os grain since we'll look for it later.
        mock_opts["grains"]["os"] = "linux"
        mock_opts["start_event_grains"] = ["os"]
        io_loop = salt.ext.tornado.ioloop.IOLoop()
        io_loop.make_current()
        minion = salt.minion.Minion(mock_opts, io_loop=io_loop)
        try:
            minion.tok = MagicMock()
            minion._send_req_sync = MagicMock()
            minion._fire_master("Minion has started",
                                "minion_start",
                                include_startup_grains=True)
            load = minion._send_req_sync.call_args[0][0]

            self.assertTrue("grains" in load)
            self.assertTrue("os" in load["grains"])
        finally:
            minion.destroy()