Ejemplo n.º 1
0
    def testAddLocalNode(self):

        cid = self._clusterId
        cluster = self._getCluster()
        for i in range(0, 3):
            cluster.addNode("%s_%s" % (cid, i))

        n0 = '%s_0' % cid
        n1 = '%s_1' % cid

        cluster.addLocalNode(n1)

        sn = self.__servernodes()

        cfgPath = '/'.join(
            [X.cfgDir, "qconfig", "arakoon", cid,
             "%s_local_nodes" % cid])
        config = X.getConfig(cfgPath)
        assert_equals(Compat.sectionAsDict(config, "global"), {'cluster': n1})

        cluster.addLocalNode(n0)

        config = X.getConfig(cfgPath)
        assert_equals(Compat.sectionAsDict(config, "global"),
                      {'cluster': '%s,%s' % (n1, n0)})
Ejemplo n.º 2
0
    def testAddNode(self):
        cid = self._clusterId
        n0 = '%s_0' % cid
        n1 = '%s_1' % cid

        cluster = self._getCluster()
        cluster.addNode(n0)

        config = cluster._getConfigFile()
        assert_equals(Compat.sectionAsDict(config, "global"), {
            'cluster': n0,
            'cluster_id': cid
        })
        assert_equals(
            Compat.sectionAsDict(config, n0), {
                'client_port': '7080',
                'home': '%s/db/%s/%s' % (X.varDir, cid, n0),
                'ip': '127.0.0.1',
                'log_dir': '%s/%s/%s' % (X.logDir, cid, n0),
                'log_level': 'info',
                'messaging_port': '10000'
            })

        cluster.addNode(n1, "192.168.0.1", 7081, 12345, "debug", "/tmp",
                        "/tmp/joe")

        config = cluster._getConfigFile()

        assert_equals(Compat.sectionAsDict(config, "global"), {
            'cluster': '%s,%s' % (n0, n1),
            'cluster_id': cid
        })

        assert_equals(
            Compat.sectionAsDict(config, n0), {
                'client_port': '7080',
                'home': '%s/db/%s/%s' % (X.varDir, cid, n0),
                'ip': '127.0.0.1',
                'log_dir': '%s/%s/%s' % (X.logDir, cid, n0),
                'log_level': 'info',
                'messaging_port': '10000'
            })

        assert_equals(
            Compat.sectionAsDict(config, n1), {
                'client_port': '7081',
                'home': '/tmp/joe',
                'ip': '192.168.0.1',
                'log_dir': '/tmp',
                'log_level': 'debug',
                'messaging_port': '12345'
            })
Ejemplo n.º 3
0
 def testAddNodeMultipleIps(self):
     cluster = self._getCluster()
     name = "whatever"
     ips = ["127.0.0.1", "192.168.0.1"]
     cluster.addNode(name=name, ip=ips)
     config = cluster._getConfigFile()
     d = Compat.sectionAsDict(config, name)
     assert_equals(d['ip'], '127.0.0.1, 192.168.0.1')
Ejemplo n.º 4
0
    def testRemoveNode(self):
        cid = self._clusterId
        n0 = '%s_%i' % (cid, 0)
        n1 = '%s_%i' % (cid, 1)
        cluster = self._getCluster()
        cluster.addNode(n0)
        cluster.addNode(n1)

        cluster.removeNode(n0)

        config = cluster._getConfigFile()
        assert_equals(Compat.sectionAsDict(config, "global")['cluster'], n1)
        assert_false(config.has_section(n0))