From 4d8bc2d9d26f91fa68368bee7a24566b500d6a51 Mon Sep 17 00:00:00 2001
From: MJB <mjb@it-innovation.soton.ac.uk>
Date: Sun, 25 Feb 2018 13:36:53 +0000
Subject: [PATCH] moved rspec tests to the actual test directories streaming
 and streaming-sim

---
 test/streaming-sim/conftest.py   |  9 +++++++++
 test/streaming-sim/test_rspec.py | 16 ++++++++++++++++
 test/streaming/conftest.py       |  9 +++++++++
 test/streaming/test_rspec.py     | 17 +++++++++++++++++
 4 files changed, 51 insertions(+)
 create mode 100644 test/streaming-sim/conftest.py
 create mode 100644 test/streaming-sim/test_rspec.py
 create mode 100644 test/streaming/conftest.py
 create mode 100644 test/streaming/test_rspec.py

diff --git a/test/streaming-sim/conftest.py b/test/streaming-sim/conftest.py
new file mode 100644
index 0000000..5b953a0
--- /dev/null
+++ b/test/streaming-sim/conftest.py
@@ -0,0 +1,9 @@
+import pytest
+import yaml
+
+@pytest.fixture(scope="module")
+def streaming_sim_config():
+    """Returns the service configuration deployed for the streaming simulation test. In future this needs to be a parameterised fixture shared with other rspec.yml based tests"""
+    with open("test/streaming-sim/rspec.yml", 'r') as stream:
+        data_loaded = yaml.load(stream)
+    return data_loaded
\ No newline at end of file
diff --git a/test/streaming-sim/test_rspec.py b/test/streaming-sim/test_rspec.py
new file mode 100644
index 0000000..217ceeb
--- /dev/null
+++ b/test/streaming-sim/test_rspec.py
@@ -0,0 +1,16 @@
+import pytest
+import os
+
+def test_service_names(streaming_sim_config):
+    print(streaming_sim_config['hosts'][0]['name'])
+    assert streaming_sim_config['hosts'][0]['name'] == 'clmc-service'
+    assert streaming_sim_config['hosts'][1]['name'] == 'ipendpoint1'
+    assert streaming_sim_config['hosts'][2]['name'] == 'ipendpoint2'            
+
+def test_ping(streaming_sim_config):
+    """This test will only run on linux due to using os.system library"""
+    for x in streaming_sim_config['hosts']:
+        print(x['ip_address'])
+        response = os.system("ping -c 1 " + x['ip_address'])
+        assert response == 0     
+    
diff --git a/test/streaming/conftest.py b/test/streaming/conftest.py
new file mode 100644
index 0000000..4fdb50a
--- /dev/null
+++ b/test/streaming/conftest.py
@@ -0,0 +1,9 @@
+import pytest
+import yaml
+
+@pytest.fixture(scope="module")
+def streaming_config():
+    """Returns the service configuration deployed for the streaming test. In future this needs to be a parameterised fixture shared with other rspec.yml based tests"""
+    with open("test/streaming/rspec.yml", 'r') as stream:
+        data_loaded = yaml.load(stream)
+    return data_loaded
\ No newline at end of file
diff --git a/test/streaming/test_rspec.py b/test/streaming/test_rspec.py
new file mode 100644
index 0000000..a3bf7d9
--- /dev/null
+++ b/test/streaming/test_rspec.py
@@ -0,0 +1,17 @@
+import pytest
+import os
+
+def test_service_names(streaming_config):
+    print(streaming_config['hosts'][0]['name'])
+    assert streaming_config['hosts'][0]['name'] == 'clmc-service'
+    assert streaming_config['hosts'][1]['name'] == 'nginx1'
+    assert streaming_config['hosts'][2]['name'] == 'nginx2' 
+    assert streaming_config['hosts'][3]['name'] == 'loadtest-streaming'            
+
+def test_ping(streaming_config):
+    """This test will only run on linux"""
+    for x in streaming_config['hosts']:
+        print(x['ip_address'])
+        response = os.system("ping -c 1 " + x['ip_address'])
+        assert response == 0     
+    
-- 
GitLab