def test_04(self): for p in posts.ALL: r = requests.post(self.api_discovery, data=json.dumps(p)) self.assertEqual(r.status_code, 200) r.close() sch_no = schedulerv2.KubernetesNode(EC.api_uri, True) self.assertEqual( len(posts.ALL) - schedulerv2.EtcdMemberKubernetesControlPlane.expected_nb, sch_no.apply()) s = sync.ConfigSyncSchedules( EC.api_uri, self.test_matchbox_path, ignition_dict={ "etcd_member_kubernetes_control_plane": "inte-testapigunicornscheduler-etcd-k8s-cp", "kubernetes_nodes": "inte-testapigunicornscheduler-etcd-k8s-cp", }, extra_selector_dict={"os": "installed"}, ) s.apply()
def test_03(self): s = sync.ConfigSyncSchedules( api_uri=self.api_uri, matchbox_path=self.test_matchbox_path, ignition_dict={}, extra_selector_dict=None, ) d = s.cni_ipam("172.20.0.10/19", "172.20.0.1") self.assertEqual( json.dumps( { "dataDir": "/var/lib/cni/networks", 'gateway': '172.20.0.1', 'rangeStart': '172.20.10.1', 'rangeEnd': '172.20.10.254', 'routes': [ { "dst": "172.31.255.255/32", "gw": "172.20.0.10" }, { 'dst': '0.0.0.0/0' }, ], 'subnet': '172.20.0.0/19', 'type': 'host-local' }, indent=2, sort_keys=True), json.dumps(d, indent=2, sort_keys=True))
def test_03(self): r = requests.post(self.api_discovery, data=json.dumps(posts.M01)) r.close() self.assertEqual(r.status_code, 200) sch = schedulerv2.EtcdMemberKubernetesControlPlane(EC.api_uri) self.assertFalse(sch.apply()) self.assertFalse(sch.apply()) r = requests.post(self.api_discovery, data=json.dumps(posts.M02)) r.close() self.assertFalse(sch.apply()) r = requests.post(self.api_discovery, data=json.dumps(posts.M03)) r.close() self.assertTrue(sch.apply()) sch_no = schedulerv2.KubernetesNode(EC.api_uri, True) self.assertEqual(0, sch_no.apply()) r = requests.post(self.api_discovery, data=json.dumps(posts.M04)) r.close() self.assertEqual(1, sch_no.apply()) s = sync.ConfigSyncSchedules( EC.api_uri, self.test_matchbox_path, ignition_dict={ "etcd_member_kubernetes_control_plane": "inte-testapigunicornscheduler-etcd-k8s-cp", "kubernetes_nodes": "inte-testapigunicornscheduler-etcd-k8s-cp", }, ) s.apply()
def test_05(self): with self.assertRaises(IOError): sync.ConfigSyncSchedules( api_uri=self.api_uri, matchbox_path=self.test_matchbox_path, ignition_dict={"etcd-member": "no-here"}, extra_selector_dict=None, )
def test_02(self): s = sync.ConfigSyncSchedules( api_uri=self.api_uri, matchbox_path=self.test_matchbox_path, ignition_dict={}, extra_selector_dict=None, ) d = s.get_dns_attr("kubernetes-control-plane-0") self.assertEqual( { 'dc': '', 'domain': '', 'pos': '', 'rack': '', 'shortname': 'kubernetes-control-plane-0' }, d)
def test_01(self): s = sync.ConfigSyncSchedules( api_uri=self.api_uri, matchbox_path=self.test_matchbox_path, ignition_dict={}, extra_selector_dict=None, ) d = s.get_dns_attr("r13srv3.dc-1.foo.bar.cr") self.assertEqual( { 'dc': 'dc-1', 'shortname': 'r13srv3', "rack": "", "pos": "", "domain": "dc-1.foo.bar.cr" }, d)
def test_04_1(self): s = sync.ConfigSyncSchedules( api_uri=self.api_uri, matchbox_path=self.test_matchbox_path, ignition_dict={}, extra_selector_dict=None, ) sync.ConfigSyncSchedules.range_nb_ips = 60 sync.ConfigSyncSchedules.skip_ips = 1 sync.ConfigSyncSchedules.sub_ips = 0 d = s.cni_ipam("10.99.39.129/19", "10.99.64.254") self.assertEqual( json.dumps( { "dataDir": "/var/lib/cni/networks", "type": "host-local", "subnet": "10.99.32.0/19", "rangeStart": "10.99.39.130", "rangeEnd": "10.99.39.190", "gateway": "10.99.64.254", "routes": [ { "dst": "172.31.255.255/32", "gw": "10.99.39.129" }, { "dst": "0.0.0.0/0" }, ] }, indent=2, sort_keys=True), json.dumps(d, indent=2, sort_keys=True))