]> git.proxmox.com Git - ceph.git/blame - ceph/src/cephadm/tests/test_cephadm.py
d/control: depend on python3-yaml for ceph-mgr
[ceph.git] / ceph / src / cephadm / tests / test_cephadm.py
CommitLineData
9f95a23c
TL
1import argparse
2import mock
3import os
4import sys
5import unittest
6
7import pytest
8
9if sys.version_info >= (3, 3):
10 from importlib.machinery import SourceFileLoader
11 cd = SourceFileLoader('cephadm', 'cephadm').load_module()
12else:
13 import imp
14 cd = imp.load_source('cephadm', 'cephadm')
15
16class TestCephAdm(object):
17 def test_is_fsid(self):
18 assert not cd.is_fsid('no-uuid')
19
20 def test__get_parser_image(self):
21 args = cd._parse_args(['--image', 'foo', 'version'])
22 assert args.image == 'foo'
23
24 def test_CustomValidation(self):
25 assert cd._parse_args(['deploy', '--name', 'mon.a', '--fsid', 'fsid'])
26
27 with pytest.raises(SystemExit):
28 cd._parse_args(['deploy', '--name', 'wrong', '--fsid', 'fsid'])
29
30 @pytest.mark.parametrize("test_input, expected", [
31 ("podman version 1.6.2", (1,6,2)),
32 ("podman version 1.6.2-stable2", (1,6,2)),
33 ])
34 def test_parse_podman_version(self, test_input, expected):
35 assert cd._parse_podman_version(test_input) == expected
36
37 def test_parse_podman_version_invalid(self):
38 with pytest.raises(ValueError) as res:
39 cd._parse_podman_version('podman version inval.id')
40 assert 'inval' in str(res.value)
41
42 @pytest.mark.parametrize("test_input, expected", [
43 (
44"""
45default via 192.168.178.1 dev enxd89ef3f34260 proto dhcp metric 100
4610.0.0.0/8 via 10.4.0.1 dev tun0 proto static metric 50
4710.3.0.0/21 via 10.4.0.1 dev tun0 proto static metric 50
4810.4.0.1 dev tun0 proto kernel scope link src 10.4.0.2 metric 50
49137.1.0.0/16 via 10.4.0.1 dev tun0 proto static metric 50
50138.1.0.0/16 via 10.4.0.1 dev tun0 proto static metric 50
51139.1.0.0/16 via 10.4.0.1 dev tun0 proto static metric 50
52140.1.0.0/17 via 10.4.0.1 dev tun0 proto static metric 50
53141.1.0.0/16 via 10.4.0.1 dev tun0 proto static metric 50
54169.254.0.0/16 dev docker0 scope link metric 1000
55172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1
56192.168.39.0/24 dev virbr1 proto kernel scope link src 192.168.39.1 linkdown
57192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 linkdown
58192.168.178.0/24 dev enxd89ef3f34260 proto kernel scope link src 192.168.178.28 metric 100
59192.168.178.1 dev enxd89ef3f34260 proto static scope link metric 100
60195.135.221.12 via 192.168.178.1 dev enxd89ef3f34260 proto static metric 100
61""",
62 {
63 '10.4.0.1': ['10.4.0.2'],
64 '172.17.0.0/16': ['172.17.0.1'],
65 '192.168.39.0/24': ['192.168.39.1'],
66 '192.168.122.0/24': ['192.168.122.1'],
67 '192.168.178.0/24': ['192.168.178.28']
68 }
69 ), (
70"""
71default via 10.3.64.1 dev eno1 proto static metric 100
7210.3.64.0/24 dev eno1 proto kernel scope link src 10.3.64.23 metric 100
7310.3.64.0/24 dev eno1 proto kernel scope link src 10.3.64.27 metric 100
7410.88.0.0/16 dev cni-podman0 proto kernel scope link src 10.88.0.1 linkdown
75172.21.0.0/20 via 172.21.3.189 dev tun0
76172.21.1.0/20 via 172.21.3.189 dev tun0
77172.21.2.1 via 172.21.3.189 dev tun0
78172.21.3.1 dev tun0 proto kernel scope link src 172.21.3.2
79172.21.4.0/24 via 172.21.3.1 dev tun0
80172.21.5.0/24 via 172.21.3.1 dev tun0
81172.21.6.0/24 via 172.21.3.1 dev tun0
82172.21.7.0/24 via 172.21.3.1 dev tun0
83192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 linkdown
84""",
85 {
86 '10.3.64.0/24': ['10.3.64.23', '10.3.64.27'],
87 '10.88.0.0/16': ['10.88.0.1'],
88 '172.21.3.1': ['172.21.3.2'],
89 '192.168.122.0/24': ['192.168.122.1']}
90 ),
91 ])
92 def test_parse_ip_route(self, test_input, expected):
93 assert cd._parse_ip_route(test_input) == expected