Пример #1
0
    def test_hdfs_services_op(self, get, post):
        client = c.IntelClient(self._get_instance(), 'rty')

        # format
        get.return_value = r.make_resp(SESSION_GET_DATA)
        post.return_value = r.make_resp(SESSION_POST_DATA)
        client.services.hdfs.format()

        # decommission
        post.return_value = r.make_resp()
        client.services.hdfs.decommission_nodes(['n1'])

        # get status
        get.return_value = r.make_resp(
            data={"items": [{
                "hostname": "n1",
                "status": "start"
            }]})
        client.services.hdfs.get_datanodes_status()
        self.assertEqual(client.services.hdfs.get_datanode_status('n1'),
                         'start')
        self.assertRaises(iex.IntelPluginException,
                          client.services.hdfs.get_datanode_status, 'n2')

        self.assertEqual(get.call_count, 4)
        self.assertEqual(post.call_count, 2)
Пример #2
0
    def test_session_op(self, get, post):
        client = c.IntelClient(self._get_instance(), 'rty')

        data1 = {
            "items": [{
                "nodeprogress": {
                    "hostname": 'host',
                    'info': 'info\n'
                }
            }]
        }
        data2 = {
            "items": [{
                "nodeprogress": {
                    "hostname": 'host',
                    'info': '_ALLFINISH\n'
                }
            }]
        }

        get.side_effect = (r.make_resp(data1), r.make_resp(data2))
        post.return_value = r.make_resp(SESSION_POST_DATA)

        client.services.hdfs.format()

        self.assertEqual(get.call_count, 2)
        self.assertEqual(post.call_count, 1)
Пример #3
0
    def test_params_op(self, post, put):
        client = c.IntelClient(self._get_instance(), "rty")
        post.return_value = r.make_resp()
        put.return_value = r.make_resp()

        # add
        client.params.hdfs.add("lelik", "bolik")
        client.params.hadoop.add("lelik", "bolik")
        client.params.yarn.add("lelik", "bolik")

        # get
        self.assertRaises(ex.NotImplementedException, client.params.hdfs.get, ["n1"], "lelik")
        self.assertRaises(ex.NotImplementedException, client.params.hadoop.get, ["n1"], "lelik")
        self.assertRaises(ex.NotImplementedException, client.params.yarn.get, ["n1"], "lelik")

        # update
        client.params.hdfs.update("lelik", "bolik", nodes=["n1"])
        client.params.hdfs.update("lelik", "bolik")
        client.params.hadoop.update("lelik", "bolik", nodes=["n1"])
        client.params.hadoop.update("lelik", "bolik")
        client.params.yarn.update("lelik", "bolik", nodes=["n1"])
        client.params.yarn.update("lelik", "bolik")

        self.assertEqual(post.call_count, 3)
        self.assertEqual(put.call_count, 6)
Пример #4
0
    def test_params_op(self, post, put):
        client = c.IntelClient(self._get_instance(), 'rty')
        post.return_value = r.make_resp()
        put.return_value = r.make_resp()

        # add
        client.params.hdfs.add('lelik', 'bolik')
        client.params.hadoop.add('lelik', 'bolik')
        client.params.yarn.add('lelik', 'bolik')

        # get
        self.assertRaises(ex.NotImplementedException, client.params.hdfs.get,
                          ['n1'], 'lelik')
        self.assertRaises(ex.NotImplementedException, client.params.hadoop.get,
                          ['n1'], 'lelik')
        self.assertRaises(ex.NotImplementedException, client.params.yarn.get,
                          ['n1'], 'lelik')

        # update
        client.params.hdfs.update('lelik', 'bolik', nodes=['n1'])
        client.params.hdfs.update('lelik', 'bolik')
        client.params.hadoop.update('lelik', 'bolik', nodes=['n1'])
        client.params.hadoop.update('lelik', 'bolik')
        client.params.yarn.update('lelik', 'bolik', nodes=['n1'])
        client.params.yarn.update('lelik', 'bolik')

        self.assertEqual(post.call_count, 3)
        self.assertEqual(put.call_count, 6)
Пример #5
0
    def test_session_op(self, get, post):
        client = c.IntelClient(self._get_instance(), "rty")

        data1 = {"items": [{"nodeprogress": {"hostname": "host", "info": "info\n"}}]}
        data2 = {"items": [{"nodeprogress": {"hostname": "host", "info": "_ALLFINISH\n"}}]}

        get.side_effect = (r.make_resp(data1), r.make_resp(data2))
        post.return_value = r.make_resp(SESSION_POST_DATA)

        client.services.hdfs.format()

        self.assertEqual(get.call_count, 2)
        self.assertEqual(post.call_count, 1)
