Skip to content

Commit 06c1799

Browse files
committed
Integration tests run against provided YARN ENDPOINT
Integration test that, given a provided YARN ENDPOINT, execute some real scenario test against that server. Note that, if no YARN ENDPOINT is provided, the tests are ignored.
1 parent e65a61f commit 06c1799

File tree

5 files changed

+95
-10
lines changed

5 files changed

+95
-10
lines changed

.travis.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@ matrix:
1313

1414

1515
install:
16-
- pip install --upgrade setuptools pip
17-
- pip install --upgrade requests requests_mock requests_kerberos tox coveralls
18-
- python setup.py bdist_wheel
19-
- pip install dist/*.whl
16+
- pip install --upgrade pip tox coveralls
2017
- pip freeze
2118

2219
script:

itests/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# -*- coding: utf-8 -*-
2+
try:
3+
from unittest2 import TestCase
4+
except ImportError:
5+
from unittest import TestCase
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# -*- coding: utf-8 -*-
2+
3+
import os
4+
5+
from pprint import pprint
6+
from unittest import TestCase
7+
from yarn_api_client.resource_manager import ResourceManager
8+
9+
try:
10+
from urlparse import urlparse
11+
except ImportError:
12+
from urllib.parse import urlparse
13+
14+
15+
class ResourceManagerTestCase(TestCase):
16+
"""
17+
Integration test that, given a provided YARN ENDPOINT,
18+
execute some real scenario test against that server.
19+
20+
Note that, if no YARN ENDPOINT is provided, the tests
21+
are ignored.
22+
"""
23+
@classmethod
24+
def setUpClass(self):
25+
self.configured = False
26+
if os.getenv('YARN_ENDPOINT'):
27+
yarn_endpoint = os.getenv('YARN_ENDPOINT')
28+
yarn_endpoint_uri = urlparse(yarn_endpoint)
29+
30+
if yarn_endpoint_uri.hostname and yarn_endpoint_uri.port:
31+
self.configured = True
32+
self.resourceManager = ResourceManager(yarn_endpoint_uri.hostname, yarn_endpoint_uri.port)
33+
34+
def test_cluster_information(self):
35+
if self.configured:
36+
info = self.resourceManager.cluster_information()
37+
pprint(info.data)
38+
self.assertEqual(info.data['clusterInfo']['state'], 'STARTED')
39+
40+
def test_cluster_metrics(self):
41+
if self.configured:
42+
metrics = self.resourceManager.cluster_metrics()
43+
pprint(metrics.data)
44+
self.assertGreater(metrics.data['clusterMetrics']['activeNodes'], 0)
45+
self.assertIsNotNone(metrics.data['clusterMetrics']['totalNodes'])
46+
47+
def test_cluster_scheduler(self):
48+
if self.configured:
49+
scheduler = self.resourceManager.cluster_scheduler()
50+
pprint(scheduler.data)
51+
self.assertIsNotNone(scheduler.data['scheduler']['schedulerInfo'])
52+
53+
def test_cluster_applications(self):
54+
if self.configured:
55+
apps = self.resourceManager.cluster_applications()
56+
pprint(apps.data)
57+
self.assertIsNotNone(apps.data['apps'])
58+
59+
def test_cluster_application_state(self):
60+
if self.configured:
61+
apps = self.resourceManager.cluster_applications()
62+
appid = apps.data['apps']['app'][0]['id']
63+
print(appid)
64+
response = self.resourceManager.cluster_application_state(appid)
65+
pprint(response.data)
66+
pprint(response.data['state'])
67+
self.assertIsNotNone(apps.data['apps'])
68+
69+
def test_cluster_application_statistics(self):
70+
if self.configured:
71+
appstats = self.resourceManager.cluster_application_statistics()
72+
pprint(appstats.data)
73+
self.assertIsNotNone(appstats.data['appStatInfo'])
74+
75+
def test_cluster_nodes(self):
76+
if self.configured:
77+
nodes = self.resourceManager.cluster_nodes()
78+
pprint(nodes.data)
79+
self.assertIsNotNone(nodes.data['nodes'])
80+
81+
running_nodes = self.resourceManager.cluster_nodes(state='RUNNING', healthy='true')
82+
pprint(running_nodes.data)
83+
self.assertIsNotNone(nodes.data['nodes'])

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def find_version(*file_paths):
2828

2929
install_requires = [
3030
'requests>=2.7,<3.0',
31-
'requests-kerberos==0.12.0',
31+
'requests-kerberos',
3232
],
3333
entry_points = {
3434
'console_scripts': [

tox.ini

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ envlist = py27,py35,py36
33

44
[testenv]
55
deps =
6-
requests
7-
requests-kerberos
8-
requests_mock
9-
coverage
10-
mock
6+
coverage
7+
mock
8+
requests
9+
requests-kerberos
10+
requests_mock
1111
commands = coverage run --source=yarn_api_client setup.py test

0 commit comments

Comments
 (0)