Merge "Added NSB descriptors for vCMTS testcase"
[yardstick.git] / yardstick / tests / unit / benchmark / scenarios / storage / test_fio.py
index 0cffea2..6e69ddc 100644 (file)
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
 ##############################################################################
 # Copyright (c) 2015 Ericsson AB and others.
 #
@@ -20,6 +18,7 @@ import mock
 from oslo_serialization import jsonutils
 
 from yardstick.benchmark.scenarios.storage import fio
+from yardstick.common import exceptions as y_exc
 
 
 @mock.patch('yardstick.benchmark.scenarios.storage.fio.ssh')
@@ -63,6 +62,22 @@ class FioTestCase(unittest.TestCase):
         }
         args = {'options': options}
         p = fio.Fio(args, self.ctx)
+        mock_ssh.SSH.from_node().execute.return_value = (0, '/dev/vdb', '')
+        p.setup()
+
+        mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
+        self.assertIsNotNone(p.client)
+        self.assertTrue(p.setup_done)
+
+    def test_fio_job_file_no_disk__setup(self, mock_ssh):
+
+        options = {
+            'job_file': 'job_file.ini',
+            'directory': '/FIO_Test'
+        }
+        args = {'options': options}
+        p = fio.Fio(args, self.ctx)
+        mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
         p.setup()
 
         mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
@@ -189,7 +204,7 @@ class FioTestCase(unittest.TestCase):
 
         sample_output = self._read_sample_output(self.sample_output['rw'])
         mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
-        self.assertRaises(AssertionError, p.run, result)
+        self.assertRaises(y_exc.SLAValidationError, p.run, result)
 
     def test_fio_successful_bw_iops_sla(self, mock_ssh):
 
@@ -238,7 +253,7 @@ class FioTestCase(unittest.TestCase):
 
         sample_output = self._read_sample_output(self.sample_output['rw'])
         mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
-        self.assertRaises(AssertionError, p.run, result)
+        self.assertRaises(y_exc.SLAValidationError, p.run, result)
 
     def test_fio_unsuccessful_script_error(self, mock_ssh):
 
@@ -263,11 +278,3 @@ class FioTestCase(unittest.TestCase):
         with open(output) as f:
             sample_output = f.read()
         return sample_output
-
-
-def main():
-    unittest.main()
-
-
-if __name__ == '__main__':
-    main()