Пример #6
0
    def test_services_op(self, get, post, delete):
        client = c.IntelClient(self._get_instance(), 'rty')

        # add
        post.return_value = r.make_resp()
        client.services.add(['hdfs', 'yarn'])

        # get_services
        get.return_value = r.make_resp()
        client.services.get_services()

        # delete_service
        delete.return_value = r.make_resp()
        client.services.delete_service('hdfs')
Пример #7
0
    def test_nodes_op(self, get, post, delete):
        client = c.IntelClient(self._get_instance(), "rty")

        # add
        post.return_value = r.make_resp(
            data={"items": [{"iporhostname": "n1", "info": "Connected"}, {"iporhostname": "n2", "info": "Connected"}]}
        )
        client.nodes.add(["n1", "n2"], "hadoop", "/Def", "/tmp/key")
        post.return_value = r.make_resp(data={"items": [{"iporhostname": "n1", "info": "bla-bla"}]})
        self.assertRaises(iex.IntelPluginException, client.nodes.add, ["n1"], "hadoop", "/Def", "/tmp/key")

        # config
        post.return_value = r.make_resp(SESSION_POST_DATA)
        get.return_value = r.make_resp(SESSION_GET_DATA)
        client.nodes.config()

        # delete
        delete.return_value = r.make_resp()
        client.nodes.delete(["n1"])

        # get
        get.return_value = r.make_resp()
        client.nodes.get()

        # get_status
        get.return_value = r.make_resp(data={"status": "running"})
        client.nodes.get_status(["n1"])

        # stop_nodes
        post.return_value = r.make_resp()
        client.nodes.stop(["n1"])

        self.assertEqual(delete.call_count, 1)
        self.assertEqual(post.call_count, 4)
        self.assertEqual(get.call_count, 3)
Пример #8
0
    def test_services_op(self, get, post, delete):
        client = c.IntelClient(self._get_instance(), "rty")

        # add
        post.return_value = r.make_resp()
        client.services.add(["hdfs", "yarn"])

        # get_services
        get.return_value = r.make_resp()
        client.services.get_services()

        # delete_service
        delete.return_value = r.make_resp()
        client.services.delete_service("hdfs")
Пример #9
0
 def test_rest_client(self, get):
     client = c.IntelClient(self._get_instance(), 'rty')
     get.return_value = r.make_resp(ok=False,
                                    status_code=500,
                                    data={"message": "message"})
     self.assertRaises(iex.IntelPluginException,
                       client.services.get_services)
Пример #10
0
    def test_cluster_op(self, get, post):
        client = c.IntelClient(self._get_instance(), 'rty')

        data = {'lelik': 'bolik'}

        post.return_value = r.make_resp(data)
        self.assertEqual(client.cluster.create(), data)

        get.return_value = r.make_resp(data)
        self.assertEqual(client.cluster.get(), data)

        post.return_value = r.make_resp(SESSION_POST_DATA)
        get.return_value = r.make_resp(SESSION_GET_DATA)
        client.cluster.install_software(['bla-bla'])

        self.assertEqual(post.call_count, 2)
        self.assertEqual(get.call_count, 2)
Пример #11
0
    def test_cluster_op(self, get, post):
        client = c.IntelClient(self._get_instance(), "rty")

        data = {"lelik": "bolik"}

        post.return_value = r.make_resp(data)
        self.assertEqual(client.cluster.create(), data)

        get.return_value = r.make_resp(data)
        self.assertEqual(client.cluster.get(), data)

        post.return_value = r.make_resp(SESSION_POST_DATA)
        get.return_value = r.make_resp(SESSION_GET_DATA)
        client.cluster.install_software(["bla-bla"])

        self.assertEqual(post.call_count, 2)
        self.assertEqual(get.call_count, 2)
Пример #12
0
    def test_hdfs_services_op(self, get, post):
        client = c.IntelClient(self._get_instance(), "rty")

        # format
        get.return_value = r.make_resp(SESSION_GET_DATA)
        post.return_value = r.make_resp(SESSION_POST_DATA)
        client.services.hdfs.format()

        # decommission
        post.return_value = r.make_resp()
        client.services.hdfs.decommission_nodes(["n1"])

        # get status
        get.return_value = r.make_resp(data={"items": [{"hostname": "n1", "status": "start"}]})
        client.services.hdfs.get_datanodes_status()
        self.assertEqual(client.services.hdfs.get_datanode_status("n1"), "start")
        self.assertRaises(iex.IntelPluginException, client.services.hdfs.get_datanode_status, "n2")

        self.assertEqual(get.call_count, 4)
        self.assertEqual(post.call_count, 2)
