Browse code

Allow plugin names to contain non-letter characters

There are already devstack plugins that contain a hyphen in the name,
like `networking-baremetal`. In order to allow ordering for these to
work properly, amend the regexes we are using to match any
non-whitespace characters instead of only alphanumerics.

Amend the test to cover this use case.

Change-Id: I91093a424f8d5e8007f140083e1ea36a81fe849f
Closes-Bug: 1809016

Jens Harbott authored on 2018/12/19 21:20:51
Showing 2 changed files
... ...
@@ -155,8 +155,8 @@ class PluginGraph(DependencyGraph):
155 155
                 continue
156 156
             self.loadDevstackPluginInfo(settings)
157 157
 
158
-    define_re = re.compile(r'^define_plugin\s+(\w+).*')
159
-    require_re = re.compile(r'^plugin_requires\s+(\w+)\s+(\w+).*')
158
+    define_re = re.compile(r'^define_plugin\s+(\S+).*')
159
+    require_re = re.compile(r'^plugin_requires\s+(\S+)\s+(\S+).*')
160 160
     def loadDevstackPluginInfo(self, fn):
161 161
         name = None
162 162
         reqs = set()
... ...
@@ -78,12 +78,12 @@ class TestDevstackLocalConf(unittest.TestCase):
78 78
         with open(os.path.join(
79 79
                 self.tmpdir,
80 80
                 'foo-plugin', 'devstack', 'settings'), 'w') as f:
81
-            f.write('define_plugin foo\n')
81
+            f.write('define_plugin foo-plugin\n')
82 82
         with open(os.path.join(
83 83
                 self.tmpdir,
84 84
                 'bar-plugin', 'devstack', 'settings'), 'w') as f:
85
-            f.write('define_plugin bar\n')
86
-            f.write('plugin_requires bar foo\n')
85
+            f.write('define_plugin bar-plugin\n')
86
+            f.write('plugin_requires bar-plugin foo-plugin\n')
87 87
 
88 88
         localrc = {'test_localrc': '1'}
89 89
         local_conf = {'install':
... ...
@@ -94,8 +94,8 @@ class TestDevstackLocalConf(unittest.TestCase):
94 94
         # We use ordereddict here to make sure the plugins are in the
95 95
         # *wrong* order for testing.
96 96
         plugins = OrderedDict([
97
-            ('bar', 'git://git.openstack.org/openstack/bar-plugin'),
98
-            ('foo', 'git://git.openstack.org/openstack/foo-plugin'),
97
+            ('bar-plugin', 'git://git.openstack.org/openstack/bar-plugin'),
98
+            ('foo-plugin', 'git://git.openstack.org/openstack/foo-plugin'),
99 99
             ])
100 100
         p = dict(localrc=localrc,
101 101
                  local_conf=local_conf,
... ...
@@ -119,7 +119,7 @@ class TestDevstackLocalConf(unittest.TestCase):
119 119
             for line in f:
120 120
                 if line.startswith('enable_plugin'):
121 121
                     plugins.append(line.split()[1])
122
-        self.assertEqual(['foo', 'bar'], plugins)
122
+        self.assertEqual(['foo-plugin', 'bar-plugin'], plugins)
123 123
 
124 124
     def test_libs_from_git(self):
125 125
         "Test that LIBS_FROM_GIT is auto-generated"