summaryrefslogtreecommitdiff
path: root/ironic/tests/unit/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'ironic/tests/unit/drivers')
-rw-r--r--ironic/tests/unit/drivers/ks_extra_vars.tmpl41
-rw-r--r--ironic/tests/unit/drivers/ks_missing_var.tmpl37
-rw-r--r--ironic/tests/unit/drivers/modules/test_pxe.py9
3 files changed, 85 insertions, 2 deletions
diff --git a/ironic/tests/unit/drivers/ks_extra_vars.tmpl b/ironic/tests/unit/drivers/ks_extra_vars.tmpl
new file mode 100644
index 000000000..37f2e2d19
--- /dev/null
+++ b/ironic/tests/unit/drivers/ks_extra_vars.tmpl
@@ -0,0 +1,41 @@
+lang en_US
+keyboard us
+timezone UTC --utc
+#platform x86, AMD64, or Intel EM64T
+text
+cmdline
+reboot
+selinux --enforcing
+firewall --enabled
+firstboot --disabled
+
+bootloader --location=mbr --append="rhgb quiet crashkernel=auto"
+zerombr
+clearpart --all --initlabel
+autopart
+
+# Downloading and installing OS image using liveimg section is mandatory
+liveimg --url {{ ks_options.liveimg_url }}
+
+# Following %pre, %onerror and %trackback sections are mandatory
+%pre
+/usr/bin/curl -X PUT -H 'Content-Type: application/json' -H 'Accept:application/json' -d '{"agent_token": {{ ks_options.agent_token }}, "agent_status": "start"}' {{ ks_options.heartbeat_url }}
+%end
+
+%onerror
+/usr/bin/curl -X PUT -H 'Content-Type: application/json' -H 'Accept:application/json' -d '{"agent_token": {{ ks_options.agent_token }}, "agent_status": "Error: Deploying using anaconda. Check console for more information."}' {{ ks_options.heartbeat_url }}
+%end
+
+%traceback
+/usr/bin/curl -X PUT -H 'Content-Type: application/json' -H 'Accept:application/json' -d '{"agent_token": {{ ks_options.agent_token }}, "agent_status": "Error: Installer crashed unexpectedly."}' {{ ks_options.heartbeat_url }}
+%end
+
+# Sending callback after the installation is mandatory
+%post
+/usr/bin/curl -X PUT -H 'Content-Type: application/json' -H 'Accept:application/json' -d '{"agent_token": {{ ks_options.agent_token }}, "agent_status": "success"}' {{ ks_options.heartbeat_url }}
+%end
+
+# config_drive is an extra variable and should raise an exception
+%post
+{{ config_drive }}
+%end
diff --git a/ironic/tests/unit/drivers/ks_missing_var.tmpl b/ironic/tests/unit/drivers/ks_missing_var.tmpl
new file mode 100644
index 000000000..ad160fb8f
--- /dev/null
+++ b/ironic/tests/unit/drivers/ks_missing_var.tmpl
@@ -0,0 +1,37 @@
+lang en_US
+keyboard us
+timezone UTC --utc
+#platform x86, AMD64, or Intel EM64T
+text
+cmdline
+reboot
+selinux --enforcing
+firewall --enabled
+firstboot --disabled
+
+bootloader --location=mbr --append="rhgb quiet crashkernel=auto"
+zerombr
+clearpart --all --initlabel
+autopart
+
+# Downloading and installing OS image using liveimg section is mandatory
+liveimg --url http://this_should_raise_an_exception
+
+# Following %pre, %onerror and %trackback sections are mandatory
+%pre
+/usr/bin/curl -X PUT -H 'Content-Type: application/json' -H 'Accept:application/json' -d '{"agent_token": {{ ks_options.agent_token }}, "agent_status": "start"}' {{ ks_options.heartbeat_url }}
+%end
+
+%onerror
+/usr/bin/curl -X PUT -H 'Content-Type: application/json' -H 'Accept:application/json' -d '{"agent_token": {{ ks_options.agent_token }}, "agent_status": "Error: Deploying using anaconda. Check console for more information."}' {{ ks_options.heartbeat_url }}
+%end
+
+%traceback
+/usr/bin/curl -X PUT -H 'Content-Type: application/json' -H 'Accept:application/json' -d '{"agent_token": {{ ks_options.agent_token }}, "agent_status": "Error: Installer crashed unexpectedly."}' {{ ks_options.heartbeat_url }}
+%end
+
+# Sending callback after the installation is mandatory
+%post
+/usr/bin/curl -X PUT -H 'Content-Type: application/json' -H 'Accept:application/json' -d '{"agent_token": {{ ks_options.agent_token }}, "agent_status": "success"}' {{ ks_options.heartbeat_url }}
+%end
+
diff --git a/ironic/tests/unit/drivers/modules/test_pxe.py b/ironic/tests/unit/drivers/modules/test_pxe.py
index a204f6954..3f7d9e4b7 100644
--- a/ironic/tests/unit/drivers/modules/test_pxe.py
+++ b/ironic/tests/unit/drivers/modules/test_pxe.py
@@ -755,9 +755,10 @@ class PXEBootTestCase(db_base.DbTestCase):
return_value='http://fakeserver/api', autospec=True)
@mock.patch('ironic.common.utils.render_template', autospec=True)
@mock.patch('ironic.common.utils.write_to_file', autospec=True)
+ @mock.patch('ironic.common.utils.execute', autospec=True)
def test_prepare_instance_kickstart(
- self, write_file_mock, render_mock, api_url_mock, boot_opt_mock,
- get_image_info_mock, cache_mock, dhcp_factory_mock,
+ self, exec_mock, write_file_mock, render_mock, api_url_mock,
+ boot_opt_mock, get_image_info_mock, cache_mock, dhcp_factory_mock,
create_pxe_config_mock, switch_pxe_config_mock,
set_boot_device_mock):
image_info = {'kernel': ['ins_kernel_id', '/path/to/kernel'],
@@ -784,6 +785,10 @@ class PXEBootTestCase(db_base.DbTestCase):
ipxe_enabled=False)
cache_mock.assert_called_once_with(
task, image_info, False)
+ if os.path.isfile('/usr/bin/ksvalidator'):
+ exec_mock.assert_called_once_with(
+ 'ksvalidator', mock.ANY, check_on_exit=[0], attempts=1
+ )
provider_mock.update_dhcp.assert_called_once_with(task, dhcp_opts)
render_mock.assert_called()
write_file_mock.assert_called_with(