Пример #13
0
    def test_nodes_op(self, get, post, delete):
        client = c.IntelClient(self._get_instance(), 'rty')

        # add
        post.return_value = r.make_resp(
            data={
                "items": [{
                    "iporhostname": "n1",
                    "info": "Connected"
                }, {
                    "iporhostname": "n2",
                    "info": "Connected"
                }]
            })
        client.nodes.add(['n1', 'n2'], 'hadoop', '/Def', '/tmp/key')
        post.return_value = r.make_resp(
            data={"items": [{
                "iporhostname": "n1",
                "info": "bla-bla"
            }]})
        self.assertRaises(iex.IntelPluginException, client.nodes.add, ['n1'],
                          'hadoop', '/Def', '/tmp/key')

        # config
        post.return_value = r.make_resp(SESSION_POST_DATA)
        get.return_value = r.make_resp(SESSION_GET_DATA)
        client.nodes.config()

        # delete
        delete.return_value = r.make_resp()
        client.nodes.delete(['n1'])

        # get
        get.return_value = r.make_resp()
        client.nodes.get()

        # get_status
        get.return_value = r.make_resp(data={"status": "running"})
        client.nodes.get_status(['n1'])

        # stop_nodes
        post.return_value = r.make_resp()
        client.nodes.stop(['n1'])

        self.assertEqual(delete.call_count, 1)
        self.assertEqual(post.call_count, 4)
        self.assertEqual(get.call_count, 3)
Пример #14
0
    def test_base_services_op(self, get, post):
        client = c.IntelClient(self._get_instance(), "rty")

        # start
        post.return_value = r.make_resp()
        get.return_value = r.make_resp(
            data={"items": [{"serviceName": "hdfs", "status": "running"}, {"serviceName": "yarn", "status": "running"}]}
        )
        client.services.hdfs.start()
        client.services.yarn.start()

        get.return_value = r.make_resp(
            data={"items": [{"serviceName": "hdfs", "status": "stopped"}, {"serviceName": "yarn", "status": "stopped"}]}
        )

        self.assertRaises(iex.IntelPluginException, client.services.hdfs.start)
        self.assertRaises(iex.IntelPluginException, client.services.yarn.start)

        # stop
        post.return_value = r.make_resp()
        client.services.hdfs.stop()
        client.services.yarn.stop()

        # service
        get.return_value = r.make_resp(data={"items": [{"serviceName": "bla-bla", "status": "fail"}]})

        self.assertRaises(iex.IntelPluginException, client.services.hdfs.status)
        self.assertRaises(iex.IntelPluginException, client.services.yarn.status)

        # get_nodes
        get.return_value = r.make_resp()
        client.services.hdfs.get_nodes()
        client.services.yarn.get_nodes()

        # add_nodes
        post.return_value = r.make_resp()
        client.services.hdfs.add_nodes("DataNode", ["n1", "n2"])
        client.services.yarn.add_nodes("NodeManager", ["n1", "n2"])

        self.assertEqual(get.call_count, 606)
        self.assertEqual(post.call_count, 8)
Пример #15
0
    def test_base_services_op(self, get, post):
        client = c.IntelClient(self._get_instance(), 'rty')

        # start
        post.return_value = r.make_resp()
        get.return_value = r.make_resp(
            data={
                "items": [{
                    "serviceName": "hdfs",
                    "status": "running"
                }, {
                    "serviceName": "yarn",
                    "status": "running"
                }]
            })
        client.services.hdfs.start()
        client.services.yarn.start()

        get.return_value = r.make_resp(
            data={
                "items": [{
                    "serviceName": "hdfs",
                    "status": "stopped"
                }, {
                    "serviceName": "yarn",
                    "status": "stopped"
                }]
            })

        self.assertRaises(iex.IntelPluginException, client.services.hdfs.start)
        self.assertRaises(iex.IntelPluginException, client.services.yarn.start)

        # stop
        post.return_value = r.make_resp()
        client.services.hdfs.stop()
        client.services.yarn.stop()

        # service
        get.return_value = r.make_resp(
            data={"items": [{
                "serviceName": "bla-bla",
                "status": "fail"
            }]})

        self.assertRaises(iex.IntelPluginException,
                          client.services.hdfs.status)
        self.assertRaises(iex.IntelPluginException,
                          client.services.yarn.status)

        # get_nodes
        get.return_value = r.make_resp()
        client.services.hdfs.get_nodes()
        client.services.yarn.get_nodes()

        # add_nodes
        post.return_value = r.make_resp()
        client.services.hdfs.add_nodes('DataNode', ['n1', 'n2'])
        client.services.yarn.add_nodes('NodeManager', ['n1', 'n2'])

        self.assertEqual(get.call_count, 606)
        self.assertEqual(post.call_count, 8)
Пример #16
0
 def test_rest_client(self, get):
     client = c.IntelClient(self._get_instance(), "rty")
     get.return_value = r.make_resp(ok=False, status_code=500, data={"message": "message"})
     self.assertRaises(iex.IntelPluginException, client.services.get_services)