Przeglądaj źródła

HUE-8758 [editor] Add install samples test via load with hive

Romain 5 lat temu
rodzic
commit
0d82c87b8e

+ 1 - 2
apps/beeswax/src/beeswax/management/commands/beeswax_install_examples.py

@@ -174,8 +174,7 @@ class SampleTable(object):
 
   def install(self, django_user):
     if not (has_concurrency_support() and self.is_transactional) and not cluster.get_hdfs():
-      LOG.warn('Skipping table %s as requiring a File System to load its data' % self.name)
-      return
+      raise PopupException('Requiring a File System to load its data')
 
     self.create(django_user)
 

+ 47 - 2
desktop/libs/notebook/src/notebook/views_tests.py

@@ -64,7 +64,6 @@ class TestInstallExamples():
                 'type': 10,
                 'dialect': 'mysql',
                 'interface': 'sqlalchemy',
-                'options': {'url': 'mysql://hue:pwd@hue:3306/hue'},
               }
             ]
 
@@ -83,7 +82,53 @@ class TestInstallExamples():
 
 
   def test_install_via_load_hive(self):
-    pass
+    with patch('notebook.views.Connector.objects') as ConnectorObjects:
+      with patch('notebook.views.get_interpreter') as get_interpreter:
+        with patch('notebook.connectors.base.get_ordered_interpreters') as get_ordered_interpreters:
+          with patch('beeswax.management.commands.beeswax_install_examples.make_notebook') as make_notebook:
+            with patch('beeswax.management.commands.beeswax_install_examples.has_concurrency_support') as has_concurrency_support:
+              with patch('beeswax.management.commands.beeswax_install_examples.cluster.get_hdfs') as get_hdfs:
+
+                ConnectorObjects.get = Mock(
+                  return_value=Connector(
+                    id=10,
+                    name='MyHive',
+                    dialect='hive',
+                  ),
+                )
+
+                get_interpreter.return_value = {'type': 10, 'dialect': 'hive'}
+                get_ordered_interpreters.return_value = [
+                  {
+                    'name': 'MyHive',
+                    'type': 10,
+                    'dialect': 'hive',
+                    'interface': 'hiveserver',
+                  }
+                ]
+
+                has_concurrency_support.return_value = False
+
+                resp = self.client.post(reverse('notebook:install_examples'), {'db_name': 'default'})
+                data = json.loads(resp.content)
+
+                assert_equal(0, data['status'], data)
+                assert_equal(
+                    'Query Sample: Top salary hive installed. '
+                    'Query Sample: Salary growth hive installed. '
+                    'Query Sample: Job loss hive installed. '
+                    'Query Sample: Customers hive installed. '
+                    'Table default.sample_07 installed. '
+                    'Table default.sample_08 installed. '
+                    'Table default.customers installed. '
+                    'Table default.web_logs installed.',
+                    data['message'],
+                    data
+                )
+                assert_equal('', data['errorMessage'], data)
+
+                make_notebook.assert_called()
+
 
   def test_install_via_insert_hive(self):
     pass