Browse Source

tests for merging with existing ini files

Sean Dague 2 years ago
parent
commit
edd7cc1bcc
1 changed files with 45 additions and 0 deletions
  1. 45
    0
      devstack/tests/test_localconf_extract.py

+ 45
- 0
devstack/tests/test_localconf_extract.py View File

@@ -44,6 +44,25 @@ NEUTRON = """[DEFAULT]
44 44
 global_physnet_mtu = 1450
45 45
 """
46 46
 
47
+NEUTRON_BASE = """[DEFAULT]
48
+api_workers = 2
49
+"""
50
+
51
+NEUTRON_BASE_RES = """[DEFAULT]
52
+global_physnet_mtu = 1450
53
+api_workers = 2
54
+"""
55
+
56
+NEUTRON_BASE2 = """[DEFAULT]
57
+api_workers = 2
58
+global_physnet_mtu = 1400
59
+"""
60
+
61
+NEUTRON_BASE2_RES = """[DEFAULT]
62
+api_workers = 2
63
+global_physnet_mtu = 1450
64
+"""
65
+
47 66
 
48 67
 class TestLcExtract(testtools.TestCase):
49 68
 
@@ -69,3 +88,29 @@ class TestLcExtract(testtools.TestCase):
69 88
         with open(nova) as f:
70 89
             content = f.read()
71 90
             self.assertEqual(content, NOVA)
91
+
92
+    def test_extract_neutron_merge_add(self):
93
+        dirname = self.useFixture(fixtures.TempDir()).path
94
+        neutron = os.path.join(dirname, "neutron.conf")
95
+        with open(neutron, "w+") as f:
96
+            f.write(NEUTRON_BASE)
97
+
98
+        conf = dsconf.LocalConf(self._path)
99
+        conf.extract("post-config", "$NEUTRON_CONF", neutron)
100
+
101
+        with open(neutron) as f:
102
+            content = f.read()
103
+            self.assertEqual(content, NEUTRON_BASE_RES)
104
+
105
+    def test_extract_neutron_merge_set(self):
106
+        dirname = self.useFixture(fixtures.TempDir()).path
107
+        neutron = os.path.join(dirname, "neutron.conf")
108
+        with open(neutron, "w+") as f:
109
+            f.write(NEUTRON_BASE2)
110
+
111
+        conf = dsconf.LocalConf(self._path)
112
+        conf.extract("post-config", "$NEUTRON_CONF", neutron)
113
+
114
+        with open(neutron) as f:
115
+            content = f.read()
116
+            self.assertEqual(content, NEUTRON_BASE2_RES)

Loading…
Cancel
Save