Esempio n. 1
0
 def test_build_links_all(self):
     """Should generate all links when nodes define connections"""
     data = chef.filter_nodes(self.nodes, 'production', virt_roles='guest')
     links = graphs._build_links(data)
     expected = {
         'testnode1': {'role_prefix': 'loadbalancer'},
         'testnode2': {
             'role_prefix': 'webserver',
             'client_nodes': [('testnode1', 'apache2')]
         },
         'testnode3.mydomain.com': {
             'role_prefix': 'dbserver',
             'client_nodes': [
                 ('testnode2', 'mysql'), ('testnode7', 'mysql')
             ]
         },
         'testnode7': {
             'role_prefix': 'webserver',
             'client_nodes': [('testnode1', 'apache2')]
         },
         'testnode8': {
             'role_prefix': 'worker',
             'needs_nodes': [
                 ('testnode3.mydomain.com', 'mysql')
             ]
         }
     }
     self.assertEqual(links, expected)
Esempio n. 2
0
 def test_build_links_all(self):
     """Should generate all links when nodes define connections"""
     data = chef.filter_nodes(
         self.nodes, 'production')
     links = graphs._build_links(data)
     expected = {
         'testnode2': {'client_nodes': [('testnode1', 'apache2')]},
         'testnode3.mydomain.com': {
             'client_nodes': [
                 ('testnode2', 'mysql'), ('testnode7', 'mysql')
             ]
         },
         'testnode5': {
             'client_nodes': [
                 ('testnode2', 'mysql'), ('testnode7', 'mysql')
             ]
         },
         'testnode7': {'client_nodes': [('testnode1', 'apache2')]},
         'testnode8': {
             'needs_nodes': [
                 ('testnode3.mydomain.com', 'mysql'), ('testnode5', 'mysql')
             ]
         }
     }
     self.assertEqual(links, expected)
Esempio n. 3
0
 def test_build_links_needs_nodes(self):
     """Should generate links when nodes have needs_nodes set"""
     data = chef.filter_nodes(self.nodes, "production", "dbserver,worker", "guest")
     links = graphs._build_links(data)
     expected = {
         "testnode3.mydomain.com": {"role_prefix": "dbserver"},
         "testnode8": {"role_prefix": "worker", "needs_nodes": [("testnode3.mydomain.com", "mysql")]},
     }
     self.assertEqual(links, expected)
Esempio n. 4
0
 def test_build_links_needs_nodes(self):
     """Should generate links when nodes have needs_nodes set"""
     data = chef.filter_nodes(
         self.nodes, 'production', 'dbserver,worker')
     links = graphs._build_links(data)
     expected = {
         'testnode8': {
             'needs_nodes': [
                 ('testnode3.mydomain.com', 'mysql'), ('testnode5', 'mysql')
             ]
         }
     }
     self.assertEqual(links, expected)
Esempio n. 5
0
 def test_build_links_all(self):
     """Should generate all links when nodes define connections"""
     data = chef.filter_nodes(self.nodes, "production", virt_roles="guest")
     links = graphs._build_links(data)
     expected = {
         "testnode1": {"role_prefix": "loadbalancer"},
         "testnode2": {"role_prefix": "webserver", "client_nodes": [("testnode1", "apache2")]},
         "testnode3.mydomain.com": {
             "role_prefix": "dbserver",
             "client_nodes": [("testnode2", "mysql"), ("testnode7", "mysql")],
         },
         "testnode7": {"role_prefix": "webserver", "client_nodes": [("testnode1", "apache2")]},
         "testnode8": {"role_prefix": "worker", "needs_nodes": [("testnode3.mydomain.com", "mysql")]},
     }
     self.assertEqual(links, expected)
Esempio n. 6
0
 def test_build_links_client_nodes(self):
     """Should generate links when nodes have client_nodes set"""
     data = chef.filter_nodes(self.nodes, "production", "loadbalancer,webserver,dbserver", "guest")
     links = graphs._build_links(data)
     self.maxDiff = None
     expected = {
         "testnode1": {"role_prefix": "loadbalancer"},
         "testnode2": {"role_prefix": "webserver", "client_nodes": [("testnode1", "apache2")]},
         "testnode3.mydomain.com": {
             "role_prefix": "dbserver",
             "client_nodes": [("testnode2", "mysql"), ("testnode7", "mysql")],
         },
         "testnode7": {"role_prefix": "webserver", "client_nodes": [("testnode1", "apache2")]},
     }
     self.assertEqual(links, expected)
Esempio n. 7
0
 def test_build_links_client_nodes(self):
     """Should generate links when nodes have client_nodes set"""
     data = chef.filter_nodes(
         self.nodes, 'production', 'loadbalancer,webserver,dbserver')
     links = graphs._build_links(data)
     self.maxDiff = None
     expected = {
         'testnode2': {'client_nodes': [('testnode1', 'apache2')]},
         'testnode3.mydomain.com': {
             'client_nodes': [
                 ('testnode2', 'mysql'), ('testnode7', 'mysql')
             ]
         },
         'testnode5': {
             'client_nodes': [
                 ('testnode2', 'mysql'), ('testnode7', 'mysql')
             ]
         },
         'testnode7': {'client_nodes': [('testnode1', 'apache2')]}
     }
     self.assertEqual(links, expected)
Esempio n. 8
0
 def test_build_links_empty(self):
     """Should not generate links when nodes do not have any defined"""
     data = chef.filter_nodes(self.nodes, 'staging', virt_roles='guest')
     links = graphs._build_links(data)
     expected = {'testnode4': {'role_prefix': 'webserver'}}
     self.assertEqual(links, expected)
Esempio n. 9
0
 def test_build_links_empty(self):
     """Should not generate links when nodes do not have any defined"""
     data = chef.filter_nodes(self.nodes, "staging", virt_roles="guest")
     links = graphs._build_links(data)
     expected = {"testnode4": {"role_prefix": "webserver"}}
     self.assertEqual(links, expected)
Esempio n. 10
0
 def test_build_links_empty(self):
     """Should not generate links when nodes do not have any defined"""
     data = chef.filter_nodes(self.nodes, 'staging', virt_roles='guest')
     links = graphs._build_links(data)
     self.assertEqual(links, {})