mirror of
https://github.com/rancher/os.git
synced 2025-09-05 00:37:12 +00:00
make tests run on arm64
This commit is contained in:
@@ -9,7 +9,7 @@ rancher:
|
|||||||
interfaces:
|
interfaces:
|
||||||
eth*:
|
eth*:
|
||||||
dhcp: true
|
dhcp: true
|
||||||
eth1:
|
"mac=52:54:00:12:34:59":
|
||||||
address: 10.10.2.17/24
|
address: 10.10.2.17/24
|
||||||
gateway: 10.10.2.2
|
gateway: 10.10.2.2
|
||||||
mtu: 1500
|
mtu: 1500
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
import string
|
import string
|
||||||
import subprocess
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import rostest.util as u
|
import rostest.util as u
|
||||||
@@ -10,8 +9,10 @@ ssh_command = ['./scripts/ssh', '--qemu', '--key', './tests/integration/assets/t
|
|||||||
cloud_config_path = './tests/integration/assets/test_01/cloud-config.yml'
|
cloud_config_path = './tests/integration/assets/test_01/cloud-config.yml'
|
||||||
|
|
||||||
|
|
||||||
net_args = {'amd64': ['-net', 'nic,vlan=1,model=virtio', '-net', 'user,vlan=1,net=10.10.2.0/24'],
|
net_args = {'amd64': ['-net', 'nic,vlan=1,model=virtio,macaddr=52:54:00:12:34:59',
|
||||||
'arm64': ['-netdev', 'user,id=net1,net=10.10.2.0/24', '-device', 'virtio-net-device,netdev=net1']}
|
'-net', 'user,vlan=1,net=10.10.2.0/24'],
|
||||||
|
'arm64': ['-netdev', 'user,id=net1,net=10.10.2.0/24',
|
||||||
|
'-device', 'virtio-net-device,netdev=net1,mac=52:54:00:12:34:59']}
|
||||||
net_args['arm'] = net_args['arm64']
|
net_args['arm'] = net_args['arm64']
|
||||||
|
|
||||||
|
|
||||||
@@ -35,22 +36,18 @@ def test_ssh_authorized_keys(qemu):
|
|||||||
|
|
||||||
@pytest.mark.timeout(40)
|
@pytest.mark.timeout(40)
|
||||||
def test_rancher_environment(qemu, cloud_config):
|
def test_rancher_environment(qemu, cloud_config):
|
||||||
u.wait_for_ssh(qemu, ssh_command)
|
v = SSH(qemu, ssh_command).check_output('''
|
||||||
|
sudo ros env printenv FLANNEL_NETWORK
|
||||||
v = subprocess.check_output(
|
'''.strip())
|
||||||
ssh_command + ['sudo', 'ros', 'env', 'printenv', 'FLANNEL_NETWORK'],
|
|
||||||
stderr=subprocess.STDOUT, universal_newlines=True)
|
|
||||||
|
|
||||||
assert v.strip() == cloud_config['rancher']['environment']['FLANNEL_NETWORK']
|
assert v.strip() == cloud_config['rancher']['environment']['FLANNEL_NETWORK']
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.timeout(40)
|
@pytest.mark.timeout(40)
|
||||||
def test_docker_args(qemu, cloud_config):
|
def test_docker_args(qemu, cloud_config):
|
||||||
u.wait_for_ssh(qemu, ssh_command)
|
v = SSH(qemu, ssh_command).check_output('''
|
||||||
|
ps -ef | grep docker
|
||||||
v = subprocess.check_output(
|
'''.strip())
|
||||||
ssh_command + ['sh', '-c', 'ps -ef | grep docker'],
|
|
||||||
stderr=subprocess.STDOUT, universal_newlines=True)
|
|
||||||
|
|
||||||
expected = string.join(cloud_config['rancher']['docker']['args'])
|
expected = string.join(cloud_config['rancher']['docker']['args'])
|
||||||
|
|
||||||
@@ -59,11 +56,9 @@ def test_docker_args(qemu, cloud_config):
|
|||||||
|
|
||||||
@pytest.mark.timeout(40)
|
@pytest.mark.timeout(40)
|
||||||
def test_dhcpcd(qemu, cloud_config):
|
def test_dhcpcd(qemu, cloud_config):
|
||||||
u.wait_for_ssh(qemu, ssh_command)
|
v = SSH(qemu, ssh_command).check_output('''
|
||||||
|
ps -ef | grep dhcpcd
|
||||||
v = subprocess.check_output(
|
'''.strip())
|
||||||
ssh_command + ['sh', '-c', 'ps -ef | grep dhcpcd'],
|
|
||||||
stderr=subprocess.STDOUT, universal_newlines=True)
|
|
||||||
|
|
||||||
assert v.find('dhcpcd -M') != -1
|
assert v.find('dhcpcd -M') != -1
|
||||||
|
|
||||||
@@ -78,21 +73,19 @@ def test_docker_tls_args(qemu, cloud_config):
|
|||||||
SSH(qemu, ssh_command).check_call('''
|
SSH(qemu, ssh_command).check_call('''
|
||||||
set -e -x
|
set -e -x
|
||||||
sudo ros tls gen
|
sudo ros tls gen
|
||||||
sleep 3
|
sleep 5
|
||||||
docker --tlsverify version
|
docker --tlsverify version
|
||||||
'''.strip())
|
'''.strip())
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.timeout(40)
|
@pytest.mark.timeout(40)
|
||||||
def test_rancher_network(qemu, cloud_config):
|
def test_rancher_network(qemu, cloud_config):
|
||||||
u.wait_for_ssh(qemu, ssh_command)
|
v = SSH(qemu, ssh_command).check_output('''
|
||||||
|
ip route get to 10.10.2.120
|
||||||
|
'''.strip())
|
||||||
|
|
||||||
v = subprocess.check_output(
|
assert v.split(' ')[5] + '/24' == \
|
||||||
ssh_command + ['ip', 'route', 'get', 'to', '10.10.2.120'],
|
cloud_config['rancher']['network']['interfaces']['mac=52:54:00:12:34:59']['address']
|
||||||
stderr=subprocess.STDOUT, universal_newlines=True)
|
|
||||||
|
|
||||||
assert v.split(' ')[2] == 'eth1'
|
|
||||||
assert v.split(' ')[5] + '/24' == cloud_config['rancher']['network']['interfaces']['eth1']['address']
|
|
||||||
|
|
||||||
|
|
||||||
def test_docker_not_pid_one(qemu):
|
def test_docker_not_pid_one(qemu):
|
||||||
|
@@ -1,7 +1,8 @@
|
|||||||
import subprocess
|
import time
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import rostest.util as u
|
import rostest.util as u
|
||||||
|
from rostest.util import SSH
|
||||||
|
|
||||||
ssh_command = ['./scripts/ssh', '--qemu', '--key', './tests/integration/assets/test.key']
|
ssh_command = ['./scripts/ssh', '--qemu', '--key', './tests/integration/assets/test.key']
|
||||||
cloud_config_path = './tests/integration/assets/test_03/cloud-config.yml'
|
cloud_config_path = './tests/integration/assets/test_03/cloud-config.yml'
|
||||||
@@ -19,15 +20,19 @@ nginx = {'amd64': 'nginx', 'arm': 'armhfbuild/nginx', 'arm64': 'armhfbuild/nginx
|
|||||||
|
|
||||||
@pytest.mark.timeout(40)
|
@pytest.mark.timeout(40)
|
||||||
def test_reboot_with_container_running(qemu):
|
def test_reboot_with_container_running(qemu):
|
||||||
u.wait_for_ssh(qemu, ssh_command)
|
try:
|
||||||
subprocess.check_call(ssh_command + ['docker', 'run', '-d', '--restart=always', nginx[u.arch]],
|
SSH(qemu, ssh_command).check_call('''
|
||||||
stderr=subprocess.STDOUT, universal_newlines=True)
|
set -ex
|
||||||
|
docker run -d --restart=always %(image)s
|
||||||
|
sudo reboot
|
||||||
|
'''.strip() % {'image': nginx[u.arch]})
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
subprocess.call(ssh_command + ['sudo', 'reboot'],
|
time.sleep(3)
|
||||||
stderr=subprocess.STDOUT, universal_newlines=True)
|
|
||||||
|
|
||||||
u.wait_for_ssh(qemu, ssh_command)
|
v = SSH(qemu, ssh_command).check_output('''
|
||||||
v = subprocess.check_output(ssh_command + ['docker', 'ps', '-f', 'status=running'],
|
docker ps -f status=running
|
||||||
stderr=subprocess.STDOUT, universal_newlines=True)
|
'''.strip())
|
||||||
|
|
||||||
assert v.find('nginx') != -1
|
assert v.find('nginx') != -1
|
||||||
|
@@ -2,20 +2,21 @@ import pytest
|
|||||||
import rostest.util as u
|
import rostest.util as u
|
||||||
from rostest.util import SSH
|
from rostest.util import SSH
|
||||||
|
|
||||||
|
pytestmark = pytest.mark.skipif(u.arch != 'amd64', reason='amd64 network setup impossible to replicate for arm64')
|
||||||
|
|
||||||
cloud_config_path = './tests/integration/assets/test_09/cloud-config.yml'
|
cloud_config_path = './tests/integration/assets/test_09/cloud-config.yml'
|
||||||
|
|
||||||
|
net_args_arch = {'amd64': ['-net', 'nic,vlan=0,model=virtio'],
|
||||||
|
'arm64': ['-device', 'virtio-net-device']}
|
||||||
|
net_args_arch['arm'] = net_args_arch['arm64']
|
||||||
|
net_args = net_args_arch[u.arch]
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="module")
|
@pytest.fixture(scope="module")
|
||||||
def qemu(request):
|
def qemu(request):
|
||||||
q = u.run_qemu(request, run_args=['--cloud-config', cloud_config_path,
|
q = u.run_qemu(request,
|
||||||
'-net', 'nic,vlan=0,model=virtio',
|
run_args=['--cloud-config', cloud_config_path] +
|
||||||
'-net', 'nic,vlan=0,model=virtio',
|
net_args + net_args + net_args + net_args + net_args + net_args + net_args)
|
||||||
'-net', 'nic,vlan=0,model=virtio',
|
|
||||||
'-net', 'nic,vlan=0,model=virtio',
|
|
||||||
'-net', 'nic,vlan=0,model=virtio',
|
|
||||||
'-net', 'nic,vlan=0,model=virtio',
|
|
||||||
'-net', 'nic,vlan=0,model=virtio'])
|
|
||||||
u.flush_out(q.stdout)
|
u.flush_out(q.stdout)
|
||||||
return q
|
return q
|
||||||
|
|
||||||
|
@@ -90,8 +90,8 @@ def wait_for_ssh(qemu, ssh_command=['./scripts/ssh', '--qemu'], command=['docker
|
|||||||
i += 1
|
i += 1
|
||||||
print('\nWaiting for ssh and docker... ' + str(i))
|
print('\nWaiting for ssh and docker... ' + str(i))
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
if i > 60:
|
if i > 150:
|
||||||
raise 'Failed to connect to SSH'
|
raise AssertionError('Failed to connect to SSH')
|
||||||
assert qemu.returncode is None
|
assert qemu.returncode is None
|
||||||
|
|
||||||
|
|
||||||
@@ -101,11 +101,19 @@ class SSH:
|
|||||||
self._ssh_command = ssh_command
|
self._ssh_command = ssh_command
|
||||||
self._waited = False
|
self._waited = False
|
||||||
|
|
||||||
def check_call(self, *args, **kw):
|
def wait(self):
|
||||||
if not self._waited:
|
if not self._waited:
|
||||||
wait_for_ssh(self._qemu, ssh_command=self._ssh_command)
|
wait_for_ssh(self._qemu, ssh_command=self._ssh_command)
|
||||||
self._waited = True
|
self._waited = True
|
||||||
|
|
||||||
|
def check_call(self, *args, **kw):
|
||||||
|
self.wait()
|
||||||
kw['stderr'] = subprocess.STDOUT
|
kw['stderr'] = subprocess.STDOUT
|
||||||
kw['universal_newlines'] = True
|
kw['universal_newlines'] = True
|
||||||
return subprocess.check_call(self._ssh_command + list(args), **kw)
|
return subprocess.check_call(self._ssh_command + list(args), **kw)
|
||||||
|
|
||||||
|
def check_output(self, *args, **kw):
|
||||||
|
self.wait()
|
||||||
|
kw['stderr'] = subprocess.STDOUT
|
||||||
|
kw['universal_newlines'] = True
|
||||||
|
return subprocess.check_output(self._ssh_command + list(args), **kw)
|
||||||
|
Reference in New Issue
Block a user