Update tests for the LMA plugins

This change updates the tests to work with the latest versions of the
LMA plugins:
 - the new versions of InfluxDB and Grafana.
 - use the new roles for ES-Kibana and InfluxDB-Grafana.

Blueprint: upgrade-influxdb-grafana

Change-Id: Id589fd070a1ab4756a5dd053b6910932b538230e
This commit is contained in:
Simon Pasquier 2015-08-25 14:20:25 +02:00 committed by Guillaume Thouvenin
parent 4e8761f8ea
commit 1a7e29b537
2 changed files with 53 additions and 28 deletions

View File

@ -46,7 +46,7 @@ class TestInfluxdbPlugin(TestBasic):
3. Create cluster 3. Create cluster
4. Add 1 node with controller role 4. Add 1 node with controller role
5. Add 1 node with compute role 5. Add 1 node with compute role
6. Add 1 node with base-os role 6. Add 1 node with influxdb_grafana role
7. Deploy the cluster 7. Deploy the cluster
8. Check that plugin is working 8. Check that plugin is working
9. Run OSTF 9. Run OSTF
@ -75,9 +75,10 @@ class TestInfluxdbPlugin(TestBasic):
plugin_name = 'influxdb_grafana' plugin_name = 'influxdb_grafana'
options = { options = {
'metadata/enabled': True, 'metadata/enabled': True,
'node_name/value': 'slave-03_base-os', 'node_name/value': 'slave-03_influxdb_grafana',
'influxdb_rootpass/value': 'lmapass', 'influxdb_rootpass/value': 'lmapass',
'influxdb_userpass/value': 'lmapass', 'influxdb_userpass/value': 'lmapass',
'grafana_userpass/value': 'lmapass',
} }
assert_true( assert_true(
@ -91,7 +92,7 @@ class TestInfluxdbPlugin(TestBasic):
{ {
'slave-01': ['controller'], 'slave-01': ['controller'],
'slave-02': ['compute'], 'slave-02': ['compute'],
'slave-03': ['base-os'] 'slave-03': ['influxdb_grafana']
} }
) )
@ -104,16 +105,20 @@ class TestInfluxdbPlugin(TestBasic):
logger.debug("Check that InfluxDB is ready") logger.debug("Check that InfluxDB is ready")
r = requests.get( influxdb_url = "http://{0}:8086/query?db=lma&u={1}&p={2}&" + \
"http://{}:8086/db/lma/series?u=lma&p={}&q=list+series".format( "q=show+measurements"
influxdb_server_ip, options['influxdb_userpass/value'])) r = requests.get(influxdb_url.format(
influxdb_server_ip, 'lma', options['influxdb_userpass/value']))
msg = "InfluxDB responded with {}, expected 200".format(r.status_code) msg = "InfluxDB responded with {}, expected 200".format(r.status_code)
assert_equal(r.status_code, 200, msg) assert_equal(r.status_code, 200, msg)
logger.debug("Check that the HTTP server is running") logger.debug("Check that the Grafana server is running")
r = requests.get("http://{}/".format(influxdb_server_ip)) r = requests.get(
msg = "HTTP server responded with {}, expected 200".format( "http://{0}:{1}@{2}:8000/api/org".format(
'grafana', options['grafana_userpass/value'],
influxdb_server_ip))
msg = "Grafana server responded with {}, expected 200".format(
r.status_code) r.status_code)
assert_equal(r.status_code, 200, msg) assert_equal(r.status_code, 200, msg)

View File

