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