Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests dep, aslr and qos limiting #50

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 35 additions & 74 deletions storage/tests/system_tools/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,26 @@ def run_fio(self, host_target_id, virtio_blk, fio_args):
)
return self._terminal.execute(cmd) == "True"

def get_virtio_blk_qos_capabilities(self, ipu_storage_ip, sma_port):
return self._terminal.execute(
f"""docker exec {self.id} """
f"""python-c 'import sys; sys.path("/"); """
f"""from scripts.disk_infrastructure import get_virtio_blk_qos_capabilities; """
f"""get_virtio_blk_qos_capabilities"""
f""" {ipu_storage_ip} {sma_port}"""
)

def set_max_blk_qos(self, ipu_storage_ip, sma_port, virtio_blk):
return self._terminal.execute(
f"""docker exec {self.id} """
f"""python-c 'import sys; sys.path("/"); """
f"""from scripts.disk_infrastructure import set_qos_limits; """
f"""set_max_qos_limits"""
f""" {ipu_storage_ip} {sma_port} {virtio_blk} /"/" 0 0 0 16 0 0"""
)

def create_subsystem(
self, ip_addr: str, nqn: str, port_to_expose: int, storage_target_port: int
self, ip_addr: str, nqn: str, port_to_expose: int, storage_target_port: int
):
return self._terminal.execute(
f"""docker exec {self.id} """
Expand All @@ -128,7 +146,7 @@ def create_subsystem(
)

def create_ramdrives(
self, number: int, ip_addr: str, nqn: str, storage_target_port: int
self, number: int, ip_addr: str, nqn: str, storage_target_port: int
):
volumes_ids = []
for i in range(number):
Expand All @@ -143,7 +161,7 @@ def create_ramdrives(
return volumes_ids

def create_ramdrive(
self, number: int, ip_addr: str, nqn: str, storage_target_port: int
self, number: int, ip_addr: str, nqn: str, storage_target_port: int
):
cmd = (
f"""docker exec {self.id} """
Expand All @@ -155,15 +173,15 @@ def create_ramdrive(
return self._terminal.execute(cmd)

def create_virtio_blk_device(
self,
ipu_storage_container_ip: str,
host_target_address_service,
volume_id: str,
physical_id: str,
storage_target_ip: str,
port_to_expose,
nqn,
sma_port,
self,
ipu_storage_container_ip: str,
host_target_address_service,
volume_id: str,
physical_id: str,
storage_target_ip: str,
port_to_expose,
nqn,
sma_port,
):
"""
:return: device handle
Expand All @@ -183,11 +201,11 @@ def create_virtio_blk_device(
return out

def delete_virtio_blk_device(
self,
ipu_storage_container_ip,
host_target_address_service,
device_handle,
sma_port,
self,
ipu_storage_container_ip,
host_target_address_service,
device_handle,
sma_port,
):
cmd = (
f"""docker exec {self.id} """
Expand All @@ -199,63 +217,6 @@ def delete_virtio_blk_device(
)
return self._terminal.execute(cmd) == "True"

def create_sender_cmd(self, cmd):
return (
f"""sudo docker exec {self.id} bash -c 'source /scripts/disk_infrastructure.sh; export PYTHONPATH=/; """
f"""{cmd}"""
""" '"""
)

def create_nvme_device(
self,
ipu_platform_ip,
host_target_ip,
physical_id,
sma_port,
vm_port,
):
cmd = self.create_sender_cmd(
f"""create_nvme_device {ipu_platform_ip} {sma_port} {host_target_ip} {vm_port} {physical_id} 0"""
)
return self._terminal.execute(cmd)

def attach_device(
self,
ipu_platform_ip,
storage_target_ip,
nvme_device_handle,
remote_nvme_storage_guid,
nvme_port,
):
cmd = self.create_sender_cmd(
f"""attach_volume {ipu_platform_ip} "{nvme_device_handle}" "{remote_nvme_storage_guid}" nqn.2016-06.io.spdk:cnode0 {storage_target_ip} {nvme_port}"""
)
return self._terminal.execute(cmd)

def detach_volume(
self,
ipu_platform_ip,
nvme_device_handle,
remote_nvme_storage_guid,
):
cmd = self.create_sender_cmd(
f"""detach_volume {ipu_platform_ip} "{nvme_device_handle}" "{remote_nvme_storage_guid}" """
)
return self._terminal.execute(cmd)

def delete_device(
self,
ipu_platform_ip,
host_target_ip,
nvme_device_handle,
sma_port,
vm_port,
):
cmd = self.create_sender_cmd(
f"""delete_nvme_device {ipu_platform_ip} {sma_port} {host_target_ip} {vm_port} "{nvme_device_handle}" """
)
return self._terminal.execute(cmd)


class HostTargetContainer(DockerContainer):
def __init__(self):
Expand Down
60 changes: 42 additions & 18 deletions storage/tests/tests/test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@
import os

from system_tools.config import (HostTargetConfig, IPUStorageConfig,
StorageTargetConfig, import_base_test)
StorageTargetConfig, TestConfig)

if target in TestConfig().targets or target == "all":
from ptf.base_tests import BaseTest
else:
from system_tools.config import BaseTest

from system_tools.docker import (CMDSenderContainer, HostTargetContainer,
IPUStorageContainer, StorageTargetContainer)
from system_tools.terminals import SSHTerminal

BaseTest = import_base_test(target)


class TestTerminalConnect(BaseTest):
def setUp(self):
Expand Down Expand Up @@ -62,6 +66,26 @@ def tearDown(self):
pass


class TestDepAndAslrEnabled(BaseTest):
def setUp(self):
self.storage_target_terminal = SSHTerminal(StorageTargetConfig())
self.ipu_storage_terminal = SSHTerminal(IPUStorageConfig())
self.host_target_terminal = SSHTerminal(HostTargetConfig())

def runTest(self):
self.assertEqual(
self.ipu_storage_terminal.execute("grep noexec=off /proc/cmdline"),
"",
)
self.assertEqual(
self.storage_target_terminal.execute("cat /proc/self/kernel/randomize_va_space"),
"2",
)

def tearDown(self):
pass


class TestDeployContainers(BaseTest):
def setUp(self):
self.storage_target_terminal = SSHTerminal(StorageTargetConfig())
Expand All @@ -73,22 +97,22 @@ def setUp(self):
self.shared_dir = os.path.join(HostTargetConfig().vm_share_dir_path, "shared")

def runTest(self):
terminals = (
self.storage_target_terminal,
self.ipu_storage_terminal,
self.host_target_terminal,
self.storage_target_terminal.execute(
f"sudo rm -rf {self.storage_target_terminal.config.workdir}"
)
self.storage_target_terminal.execute(
f"mkdir {self.storage_target_terminal.config.workdir}"
)

cmd = f"cd {self.storage_target_terminal.config.workdir} && git clone --branch {self.branch} {self.repository_url}"
self.storage_target_terminal.execute(cmd)

self.storage_target_terminal.execute(
f"ls {self.storage_target_terminal.config.workdir}/ipdk/build"
)
self.storage_target_terminal.execute(
f"cd {self.storage_target_terminal.config.storage_dir} && git log"
)
for terminal in terminals:
cmd = f"sudo rm -rf {self.storage_target_terminal.config.workdir}"
terminal.execute(cmd)
cmd = f"mkdir -p {self.storage_target_terminal.config.workdir}"
terminal.execute(cmd)
cmd = f"cd {self.storage_target_terminal.config.workdir} && git clone --branch {self.branch} {self.repository_url}"
terminal.execute(cmd)
cmd = f"ls {self.storage_target_terminal.config.workdir}/ipdk/build"
terminal.execute(cmd)
cmd = f"cd {self.storage_target_terminal.config.storage_dir} && git log"
terminal.execute(cmd)

self.storage_target_container = StorageTargetContainer()
self.assertIn(
Expand Down