Przeglądaj źródła

CI: Adds integration tests to GitHub Actions

Adds `CORIOLIS_TEST_SSH_KEY_PATH` configuration option for the
integration tests.
Claudiu Belu 3 tygodni temu
rodzic
commit
4b45b034c6

+ 51 - 0
.github/workflows/integration-tests.yml

@@ -0,0 +1,51 @@
+name: Coriolis Integration Tests
+
+on:
+  workflow_dispatch:
+  pull_request:
+    branches: [ "master" ]
+
+permissions:
+  contents: read
+
+jobs:
+  integration:
+    runs-on: ubuntu-24.04
+
+    steps:
+    - name: Checkout repository
+      uses: actions/checkout@v4
+
+    - name: Set up Python 3.10
+      uses: actions/setup-python@v4
+      with:
+        python-version: "3.10"
+        architecture: "x64"
+
+    - name: Install tox
+      shell: bash
+      run: |
+        sudo apt install tox
+
+    - name: Install scsi_debug kernel module
+      shell: bash
+      run: |
+        sudo apt-get install -y linux-modules-extra-$(uname -r)
+
+    - name: Set up SSH for localhost
+      shell: bash
+      run: |
+        sudo apt-get install -y openssh-server
+        sudo mkdir -p /root/.ssh
+        sudo chmod 700 /root/.ssh
+        sudo ssh-keygen -t rsa -b 4096 -N "" -f /root/.ssh/id_rsa
+        sudo bash -c 'cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys'
+        sudo chmod 600 /root/.ssh/authorized_keys
+        sudo bash -c 'echo "PermitRootLogin yes" >> /etc/ssh/sshd_config'
+        sudo systemctl start ssh
+        sudo ssh-keyscan -H 127.0.0.1 | sudo tee -a /root/.ssh/known_hosts
+
+    - name: Run integration tests
+      shell: bash
+      run: |
+        sudo -E tox -e integration -v

+ 7 - 2
coriolis/tests/integration/base.py

@@ -33,6 +33,11 @@ from coriolis.tests import test_base
 CONF = cfg.CONF
 LOG = logging.getLogger(__name__)
 
+# Path to the SSH private key used to connect to the (local) provider.
+# Override via the CORIOLIS_TEST_SSH_KEY_PATH environment variable.
+_TEST_SSH_KEY_PATH = os.environ.get(
+    'CORIOLIS_TEST_SSH_KEY_PATH', '/root/.ssh/id_rsa')
+
 
 class CoriolisIntegrationTestBase(test_base.CoriolisBaseTestCase):
     """Base class for integration tests."""
@@ -112,7 +117,7 @@ class ReplicaIntegrationTestBase(CoriolisIntegrationTestBase):
             description="integration source endpoint",
             connection_info={
                 "block_device_path": self._src_device,
-                "pkey_path": "/home/ubuntu/.ssh/id_rsa",
+                "pkey_path": _TEST_SSH_KEY_PATH,
             },
         )
 
@@ -122,7 +127,7 @@ class ReplicaIntegrationTestBase(CoriolisIntegrationTestBase):
             description="integration destination endpoint",
             connection_info={
                 "devices": [self._dst_device],
-                "pkey_path": "/home/ubuntu/.ssh/id_rsa",
+                "pkey_path": _TEST_SSH_KEY_PATH,
             },
         )
 

+ 3 - 1
tox.ini

@@ -27,10 +27,12 @@ commands =
   coverage xml -o cover/coverage.xml
 
 [testenv:integration]
-# Must be run as root: sudo tox -e integration
+# Must be run as root: sudo -E tox -e integration
 # Requires the scsi_debug kernel module: modinfo scsi_debug
 # Requires kernel version 5.11 or newer (scsi_debug: per_host_store=1 parameter)
 setenv = {[testenv]setenv}
+passenv =
+  CORIOLIS_TEST_SSH_KEY_PATH
 deps =
   {[testenv]deps}
   git+https://github.com/cloudbase/python-coriolisclient.git