From cf5041f425e6659cf51dd41dc6d2b56b41cc5512 Mon Sep 17 00:00:00 2001 From: Kostiantyn Kostiuk Date: Thu, 3 Oct 2024 14:44:57 +0300 Subject: [PATCH 1/4] Attach control bridge to host The flush test requires sending UDP packets to a PDU device. We will emulate this device on the host, so we need a connection between client VMs and the host. Attaching the br_world to the client is bad because a client can download updates/drivers/applications from the Internet and spend CPU/RAM resources in vain. Signed-off-by: Kostiantyn Kostiuk --- bin/ns_unshared | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bin/ns_unshared b/bin/ns_unshared index c952ba5f..522f5668 100755 --- a/bin/ns_unshared +++ b/bin/ns_unshared @@ -40,6 +40,10 @@ module AutoHCK %w[ip link set br_world up], %w[ip route add default via 10.0.2.2], %w[ip link add br_ctrl type bridge], + # See HLK-Setup-Scripts IP configuration + # https://github.com/HCK-CI/HLK-Setup-Scripts/blob/master/client.ps1 + # needed for access to host without full Internet access + %w[ip addr add 192.168.100.100/24 dev br_ctrl], %w[ip link set br_ctrl up], %w[ip link add br_test type bridge], %w[ip link set br_test up] From 8da7698382e0f0bd744bc3a779b5627205b81f65 Mon Sep 17 00:00:00 2001 From: Kostiantyn Kostiuk Date: Thu, 3 Oct 2024 14:53:49 +0300 Subject: [PATCH 2/4] Add fake SNMP reset tool The flush test sends an SNMP request to PDU to reset the power on the hardware PC. As the flush test sends only one type of request we don't need to parse it and can just wait for any UDP packet and perform a hard reset of the VM. Signed-off-by: Kostiantyn Kostiuk --- bin/fake-snmp-reset | 50 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100755 bin/fake-snmp-reset diff --git a/bin/fake-snmp-reset b/bin/fake-snmp-reset new file mode 100755 index 00000000..cec8a97e --- /dev/null +++ b/bin/fake-snmp-reset @@ -0,0 +1,50 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# Intended to be usable as a standalone script +# it is not a part of the AutoHCK module + +require 'json' +require 'logger' +require 'socket' + +@logger = Logger.new('fake-snmp-reset.txt') + +qmp_socket_file = ARGV[0] + +def send_cmd(qmp_socket, cmd) + @logger.info "Sending #{cmd} via QMP" + qmp_socket.write JSON.dump({ 'execute' => cmd }) + qmp_socket.flush + + loop do + response = JSON.parse(qmp_socket.readline) + break response['return'] if response.key?('return') + + @logger.error(response['error'].to_s) if response.key?('error') + end +end + +count = 0 + +@logger.info 'Initializing UDP socket' +UDPSocket.open do |socket| + socket.bind('0.0.0.0', 'snmp') + @logger.info "Listening on #{socket.local_address.inspect_sockaddr}" + + loop do + _, addr = socket.recvfrom(0) + @logger.info "Received data from #{addr[3]}:#{addr[1]}" + + # Emulate that we do not get the UDP packet immediately + sleep 2 + + @logger.info "Initializing QMP session for #{qmp_socket_file}" + UNIXSocket.open(qmp_socket_file) do |qmp_socket| + send_cmd(qmp_socket, 'qmp_capabilities') + send_cmd(qmp_socket, 'system_reset') + count += 1 + @logger.info "Rebooting... #{count}" + end + end +end From 947ca6f74d7190c1f5ffd2d3b83aeb9dd7573ffc Mon Sep 17 00:00:00 2001 From: Kostiantyn Kostiuk Date: Thu, 3 Oct 2024 20:15:57 +0300 Subject: [PATCH 3/4] vioscsi: Enable flush test Signed-off-by: Kostiantyn Kostiuk --- lib/engines/hcktest/drivers/vioscsi.json | 1 - lib/engines/hcktest/hcktest.json | 15 +++++++++++++++ .../qemuhck/devices/virtio-scsi-pci.json | 11 ++++++++++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/lib/engines/hcktest/drivers/vioscsi.json b/lib/engines/hcktest/drivers/vioscsi.json index 3f60de54..09091d09 100644 --- a/lib/engines/hcktest/drivers/vioscsi.json +++ b/lib/engines/hcktest/drivers/vioscsi.json @@ -32,7 +32,6 @@ } ], "reject_test_names": [ - "Flush Test", "DF - Embedded Signature Verification Test (Certification)", "DF - Embedded Signature Verification Test (Tuning and Validation)", "Storage HBA Firmware Update", diff --git a/lib/engines/hcktest/hcktest.json b/lib/engines/hcktest/hcktest.json index ff149e50..a7843df0 100644 --- a/lib/engines/hcktest/hcktest.json +++ b/lib/engines/hcktest/hcktest.json @@ -20,6 +20,21 @@ "value": 0 } ] + }, + { + "tests": [ + "Flush Test" + ], + "parameters": [ + { + "name": "IP", + "value": "192.168.100.100" + }, + { + "name": "Outlet", + "value": "161" + } + ] } ] } diff --git a/lib/setupmanagers/qemuhck/devices/virtio-scsi-pci.json b/lib/setupmanagers/qemuhck/devices/virtio-scsi-pci.json index 90d3fd2f..884c798c 100644 --- a/lib/setupmanagers/qemuhck/devices/virtio-scsi-pci.json +++ b/lib/setupmanagers/qemuhck/devices/virtio-scsi-pci.json @@ -1,9 +1,18 @@ { "name": "virtio-scsi-pci", "type": "storage", + "define_variables": { + "@scsi_qmp_socket@": "scsi_qmp_@run_id@_@client_id@_sock" + }, + "pre_start_commands": [ + "rm -vf @scsi_qmp_socket@", + "@source@/bin/fake-snmp-reset @scsi_qmp_socket@ &" + ], "command_line": [ "-drive file=@image_path@,if=none,format=@image_format@,id=virtio_scsi_@run_id@_@client_id@@drive_cache_options@", "-device virtio-scsi-pci@device_extra_param@@iommu_device_param@,id=scsi,bus=@bus_name@.0", - "-device scsi-hd,drive=virtio_scsi_@run_id@_@client_id@,serial=@client_id@scsi@run_id@@bootindex@" + "-device scsi-hd,drive=virtio_scsi_@run_id@_@client_id@,serial=@client_id@scsi@run_id@@bootindex@", + "-chardev socket,id=scsi_qmp,path=@scsi_qmp_socket@,server=on,wait=off", + "-mon chardev=scsi_qmp,mode=control" ] } From c136f760c1c16d89d4723fedac3b3403d925efd6 Mon Sep 17 00:00:00 2001 From: Kostiantyn Kostiuk Date: Fri, 4 Oct 2024 19:44:19 +0300 Subject: [PATCH 4/4] viostor: Enable flush test Signed-off-by: Kostiantyn Kostiuk --- lib/engines/hcktest/drivers/viostor.json | 1 - lib/setupmanagers/qemuhck/devices/virtio-blk-pci.json | 11 ++++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/engines/hcktest/drivers/viostor.json b/lib/engines/hcktest/drivers/viostor.json index 161e2a00..452b4dc3 100644 --- a/lib/engines/hcktest/drivers/viostor.json +++ b/lib/engines/hcktest/drivers/viostor.json @@ -32,7 +32,6 @@ } ], "reject_test_names": [ - "Flush Test", "DF - Embedded Signature Verification Test (Certification)", "DF - Embedded Signature Verification Test (Tuning and Validation)", "Thin Provisioning SCSI Compliance Test (LOGO)", diff --git a/lib/setupmanagers/qemuhck/devices/virtio-blk-pci.json b/lib/setupmanagers/qemuhck/devices/virtio-blk-pci.json index 106c9b41..4c348861 100644 --- a/lib/setupmanagers/qemuhck/devices/virtio-blk-pci.json +++ b/lib/setupmanagers/qemuhck/devices/virtio-blk-pci.json @@ -1,8 +1,17 @@ { "name": "virtio-blk-pci", "type": "storage", + "define_variables": { + "@blk_qmp_socket@": "blk_qmp_@run_id@_@client_id@_sock" + }, + "pre_start_commands": [ + "rm -vf @blk_qmp_socket@", + "@source@/bin/fake-snmp-reset @blk_qmp_socket@ &" + ], "command_line": [ "-drive file=@image_path@,if=none,format=@image_format@,id=virtio_blk_@run_id@_@client_id@@drive_cache_options@", - "-device virtio-blk-pci@device_extra_param@@iommu_device_param@,bus=@bus_name@.0,drive=virtio_blk_@run_id@_@client_id@,serial=@client_id@blk@run_id@@bootindex@" + "-device virtio-blk-pci@device_extra_param@@iommu_device_param@,bus=@bus_name@.0,drive=virtio_blk_@run_id@_@client_id@,serial=@client_id@blk@run_id@@bootindex@", + "-chardev socket,id=blk_qmp,path=@blk_qmp_socket@,server=on,wait=off", + "-mon chardev=blk_qmp,mode=control" ] }