summaryrefslogtreecommitdiff
path: root/ironic/tests/unit/cmd/test_status.py
diff options
context:
space:
mode:
Diffstat (limited to 'ironic/tests/unit/cmd/test_status.py')
-rw-r--r--ironic/tests/unit/cmd/test_status.py82
1 files changed, 82 insertions, 0 deletions
diff --git a/ironic/tests/unit/cmd/test_status.py b/ironic/tests/unit/cmd/test_status.py
index f776e2d51..2d044cc13 100644
--- a/ironic/tests/unit/cmd/test_status.py
+++ b/ironic/tests/unit/cmd/test_status.py
@@ -14,6 +14,7 @@
from unittest import mock
+from oslo_db import sqlalchemy
from oslo_upgradecheck.upgradecheck import Code
from ironic.cmd import dbsync
@@ -38,3 +39,84 @@ class TestUpgradeChecks(db_base.DbTestCase):
check_result = self.cmd._check_obj_versions()
self.assertEqual(Code.FAILURE, check_result.code)
self.assertEqual(msg, check_result.details)
+
+ def test__check_allocations_table_ok(self):
+ check_result = self.cmd._check_allocations_table()
+ self.assertEqual(Code.SUCCESS,
+ check_result.code)
+
+ @mock.patch.object(sqlalchemy.enginefacade.reader,
+ 'get_engine', autospec=True)
+ def test__check_allocations_table_latin1(self, mock_reader):
+ mock_engine = mock.Mock()
+ mock_res = mock.Mock()
+ mock_res.all.return_value = (
+ '... ENGINE=InnoDB DEFAULT CHARSET=latin1',
+ )
+ mock_engine.url = '..mysql..'
+ mock_engine.execute.return_value = mock_res
+ mock_reader.return_value = mock_engine
+ check_result = self.cmd._check_allocations_table()
+ self.assertEqual(Code.WARNING,
+ check_result.code)
+ expected_msg = ('The Allocations table is is not using UTF8 '
+ 'encoding. This is corrected in later versions '
+ 'of Ironic, where the table character set schema '
+ 'is automatically migrated. Continued use of a '
+ 'non-UTF8 character set may produce unexpected '
+ 'results.')
+ self.assertEqual(expected_msg, check_result.details)
+
+ @mock.patch.object(sqlalchemy.enginefacade.reader,
+ 'get_engine', autospec=True)
+ def test__check_allocations_table_myiasm(self, mock_reader):
+ mock_engine = mock.Mock()
+ mock_res = mock.Mock()
+ mock_engine.url = '..mysql..'
+ mock_res.all.return_value = (
+ '... ENGINE=MyIASM DEFAULT CHARSET=utf8',
+ )
+ mock_engine.execute.return_value = mock_res
+ mock_reader.return_value = mock_engine
+ check_result = self.cmd._check_allocations_table()
+ self.assertEqual(Code.WARNING,
+ check_result.code)
+ expected_msg = ('The engine used by MySQL for the allocations '
+ 'table is not the intended engine for the Ironic '
+ 'database tables to use. This may have been a '
+ 'result of an error with the table creation schema. '
+ 'This may require Database Administrator '
+ 'intervention and downtime to dump, modify the '
+ 'table engine to utilize InnoDB, and reload the '
+ 'allocations table to utilize the InnoDB engine.')
+ self.assertEqual(expected_msg, check_result.details)
+
+ @mock.patch.object(sqlalchemy.enginefacade.reader,
+ 'get_engine', autospec=True)
+ def test__check_allocations_table_myiasm_both(self, mock_reader):
+ mock_engine = mock.Mock()
+ mock_res = mock.Mock()
+ mock_engine.url = '..mysql..'
+ mock_res.all.return_value = (
+ '... ENGINE=MyIASM DEFAULT CHARSET=latin1',
+ )
+ mock_engine.execute.return_value = mock_res
+ mock_reader.return_value = mock_engine
+ check_result = self.cmd._check_allocations_table()
+ self.assertEqual(Code.WARNING,
+ check_result.code)
+ expected_msg = ('The Allocations table is is not using UTF8 '
+ 'encoding. This is corrected in later versions '
+ 'of Ironic, where the table character set schema '
+ 'is automatically migrated. Continued use of a '
+ 'non-UTF8 character set may produce unexpected '
+ 'results. Additionally: '
+ 'The engine used by MySQL for the allocations '
+ 'table is not the intended engine for the Ironic '
+ 'database tables to use. This may have been a '
+ 'result of an error with the table creation schema. '
+ 'This may require Database Administrator '
+ 'intervention and downtime to dump, modify the '
+ 'table engine to utilize InnoDB, and reload the '
+ 'allocations table to utilize the InnoDB engine.')
+ self.assertEqual(expected_msg, check_result.details)