Example #1
0
    def test_properties(self):
        h = get_hostname(self.hostname_str)

        self.assertEqual(h.ip, self.ip)
        self.assertEqual(h.hostname, self.hostname)
        self.assertEqual(h.namespace, self.namespace)
        self.assertEqual(h.domain, self.domain)
        self.assertEqual(h.fqdn, self.hostname_str)
Example #2
0
    def test_is_master(self):
        for pod in self.pods:
            h = get_hostname(pod)
            index = int(pod.metadata.name.split('-')[1])

            if index == 0:
                self.assertTrue(h.is_master)
            else:
                self.assertFalse(h.is_master)
Example #3
0
    def test_sort(self):
        hosts = [
            get_hostname('172-17-0-%d.default.pod.cluster.local' % i)
            for i in range(3, 0, -1)
        ]

        self.assertFalse(str(hosts[0]) < str(hosts[1]) < str(hosts[2]))

        hosts = sorted(hosts)
        self.assertTrue(str(hosts[0]) < str(hosts[1]) < str(hosts[2]))
Example #4
0
 def setUp(self):
     self.index = 0
     self.statefulset = 'couchdb'
     self.hostname = '%s-%d' % (self.statefulset, self.index)
     self.subdomain = 'couchdb'
     self.namespace = 'default'
     self.domain = 'cluster.local'
     self.hostname_str = '%s.%s.%s.svc.%s' % (self.hostname, self.subdomain,
                                              self.namespace, self.domain)
     self.host = get_hostname(self.hostname_str)
Example #5
0
    def test_string_conversion(self):
        for pod in self.pods:
            h = get_hostname(pod)
            index = int(pod.metadata.name.split('-')[1])

            fqdn = '%s-%d.%s.%s.svc.%s' % (self.statefulset, index,
                                           self.subdomain, self.namespace,
                                           self.domain)

            self.assertEqual(type(str(h)), str)
            self.assertEqual(str(h), fqdn)
Example #6
0
    def test_clone(self):
        for pod in self.pods:
            h1 = get_hostname(pod)

            h2 = h1.clone()
            self.assertEqual(repr(h1), repr(h2))
            self.assertEqual(str(h1), str(h2))

            h3 = h1.clone(index=1)
            self.assertEqual(h3.index, 1)
            h4 = h3.clone(master=True)
            self.assertEqual(h4.index, 0)
Example #7
0
    def test_properties(self):
        for pod in self.pods:
            h = get_hostname(pod)
            ip = pod.status.podIP
            index = int(pod.metadata.name.split('-')[1])
            hostname = '%s-%d' % (self.statefulset, index)

            fqdn = '%s-%d.%s.%s.svc.%s' % (self.statefulset, index,
                                           self.subdomain, self.namespace,
                                           self.domain)
            self.assertEqual(h.ip, ip)
            self.assertEqual(h.index, index)
            self.assertEqual(h.statefulset, self.statefulset)
            self.assertEqual(h.hostname, hostname)
            self.assertEqual(h.subdomain, self.subdomain)
            self.assertEqual(h.namespace, self.namespace)
            self.assertEqual(h.domain, self.domain)
            self.assertEqual(h.fqdn, fqdn)
Example #8
0
 def test_clone(self):
     h1 = get_hostname(self.hostname_str)
     h2 = h1.clone()
     self.assertEqual(repr(h1), repr(h2))
     self.assertEqual(str(h1), str(h2))
Example #9
0
    def test_string_conversion(self):
        h = get_hostname(self.hostname_str)

        self.assertEqual(type(str(h)), str)
        self.assertEqual(str(h), self.hostname_str)
Example #10
0
 def test_create(self):
     h = get_hostname(self.hostname_str)
     self.assertTrue(repr(h))
     self.assertEqual(type(h), PodHostname)
Example #11
0
 def test_create(self):
     for pod in self.pods:
         h = get_hostname(pod)
         self.assertTrue(repr(h))
         self.assertEqual(type(h), StatefulPodHostname)