Beispiel #1
0
 def setUp(self):
     logging.getLogger().setLevel(logging.WARN)
     consul = mock.MagicMock()
     manta = mock.MagicMock()
     my = mock.MagicMock()
     cp = ContainerPilot()
     cp.load(get_environ())
     my.datadir = tempfile.mkdtemp()
     cp.state = PRIMARY
     my.datadir = tempfile.mkdtemp()
     self.node = manage.Node(consul=consul, cp=cp, manta=manta, mysql=my)
Beispiel #2
0
 def setUp(self):
     logging.getLogger().setLevel(logging.WARN)
     consul = mock.MagicMock()
     manta = mock.MagicMock()
     my = mock.MagicMock()
     cp = ContainerPilot()
     cp.load(get_environ())
     my.datadir = tempfile.mkdtemp()
     cp.state = PRIMARY
     my.datadir = tempfile.mkdtemp()
     self.node = manage.Node(consul=consul, cp=cp, manta=manta, mysql=my)
Beispiel #3
0
    def test_update(self):
        self.environ['CONSUL_AGENT'] = '1'
        cp = ContainerPilot()
        cp.state = REPLICA
        cp.load(envs=self.environ)
        temp_file = tempfile.NamedTemporaryFile()
        cp.path = temp_file.name

        # no update expected
        cp.update()
        with open(temp_file.name, 'r') as updated:
            self.assertEqual(updated.read(), '')

        # force an update
        cp.state = PRIMARY
        cp.update()
        with open(temp_file.name, 'r') as updated:
            config = json.loads(updated.read())
            self.assertEqual(config['consul'], 'localhost:8500')
            cmd = config['coprocesses'][0]['command']
            host_cfg_idx = cmd.index('-retry-join') + 1
            self.assertEqual(cmd[host_cfg_idx], 'my.consul.example.com')
Beispiel #4
0
    def test_update(self):
        self.environ['CONSUL_AGENT'] = '1'
        cp = ContainerPilot()
        cp.state = REPLICA
        cp.load(envs=self.environ)
        temp_file = tempfile.NamedTemporaryFile()
        cp.path = temp_file.name

        # no update expected
        cp.update()
        with open(temp_file.name, 'r') as updated:
            self.assertEqual(updated.read(), '')

        # force an update
        cp.state = PRIMARY
        cp.update()
        with open(temp_file.name, 'r') as updated:
            config = json.loads(updated.read())
            self.assertEqual(config['consul'], 'localhost:8500')
            cmd = config['coprocesses'][0]['command']
            host_cfg_idx = cmd.index('-retry-join') + 1
            self.assertEqual(cmd[host_cfg_idx], 'my.consul.example.com:8500')