@ -47,7 +47,7 @@ class TestLmaCollectorPlugin(TestBasic):
3. Create cluster 3. Create cluster
4. Add 3 nodes with controller role 4. Add 3 nodes with controller role
5. Add 1 node with compute + cinder role 5. Add 1 node with compute + cinder role
6. Add 1 node with base-os role 6. Add 1 node with influxdb_grafana + elasticsearch roles
7. Deploy the cluster 7. Deploy the cluster
8. Check that the plugins work 8. Check that the plugins work
9. Run OSTF 9. Run OSTF
@ -91,8 +91,11 @@ class TestLmaCollectorPlugin(TestBasic):
} }
) )
# this is how the base-os node will be named eventually influxdb_user = "influxdb"
analytics_node_name = 'slave-05_base-os' influxdb_pass = "influxdbpass"
influxdb_rootpass = "r00tme"
grafana_user = "grafana"
grafana_pass = "grafanapass"
plugins = [ plugins = [
{ {
'name': 'lma_collector', 'name': 'lma_collector',
@ -101,23 +104,23 @@ class TestLmaCollectorPlugin(TestBasic):
'environment_label/value': 'deploy_lma_collector_ha', 'environment_label/value': 'deploy_lma_collector_ha',
'elasticsearch_mode/value': 'local', 'elasticsearch_mode/value': 'local',
'influxdb_mode/value': 'local', 'influxdb_mode/value': 'local',
'influxdb_password/value': 'lmapass',
} }
}, },
{ {
'name': 'elasticsearch_kibana', 'name': 'elasticsearch_kibana',
'options': { 'options': {
'metadata/enabled': True, 'metadata/enabled': True,
'node_name/value': analytics_node_name,
} }
}, },
{ {
'name': 'influxdb_grafana', 'name': 'influxdb_grafana',
'options': { 'options': {
'metadata/enabled': True, 'metadata/enabled': True,
'node_name/value': analytics_node_name, 'influxdb_rootpass/value': influxdb_rootpass,
'influxdb_rootpass/value': 'lmapass', 'influxdb_username/value': influxdb_user,
'influxdb_userpass/value': 'lmapass', 'influxdb_userpass/value': influxdb_pass,
'grafana_username/value': grafana_user,
'grafana_userpass/value': grafana_pass,
} }
}, },
] ]
@ -131,6 +134,7 @@ class TestLmaCollectorPlugin(TestBasic):
self.fuel_web.update_plugin_data(cluster_id, plugin_name, self.fuel_web.update_plugin_data(cluster_id, plugin_name,
plugin['options']) plugin['options'])
analytics_roles = ["influxdb_grafana", "elasticsearch_kibana"]
self.fuel_web.update_nodes( self.fuel_web.update_nodes(
cluster_id, cluster_id,
{ {
@ -138,13 +142,20 @@ class TestLmaCollectorPlugin(TestBasic):
"slave-02": ["controller"], "slave-02": ["controller"],
"slave-03": ["controller"], "slave-03": ["controller"],
"slave-04": ["compute", "cinder"], "slave-04": ["compute", "cinder"],
"slave-05": ["base-os"] "slave-05": analytics_roles,
} }
) )
self.fuel_web.deploy_cluster_wait(cluster_id) self.fuel_web.deploy_cluster_wait(cluster_id)
analytics_node_ip = self.fuel_web.get_nailgun_node_by_name( analytics_nodes = self.fuel_web.get_nailgun_cluster_nodes_by_roles(
"slave-05").get('ip') cluster_id, analytics_roles
)
msg = "One node with '{}' roles must be present, found {}".format(
' + '.join(analytics_roles), len(analytics_nodes))
assert_true(len(analytics_nodes) == 1, msg)
analytics_node_ip = analytics_nodes[0].get('ip')
assert_is_not_none( assert_is_not_none(
analytics_node_ip, analytics_node_ip,
"Fail to retrieve the IP address for slave-05" "Fail to retrieve the IP address for slave-05"
@ -157,18 +168,27 @@ class TestLmaCollectorPlugin(TestBasic):
url, r.status_code, expected)) url, r.status_code, expected))
logger.debug("Check that Elasticsearch is ready") logger.debug("Check that Elasticsearch is ready")
assert_http_get_response("http://{}:9200/".format(analytics_node_ip)) assert_http_get_response("http://{0}:9200/".format(analytics_node_ip))
logger.debug("Check that Kibana is ready") logger.debug("Check that Kibana is ready")
assert_http_get_response("http://{}/".format(analytics_node_ip)) assert_http_get_response("http://{0}/".format(analytics_node_ip))
logger.debug("Check that InfluxDB is ready") logger.debug("Check that the root user can access InfluxDB")
influxdb_url = "http://{0}:8086/query?db=lma&u={1}&p={2}&" + \
"q=show+measurements"
assert_http_get_response(influxdb_url.format(analytics_node_ip,
'root',
influxdb_rootpass))
logger.debug("Check that the LMA user can access InfluxDB")
assert_http_get_response(influxdb_url.format(analytics_node_ip,
influxdb_user,
influxdb_pass))
logger.debug("Check that the LMA user can access Grafana")
assert_http_get_response( assert_http_get_response(
"http://{}:8086/db/lma/series?u=lma&p={}&q=list+series".format( "http://{0}:{1}@{2}:8000/api/org".format(grafana_user,
analytics_node_ip, "lmapass")) grafana_pass,
analytics_node_ip))
logger.debug("Check that Grafana is ready")
assert_http_get_response("http://{}/".format(analytics_node_ip))
self.fuel_web.run_ostf(cluster_id=cluster_id) self.fuel_web.run_ostf(cluster_id=cluster_id)