Exemple #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)
Exemple #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)
Exemple #3
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)
Exemple #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.mapred.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.mapred.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.mapred.update('lelik', 'bolik', nodes=['n1'])
        client.params.mapred.update('lelik', 'bolik')

        self.assertEqual(post.call_count, 3)
        self.assertEqual(put.call_count, 6)
Exemple #5
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)
Exemple #6
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.mapred.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.mapred.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.mapred.update('lelik', 'bolik', nodes=['n1'])
        client.params.mapred.update('lelik', 'bolik')

        self.assertEqual(post.call_count, 3)
        self.assertEqual(put.call_count, 6)
Exemple #7
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', 'mapred'])

        # 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')
Exemple #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', 'mapred'])

        # 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')
Exemple #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)
Exemple #10
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)
Exemple #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)
Exemple #12
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)
Exemple #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)
Exemple #14
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)
Exemple #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": "mapred",
                    "status": "running"
                }
            ]})
        client.services.hdfs.start()
        client.services.mapred.start()

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

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

        # stop
        post.return_value = r.make_resp()
        client.services.hdfs.stop()
        client.services.mapred.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.mapred.status)

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

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

        self.assertEqual(get.call_count, 606)
        self.assertEqual(post.call_count, 8)
Exemple #16
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": "mapred",
                    "status": "running"
                }]
            })
        client.services.hdfs.start()
        client.services.mapred.start()

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

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

        # stop
        post.return_value = r.make_resp()
        client.services.hdfs.stop()
        client.services.mapred.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.mapred.status)

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

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

        self.assertEqual(get.call_count, 606)
        self.assertEqual(post.call_count, 8)