Skip to content

Commit 8bb2c87

Browse files
committed
Dev: unittests: Adjust unit test for previous commits
1 parent f2bdf87 commit 8bb2c87

File tree

2 files changed

+0
-143
lines changed

2 files changed

+0
-143
lines changed

test/unittests/test_bootstrap.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,27 +1461,6 @@ def test_remove_qdevice_reload(self, mock_qdevice_configured, mock_confirm, mock
14611461
mock_remove_db.assert_called_once_with()
14621462
mock_cluster_shell_inst.get_stdout_or_raise_error.assert_called_once_with("corosync-cfgtool -R")
14631463

1464-
@mock.patch('crmsh.service_manager.ServiceManager.start_service')
1465-
@mock.patch('crmsh.qdevice.QDevice')
1466-
@mock.patch('crmsh.corosync.get_value')
1467-
@mock.patch('crmsh.corosync.is_qdevice_tls_on')
1468-
@mock.patch('crmsh.log.LoggerUtils.status_long')
1469-
def test_start_qdevice_on_join_node(self, mock_status_long, mock_qdevice_tls, mock_get_value, mock_qdevice, mock_start_service):
1470-
mock_qdevice_tls.return_value = True
1471-
mock_get_value.return_value = "10.10.10.123"
1472-
mock_qdevice_inst = mock.Mock()
1473-
mock_qdevice.return_value = mock_qdevice_inst
1474-
mock_qdevice_inst.certificate_process_on_join = mock.Mock()
1475-
1476-
bootstrap.start_qdevice_on_join_node("node2")
1477-
1478-
mock_status_long.assert_called_once_with("Starting corosync-qdevice.service")
1479-
mock_qdevice_tls.assert_called_once_with()
1480-
mock_get_value.assert_called_once_with("quorum.device.net.host")
1481-
mock_qdevice.assert_called_once_with("10.10.10.123", cluster_node="node2")
1482-
mock_qdevice_inst.certificate_process_on_join.assert_called_once_with()
1483-
mock_start_service.assert_called_once_with("corosync-qdevice.service", enable=True)
1484-
14851464
@mock.patch('crmsh.sh.ShellUtils.get_stdout_stderr')
14861465
@mock.patch('crmsh.log.LoggerUtils.log_only_to_file')
14871466
def test_invoke(self, mock_log, mock_run):

test/unittests/test_qdevice.py

Lines changed: 0 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ def setUp(self):
149149
self.qdevice_with_hostname = qdevice.QDevice("node.qnetd")
150150
self.qdevice_with_invalid_port = qdevice.QDevice("10.10.10.123", port=100)
151151
self.qdevice_with_invalid_tie_breaker = qdevice.QDevice("10.10.10.123", tie_breaker="wrong")
152-
self.qdevice_with_ip_cluster_node = qdevice.QDevice("10.10.10.123", cluster_node="node1.com")
153152
self.qdevice_with_invalid_cmds_relative_path = qdevice.QDevice("10.10.10.123", cmds="ls")
154153
self.qdevice_with_invalid_cmds_not_exist = qdevice.QDevice("10.10.10.123", cmds="/not_exist")
155154
self.qdevice_with_cluster_name = qdevice.QDevice("10.10.10.123", cluster_name="hacluster1")
@@ -170,10 +169,6 @@ def test_qnetd_cacert_on_local(self):
170169
res = self.qdevice_with_ip.qnetd_cacert_on_local
171170
self.assertEqual(res, "/etc/corosync/qdevice/net/10.10.10.123/qnetd-cacert.crt")
172171

173-
def test_qnetd_cacert_on_cluster(self):
174-
res = self.qdevice_with_ip_cluster_node.qnetd_cacert_on_cluster
175-
self.assertEqual(res, "/etc/corosync/qdevice/net/node1.com/qnetd-cacert.crt")
176-
177172
def test_qdevice_crq_on_qnetd(self):
178173
res = self.qdevice_with_cluster_name.qdevice_crq_on_qnetd
179174
self.assertEqual(res, "/etc/corosync/qnetd/nssdb/qdevice-net-node.crq.hacluster1")
@@ -198,10 +193,6 @@ def test_qdevice_p12_on_local(self):
198193
res = self.qdevice_with_ip.qdevice_p12_on_local
199194
self.assertEqual(res, "/etc/corosync/qdevice/net/nssdb/qdevice-net-node.p12")
200195

201-
def test_qdevice_p12_on_cluster(self):
202-
res = self.qdevice_with_ip_cluster_node.qdevice_p12_on_cluster
203-
self.assertEqual(res, "/etc/corosync/qdevice/net/node1.com/qdevice-net-node.p12")
204-
205196
@mock.patch('crmsh.utils.InterfacesInfo.ip_in_local')
206197
@mock.patch('crmsh.utils.node_reachable_check')
207198
@mock.patch('socket.getaddrinfo')
@@ -624,119 +615,6 @@ def test_certificate_process_on_init(self, mock_fetch_qnetd_crt_from_qnetd,
624615
mock_copy_p12_to_cluster.assert_called_once()
625616
mock_import_p12_on_cluster.assert_called_once()
626617

627-
@mock.patch("crmsh.qdevice.QDevice.log_only_to_file")
628-
@mock.patch("os.path.exists")
629-
@mock.patch("crmsh.qdevice.QDevice.qnetd_cacert_on_cluster", new_callable=mock.PropertyMock)
630-
@mock.patch("crmsh.qdevice.QDevice.qnetd_cacert_on_local", new_callable=mock.PropertyMock)
631-
@mock.patch("crmsh.parallax.parallax_slurp")
632-
def test_fetch_qnetd_crt_from_cluster_exist(self, mock_parallax_slurp, mock_qnetd_cacert_local,
633-
mock_qnetd_cacert_cluster, mock_exists, mock_log):
634-
mock_exists.return_value = True
635-
mock_qnetd_cacert_cluster.return_value = "/etc/corosync/qdevice/net/node1.com/qnetd-cacert.crt"
636-
637-
self.qdevice_with_ip_cluster_node.fetch_qnetd_crt_from_cluster()
638-
639-
mock_log.assert_not_called()
640-
mock_exists.assert_called_once_with(mock_qnetd_cacert_cluster.return_value)
641-
mock_qnetd_cacert_cluster.assert_called_once_with()
642-
mock_qnetd_cacert_local.assert_not_called()
643-
mock_parallax_slurp.assert_not_called()
644-
645-
@mock.patch("crmsh.qdevice.QDevice.log_only_to_file")
646-
@mock.patch("os.path.exists")
647-
@mock.patch("crmsh.qdevice.QDevice.qnetd_cacert_on_cluster", new_callable=mock.PropertyMock)
648-
@mock.patch("crmsh.qdevice.QDevice.qnetd_cacert_on_local", new_callable=mock.PropertyMock)
649-
@mock.patch("crmsh.parallax.parallax_slurp")
650-
def test_fetch_qnetd_crt_from_cluster(self, mock_parallax_slurp, mock_qnetd_cacert_local,
651-
mock_qnetd_cacert_cluster, mock_exists, mock_log):
652-
mock_exists.return_value = False
653-
mock_qnetd_cacert_cluster.return_value = "/etc/corosync/qdevice/net/node1.com/qnetd-cacert.crt"
654-
mock_qnetd_cacert_local.return_value = "/etc/corosync/qdevice/net/10.10.10.123/qnetd-cacert.crt"
655-
656-
self.qdevice_with_ip_cluster_node.fetch_qnetd_crt_from_cluster()
657-
658-
mock_log.assert_called_once_with("Step 1: Fetch qnetd-cacert.crt from node1.com")
659-
mock_exists.assert_called_once_with(mock_qnetd_cacert_cluster.return_value)
660-
mock_qnetd_cacert_cluster.assert_called_once_with()
661-
mock_qnetd_cacert_local.assert_called_once_with()
662-
mock_parallax_slurp.assert_called_once_with(["node1.com"], "/etc/corosync/qdevice/net", mock_qnetd_cacert_local.return_value)
663-
664-
@mock.patch("crmsh.qdevice.QDevice.log_only_to_file")
665-
@mock.patch("crmsh.sh.ClusterShell.get_stdout_or_raise_error")
666-
@mock.patch("crmsh.qdevice.QDevice.qnetd_cacert_on_cluster", new_callable=mock.PropertyMock)
667-
def test_init_db_on_local(self, mock_qnetd_cacert_cluster, mock_stdout_stderr, mock_log):
668-
mock_qnetd_cacert_cluster.return_value = "/etc/corosync/qdevice/net/node1.com/qnetd-cacert.crt"
669-
mock_stdout_stderr.return_value = (0, None, None)
670-
671-
self.qdevice_with_ip_cluster_node.init_db_on_local()
672-
673-
mock_log.assert_called_once_with("Step 2: Initialize database on local",
674-
'corosync-qdevice-net-certutil -i -c /etc/corosync/qdevice/net/node1.com/qnetd-cacert.crt')
675-
mock_qnetd_cacert_cluster.assert_called_once_with()
676-
mock_stdout_stderr.assert_called_once_with("corosync-qdevice-net-certutil -i -c {}".format(mock_qnetd_cacert_cluster.return_value))
677-
678-
@mock.patch("crmsh.qdevice.QDevice.log_only_to_file")
679-
@mock.patch("os.path.exists")
680-
@mock.patch("crmsh.qdevice.QDevice.qdevice_p12_on_cluster", new_callable=mock.PropertyMock)
681-
@mock.patch("crmsh.qdevice.QDevice.qdevice_p12_on_local", new_callable=mock.PropertyMock)
682-
@mock.patch("crmsh.parallax.parallax_slurp")
683-
def test_fetch_p12_from_cluster_exist(self, mock_parallax_slurp, mock_p12_on_local,
684-
mock_p12_on_cluster, mock_exists, mock_log):
685-
mock_exists.return_value = True
686-
mock_p12_on_cluster.return_value = "/etc/corosync/qdevice/net/node1.com/qdevice-net-node.p12"
687-
688-
self.qdevice_with_ip_cluster_node.fetch_p12_from_cluster()
689-
690-
mock_log.assert_not_called()
691-
mock_exists.assert_called_once_with(mock_p12_on_cluster.return_value)
692-
mock_p12_on_cluster.assert_called_once_with()
693-
mock_p12_on_local.assert_not_called()
694-
mock_parallax_slurp.assert_not_called()
695-
696-
@mock.patch("crmsh.qdevice.QDevice.log_only_to_file")
697-
@mock.patch("os.path.exists")
698-
@mock.patch("crmsh.qdevice.QDevice.qdevice_p12_on_cluster", new_callable=mock.PropertyMock)
699-
@mock.patch("crmsh.qdevice.QDevice.qdevice_p12_on_local", new_callable=mock.PropertyMock)
700-
@mock.patch("crmsh.parallax.parallax_slurp")
701-
def test_fetch_p12_from_cluster(self, mock_parallax_slurp, mock_p12_on_local,
702-
mock_p12_on_cluster, mock_exists, mock_log):
703-
mock_exists.return_value = False
704-
mock_p12_on_cluster.return_value = "/etc/corosync/qdevice/net/node1.com/qdevice-net-node.p12"
705-
mock_p12_on_local.return_value = "/etc/corosync/qdevice/net/nssdb/qdevice-net-node.p12"
706-
707-
self.qdevice_with_ip_cluster_node.fetch_p12_from_cluster()
708-
709-
mock_log.assert_called_once_with("Step 3: Fetch qdevice-net-node.p12 from node1.com")
710-
mock_exists.assert_called_once_with(mock_p12_on_cluster.return_value)
711-
mock_p12_on_cluster.assert_called_once_with()
712-
mock_p12_on_local.assert_called_once_with()
713-
mock_parallax_slurp.assert_called_once_with(["node1.com"], '/etc/corosync/qdevice/net', mock_p12_on_local.return_value)
714-
715-
@mock.patch("crmsh.qdevice.QDevice.log_only_to_file")
716-
@mock.patch("crmsh.sh.ClusterShell.get_stdout_or_raise_error")
717-
@mock.patch("crmsh.qdevice.QDevice.qdevice_p12_on_cluster", new_callable=mock.PropertyMock)
718-
def test_import_p12_on_local(self, mock_p12_on_cluster, mock_stdout_stderr, mock_log):
719-
mock_p12_on_cluster.return_value = "/etc/corosync/qdevice/net/node1.com/qdevice-net-node.p12"
720-
721-
self.qdevice_with_ip_cluster_node.import_p12_on_local()
722-
723-
mock_log.assert_called_once_with("Step 4: Import cluster certificate and key",
724-
'corosync-qdevice-net-certutil -m -c /etc/corosync/qdevice/net/node1.com/qdevice-net-node.p12')
725-
mock_p12_on_cluster.assert_called_once_with()
726-
mock_stdout_stderr.assert_called_once_with("corosync-qdevice-net-certutil -m -c {}".format(mock_p12_on_cluster.return_value))
727-
728-
@mock.patch("crmsh.qdevice.QDevice.import_p12_on_local")
729-
@mock.patch("crmsh.qdevice.QDevice.fetch_p12_from_cluster")
730-
@mock.patch("crmsh.qdevice.QDevice.init_db_on_local")
731-
@mock.patch("crmsh.qdevice.QDevice.fetch_qnetd_crt_from_cluster")
732-
def test_certificate_process_on_join(self, mock_fetch_qnetd_crt_from_cluster, mock_init_db_on_local,
733-
mock_fetch_p12_from_cluster, mock_import_p12_on_local):
734-
self.qdevice_with_ip.certificate_process_on_join()
735-
mock_fetch_qnetd_crt_from_cluster.assert_called_once_with()
736-
mock_init_db_on_local.assert_called_once_with()
737-
mock_fetch_p12_from_cluster.assert_called_once_with()
738-
mock_import_p12_on_local.assert_called_once_with()
739-
740618
@mock.patch("crmsh.parallax.parallax_call")
741619
@mock.patch('crmsh.utils.list_cluster_nodes')
742620
@mock.patch('os.path.exists')

0 commit comments

Comments
 (0)