Procházet zdrojové kódy

HUE-6077 [editor] Add more test coverage on false positive hints

Romain Rigaux před 8 roky
rodič
revize
1a84794

+ 0 - 1
desktop/core/src/desktop/templates/hue.mako

@@ -813,7 +813,6 @@ ${ smart_unicode(login_modal(request).content) | n,unicode }
           { url: '/security/solr', app: 'security_solr' },
           { url: '/sqoop', app: 'sqoop' },
           { url: '/useradmin/configurations/', app: 'useradmin_configurations' },
-          { url: '/useradmin/groups', app: 'useradmin_groups' },
           { url: '/useradmin/groups/', app: 'useradmin_groups' },
           { url: '/useradmin/groups/new', app: 'useradmin_newgroup' },
           { url: '/useradmin/groups/edit/:group', app: 'useradmin_editgroup' },

+ 18 - 8
desktop/libs/metadata/src/metadata/optimizer_client_tests.py

@@ -187,9 +187,9 @@ PARTITIONED BY (
     resp = self.api.query_risk(query=query, source_platform='hive', db_name='default')
 
     assert_true(len(resp) > 0, resp)
-    assert_true('riskAnalysis' in resp[0], resp)
-    assert_true('risk' in resp[0], resp)
-    assert_true('riskRecommendation' in resp[0], resp)
+    assert_true('riskAnalysis' in resp['hints'][0], resp)
+    assert_true('risk' in resp['hints'][0], resp)
+    assert_true('riskRecommendation' in resp['hints'][0], resp)
 
 
   def test_query_compatibility(self):
@@ -206,13 +206,13 @@ PARTITIONED BY (
 
 
   def test_top_filters(self):  # Requires test_upload to run before
-    resp = self.api.top_filters(db_tables='db1.Part')
+    resp = self.api.top_filters(db_tables=['db1.Part'])
 
     assert_true(len(resp['results']) > 0, resp)
 
 
   def test_top_joins(self):
-    resp = self.api.top_joins(db_tables='db1.Part')
+    resp = self.api.top_joins(db_tables=['db1.Part'])
 
     assert_true(len(resp['results']) > 0, resp)
 
@@ -225,7 +225,7 @@ PARTITIONED BY (
 
 
   def test_top_aggs(self):
-    resp = self.api.top_aggs(db_tables='db1.Part')
+    resp = self.api.top_aggs(db_tables=['db1.Part'])
 
     assert_true(len(resp['results']) > 0, resp)
 
@@ -238,7 +238,7 @@ PARTITIONED BY (
 
 
   def test_top_columns(self):
-    resp = self.api.top_columns(db_tables='db1.Part')
+    resp = self.api.top_columns(db_tables=['db1.Part'])
 
     assert_true('orderbyColumns' in resp, resp)
     assert_true('selectColumns' in resp, resp)
@@ -405,7 +405,6 @@ WHERE
  AND s07.salary > 100000 )
 ORDER BY s07.salary DESC
 LIMIT 1000
-
 '''
 
     resp = self.api.query_risk(query=query, source_platform=source_platform, db_name='default')
@@ -455,6 +454,17 @@ LIMIT 1000
     _assert_risks(['Query on partitioned table is missing filters on partioning columns.'], resp['hints'], present=False)
 
 
+  def test_risk_listing_all_risk_tables_all_the_time(self):
+    source_platform = 'hive'
+    query = '''SELECT * FROM web_logs JOIN a ON web_logs.id = a.id LIMIT 100'''
+    db_name = 'default'
+
+    resp = self.api.query_risk(query=query, source_platform=source_platform, db_name=db_name)
+    _assert_risks(['Query on partitioned table is missing filters on partioning columns.'], resp['hints'])
+
+    assert_true('default.web_logs' in [suggestion for suggestion in resp['hints'] if suggestion['riskId'] == 22][0]['riskTables'])
+
+
 def _assert_risks(risks, suggestions, present=True):
   suggestion_names = [suggestion['riskAnalysis'] for suggestion in suggestions]