incubator-hcatalog-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r1365722 [5/11] - in /incubator/hcatalog/trunk: ./ ant/ conf/ hcatalog-pig-adapter/ ivy/ src/docs/src/documentation/content/xdocs/ src/docs/src/documentation/content/xdocs/images/ src/java/org/apache/hcatalog/mapreduce/ src/test/e2e/templet...
Date Wed, 25 Jul 2012 20:29:49 GMT
Added: incubator/hcatalog/trunk/src/test/e2e/templeton/tests/ddl.conf
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/src/test/e2e/templeton/tests/ddl.conf?rev=1365722&view=auto
==============================================================================
--- incubator/hcatalog/trunk/src/test/e2e/templeton/tests/ddl.conf (added)
+++ incubator/hcatalog/trunk/src/test/e2e/templeton/tests/ddl.conf Wed Jul 25 20:29:44 2012
@@ -0,0 +1,1110 @@
+###############################################################################
+# curl command tests for templeton
+#
+#
+
+#use Yahoo::Miners::Test::PigSetup;
+
+#PigSetup::setup();
+
+#my $me = `whoami`;
+#chomp $me;
+
+$cfg = 
+{
+ 'driver' => 'Curl',
+
+ 'groups' => 
+ [
+##=============================================================================================================
+  {
+   'name' => 'Hcat_table',
+   'tests' => 
+   [
+    {
+                                #drop table if exists
+     'num' => 1,
+     'method' => 'POST',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl',
+     'status_code' => 200,
+     'post_options' => ['user.name=:UNAME:','exec=drop table if exists templetontest_tab2'],
+     'json_field_substr_match' => {'stderr' => 'OK'},
+
+    },
+    {
+                                #create table
+     'num' => 2,
+     'method' => 'POST',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl',
+     'status_code' => 200,
+     'post_options' => ['user.name=:UNAME:','exec=create table templetontest_tab2(i int,
j bigint) STORED AS rcfile;'],
+     'json_field_substr_match' => {'stderr' => 'OK', 'exitcode' => '^0$'}
+    },
+    {
+                                #show tables
+     'num' => 3,
+     'method' => 'POST',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl',
+     'status_code' => 200,
+     'post_options' => ['user.name=:UNAME:','exec=show tables;'],
+     'json_field_substr_match' => {'stderr' => 'OK', 'stdout' => 'templetontest_tab2',
'exitcode' => '^0$'}
+    },
+    {
+                                #create table again, should fail
+     'num' => 4,
+     'method' => 'POST',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl',
+     'status_code' => 200,
+     'post_options' => ['user.name=:UNAME:','exec=create table templetontest_tab2(i int,
j bigint) STORED AS rcfile;'],
+     'json_field_substr_match' => { 'exitcode' => '^9$'}
+    },
+    {
+                                #describe table
+     'num' => 5,
+     'method' => 'POST',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl',
+     'status_code' => 200,
+     'post_options' => ['user.name=:UNAME:','exec=describe templetontest_tab2;'],
+     'json_field_substr_match' => { 'stdout' => '.*i\s+int.*\n.*j.*bigint.*', 'exitcode'
=> '^0$', 'stderr' => 'OK'}
+    },
+    {
+                                #alter table - file format
+     'num' => 6,
+     'method' => 'POST',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl',
+     'status_code' => 200,
+     'post_options' => ['user.name=:UNAME:','exec=alter table templetontest_tab2 SET FILEFORMAT
rcfile;'],
+     'json_field_substr_match' => { 'exitcode' => '^0$', 'stderr' => 'OK'}
+    },
+    {
+                                #alter table - add column
+     'num' => 7,
+     'method' => 'POST',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl',
+     'status_code' => 200,
+     'post_options' => ['user.name=:UNAME:','exec=alter table templetontest_tab2 add columns(newcolx
int);'],
+     'json_field_substr_match' => { 'exitcode' => '^0$', 'stderr' => 'OK'}
+    },
+    {
+                                #describe table
+     'num' => 8,
+     'method' => 'POST',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl',
+     'status_code' => 200,
+     'post_options' => ['user.name=:UNAME:','exec=describe templetontest_tab2;'],
+     'json_field_substr_match' => { 'stdout' => '.*newcolx\s+int.*', 'exitcode' =>
'^0$', 'stderr' => 'OK'}
+    },
+   ]
+  },
+##=============================================================================================================
+  {
+   'name' => 'REST_DDL_DB',
+   'tests' => 
+   [
+    {
+                                #cleanup 
+                                #drop database if exists
+     'num' => 1,
+     'method' => 'POST',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl',
+     'status_code' => 200,
+     'post_options' => ['user.name=:UNAME:','exec=drop database if exists templeton_testempty_db'],
+     'json_field_substr_match' => {'stderr' => 'OK'},
+    },
+    {
+                                #create db
+     'num' => 2,
+     'method' => 'PUT',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/templeton_testempty_db?user.name=:UNAME:',
+     'status_code' => 200,
+     'format_header' => 'Content-Type: application/json',
+     'post_options' => ['{"comment":"Hello there", "location":"", "properties":{"a":"b"}}']
  
+    },
+    {
+                                #negative test - create same db again 
+     'ignore' => 'does not return corect status code',
+     'num' => 3,
+     'method' => 'PUT',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/templeton_testempty_db?user.name=:UNAME:',
+     'status_code' => 409,
+     'format_header' => 'Content-Type: application/json',
+     'post_options' => ['{"comment":"Hello there", "location":"", "properties":{"a":"b"}}']
  
+    },
+    {                           #show databases
+     'num' => 4,
+     'method' => 'GET',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/?user.name=:UNAME:',
+     'status_code' => 200,
+     'format_header' => 'Content-Type: application/json',
+     'json_field_substr_match' => {'databases' => 'templeton_testempty_db'},
+    },
+    {                           #show databases w like
+     'num' => 5,
+     'method' => 'GET',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/?like=*empty*&user.name=:UNAME:',
+     'status_code' => 200,
+     'json_field_substr_match' => {'databases' => 'templeton_testempty_db'},
+    },
+
+    {                           #desc db
+     'num' => 6,
+     'method' => 'GET',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/templeton_testempty_db?user.name=:UNAME:',
+     'status_code' => 200,
+     'json_field_substr_match' => {'database' => 'templeton_testempty_db', 'location'
=> 'templeton_testempty_db'},
+    },
+    {                           #drop db
+     'num' => 7,
+     'method' => 'DELETE',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/templeton_testempty_db?user.name=:UNAME:',
+     'status_code' => 200,
+    },
+    {
+                                #-ve test , describe on non existent db
+     'num' => 8,
+     'ignore' => 'ignore waiting for bugfix',
+     'method' => 'GET',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/test_no_such_db?user.name=:UNAME:',
+     'status_code' => 404,
+     'json_field_substr_match' => {'error' => 'No such database'},
+    },
+   ]
+  },
+##=============================================================================================================
+  {
+   'name' => 'REST_DDL_TABLE_BASIC',
+   'tests' => 
+   [
+    {
+                                #setup
+                                #create db if not exists
+     'num' => 1,
+     'method' => 'POST',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl',
+     'status_code' => 200,
+     'post_options' => ['user.name=:UNAME:','exec=create database if not exists templeton_testdb1;'],
+     'json_field_substr_match' => {'stderr' => 'OK'},
+    },
+  		  
+    {
+                                #cleanup 
+                                #drop table if exists
+     'num' => 2,
+     'method' => 'DELETE',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/templeton_testdb1/table/templeton_testtab1?user.name=:UNAME:&ifExists=true',
+     'status_code' => 200,
+     'json_field_substr_match' => {'database' => 'templeton_testdb1',  'table' =>
'templeton_testtab1'},
+    },
+    {
+                                #setup
+                                #create table if not exists
+     'ignore' => 'rest api now available',
+     'num' => 3,
+     'method' => 'POST',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl',
+     'status_code' => 200,
+     'post_options' => ['user.name=:UNAME:','exec=use templeton_testdb1; create table
if not exists templeton_testtab1 (i int, j bigint) STORED AS rcfile;'],
+     'json_field_substr_match' => {'stderr' => 'OK'},
+    },
+
+    {
+                                #create table
+     'num' => 4,
+     'method' => 'PUT',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/templeton_testdb1/table/templeton_testtab1?user.name=:UNAME:',
+     'format_header' => 'Content-Type: application/json',
+     'post_options' => ['{
+    	       "external" : "true", "ifNotExists": "true",
+              "columns": [
+                      { "name" : "i", "type" : "int" },
+                      { "name" : "j", "type" : "bigint", "comment" : "some comment" }
+              ], 
+              "location" : "/tmp/tab1",
+  	          "format" : {  "storedAs" : "rcfile"} 
+          }'],
+     'status_code' => 200,
+     'json_field_substr_match' => {'database' => 'templeton_testdb1',  'table' =>
'templeton_testtab1'},
+
+    },
+    {
+                                #negative test - create same table again 
+     'ignore' => 'currently returns success, needs to be fixed',
+     'num' => 5,
+     'method' => 'PUT',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/templeton_testdb1/table/templeton_testtab1?user.name=:UNAME:',
+     'format_header' => 'Content-Type: application/json',
+     'post_options' => ['{
+    	       "external" : "true", "ifNotExists": "true",
+              "columns": [
+                      { "name" : "i", "type" : "int" },
+                      { "name" : "j", "type" : "bigint", "comment" : "some comment" }
+              ], 
+              "location" : "/tmp/tab1",
+  	          "format" : {  "storedAs" : "rcfile"} 
+          }'],
+
+     'status_code' => 409,
+    },
+    {                           #show tables
+     'num' => 6,
+     'method' => 'GET',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/templeton_testdb1/table/?user.name=:UNAME:',
+     'status_code' => 200,
+     'json_field_substr_match' => {'tables' => 'templeton_testtab1'},
+    },
+    {                           #show tables like '%table1%'
+     'num' => 7,
+     'method' => 'GET',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/templeton_testdb1/table/?user.name=:UNAME:&like=*testtab1*',
+     'status_code' => 200,
+     'json_field_substr_match' => {'tables' => 'templeton_testtab1'},
+    },
+    {                           #desc table
+     'num' => 8,
+     'method' => 'GET',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/templeton_testdb1/table/templeton_testtab1?user.name=:UNAME:',
+     'status_code' => 200,
+                                #	  'json_field_substr_match' => {'table-name' => 'templeton_testtab1'},

+     'json_field_match_object' => { 'columns' => '[
+                 { "name" : "i", "type" : "int"},
+                 { "name" : "j", "type" : "bigint", "comment" : "some comment"  }
+           ]' },
+    },
+    {                           #drop table
+     'num' => 9,
+     'method' => 'DELETE',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/templeton_testdb1/table/templeton_testtab1?user.name=:UNAME:',
+     'status_code' => 200,
+    },
+    {
+                                #-ve test , describe on non existent table
+     'num' => 10,
+     'method' => 'GET',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/templeton_testdb1/table/templeton_testtab1?user.name=:UNAME:',
+     'status_code' => 404, 
+     'json_field_substr_match' => {'error' => 'templeton_testtab1 does not exist'},
+    },
+    {
+                                #-ve test , describe on non existent table
+     'num' => 11,
+     'method' => 'GET',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/templeton_testdb1/table/templeton_testtab1?user.name=:UNAME:&format=extended:',
+     'status_code' => 404, 
+     'json_field_substr_match' => {'error' => 'templeton_testtab1 does not exist'},
+    },
+
+   ]
+  },
+
+##=============================================================================================================
+  {	       
+   'name' => 'REST_DDL_TABLE_EXTENDED',
+   'tests' => 
+   [
+  		  
+    {
+                                #cleanup 
+                                #drop table if exists
+     'num' => 1,
+     'method' => 'DELETE',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/default/table/templetontest_tabe?user.name=:UNAME:&ifExists=true',
+     'status_code' => 200,
+     'json_field_substr_match' => {'database' => 'default',  'table' => 'templetontest_tabe'},
+
+    },
+
+
+
+    {
+                                #setup
+                                #create table if not exists
+     'num' => 2,
+     'method' => 'PUT',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/default/table/templetontest_tabe?user.name=:UNAME:',
+     'status_code' => 200,
+     'format_header' => 'Content-Type: application/json',
+     'post_options' => [
+    	       
+             '{"ifNotExists": "false",
+              "columns": [
+                      { "name" : "i", "type" : "int" },
+                      { "name" : "j", "type" : "bigint" },
+                      { "name" : "ip", "type" : "string", "comment" : "IP Address of the
User" }
+              ], 
+              "format" : {
+                "storedAs" : "rcfile",
+                "rowFormat" : {
+                      "fieldsTerminatedBy" : "\u0001",
+                      "collectionItemsTerminatedBy" : "\u0002",
+                      "mapKeysTerminatedBy" : "\u0003",
+                      "linesTerminatedBy" : "\n",
+
+                      "serde" : {
+                        "name" : "org.apache.hadoop.hive.serde2.columnar.ColumnarSerDe",
+                        "properties" : {
+                            "key" : "value"
+                        }
+                     }
+               }
+             },
+              "comment" : "This is the page view table",
+              "partitionedBy" : [ { "name" : "dt", "type" : "string"}, { "name" : "country",
"type" : "string"}  ],
+              "tableProperties" : {"prop1" : "val1" , "prop2" : "val2" },
+              "clusteredBy" : {"columnNames": ["i", "j"], "sortedBy": [ {"columnName": "i",
"order": "ASC"}, {"columnName": "j", "order": "ASC"}], "numberOfBuckets": 10 } 
+            }',
+      ],
+     'json_field_substr_match' => {'database' => 'default',  'table' => 'templetontest_tabe'},
+
+
+    },
+
+    {                           #desc table
+     'num' => 3,
+     'method' => 'GET',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/default/table/templetontest_tabe?user.name=:UNAME:&format=extended',
+     'status_code' => 200,
+	   #TODO: check for clustered section 
+     'json_field_substr_match' => 
+     {
+      'location'         => "templetontest_tabe",
+      'inputFormat'      => "org.apache.hadoop.hive.ql.io.RCFileInputFormat",
+      'lastAccessTime'   => 0,
+      'lastUpdateTime'   => '\d{13}',
+      'maxFileSize'      => 0,
+      'minFileSize'      => 0,
+      'outputFormat'     => "org.apache.hadoop.hive.ql.io.RCFileOutputFormat",
+      'partitioned'      => "true",
+      'table'        => "templetontest_tabe",
+      
+	   
+     },
+     'json_field_match_object' => 
+     {'columns' => '[
+	      {
+                  "name" : "i",
+                  "type" : "int"
+              },
+	     {
+                  "name" : "j",
+                  "type" : "bigint"
+              },
+	     {
+                  "comment" : "IP Address of the User",
+                  "name" : "ip",
+                  "type" : "string"
+              }
+            ]',
+      "partitionColumns" => '[
+		{
+                  "name" : "dt",
+                  "type" : "string"
+                },
+		{
+                  "name" : "country",
+                  "type" : "string"
+                }
+              ]',
+     },
+    },
+
+   ]
+
+  },
+##=============================================================================================================
+  {
+   'name' => 'REST_DDL_TABLE_RENAME',
+   'tests' => 
+   [
+    {
+     #cleanup table 1
+     #drop table if exists
+     'num' => 1,
+     'method' => 'POST',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl',
+     'status_code' => 200,
+     'post_options' => ['user.name=:UNAME:','exec=drop table if exists templeton_testtab_rename1'],
+     'json_field_substr_match' => {'stderr' => 'OK'},
+    },
+    {
+     #cleanup table 2
+     #drop table if exists
+     'num' => 2,
+     'method' => 'POST',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl',
+     'status_code' => 200,
+     'post_options' => ['user.name=:UNAME:','exec=drop table if exists templeton_testtab_rename2'],
+     'json_field_substr_match' => {'stderr' => 'OK'},
+    },
+    {
+     #setup
+     #create table if not exists
+     'num' => 3,
+     'method' => 'POST',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl',
+     'status_code' => 200,
+     'post_options' => ['user.name=:UNAME:','exec=create table if not exists templeton_testtab_rename1
(i int, j bigint) STORED AS rcfile;'],
+     'json_field_substr_match' => {'stderr' => 'OK'},
+    },
+    {
+     #rename table
+     'num' => 4,
+     'method' => 'POST',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/default/table/templeton_testtab_rename1',
+     'status_code' => 200,
+     'post_options' => ['user.name=:UNAME:','rename=templeton_testtab_rename2'],
+     'json_field_substr_match' => {'table' => 'templeton_testtab_rename2'},
+    },
+
+    {
+     #desc table
+     'num' => 5,
+     'method' => 'GET',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/default/table/templeton_testtab_rename2?user.name=:UNAME:',
+     'status_code' => 200,
+     #	  'json_field_substr_match' => {'table-name' => 'templeton_testtab1'}, 
+     'json_field_match_object' => { 'columns' => '[
+                 { "name" : "i", "type" : "int" },
+                 { "name" : "j", "type" : "bigint" }
+           ]' },
+    },
+
+
+   ]
+
+  },
+
+
+##=============================================================================================================
+  {	       
+   'name' => 'REST_DDL_PARTITIONS',
+   'tests' => 
+   [
+
+    {
+     #cleanup 
+     #drop table if exists
+     'num' => 1,
+     'method' => 'POST',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl',
+     'status_code' => 200,
+     'post_options' => ['user.name=:UNAME:','exec=drop table if exists templetontest_parts'],
+     'json_field_substr_match' => {'stderr' => 'OK'},
+    },
+
+
+    {
+     #setup
+     #create table if not exists
+     'num' => 2,
+     'method' => 'POST',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl',
+     'status_code' => 200,
+     'post_options' => ['user.name=:UNAME:',
+                        'exec=create table if not exists templetontest_parts (i int, j bigint,
ip STRING COMMENT "IP Address of the User")
+COMMENT "This is the page view table"
+ PARTITIONED BY(dt STRING, country STRING)
+ROW FORMAT DELIMITED
+  FIELDS TERMINATED BY "\001"
+  COLLECTION ITEMS TERMINATED BY "\002"
+  MAP KEYS TERMINATED BY "\003"
+STORED AS rcfile
+--LOCATION "table1_location" '],
+     'json_field_substr_match' => {'stderr' => 'OK'},
+    },
+    {
+     #create partition 1
+     'num' => 3,
+     'method' => 'PUT',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/default/table/templetontest_parts/partition/dt=%2720120101%27,country=%27US%27?user.name=:UNAME:',
+     'status_code' => 200,
+     'format_header' => 'Content-Type: application/json',
+     'post_options' => ['{"location" : "loc1"}' ],
+     'json_field_substr_match' => {'database' => 'default',
+                                   'table' => 'templetontest_parts',
+                                   'partition' => "dt='20120101',country='US'"
+                                  },
+    },
+    {
+     #create partition 2
+     'num' => 4,
+     'method' => 'PUT',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/default/table/templetontest_parts/partition/dt=%2720120101%27,country=%27IN%27?user.name=:UNAME:',
+     'status_code' => 200,
+     'format_header' => 'Content-Type: application/json',
+     'post_options' => ['{"location" : "loc2"}' ],
+     'json_field_substr_match' => {'database' => 'default',
+                                   'table' => 'templetontest_parts',
+                                   'partition' => "dt='20120101',country='IN'"
+                                  },
+    },
+    {
+     #-ve test. create partition 2 -with same name
+     'num' => 5,
+     'method' => 'PUT',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/default/table/templetontest_parts/partition/dt=%2720120101%27,country=%27IN%27?user.name=:UNAME:',
+     'status_code' => 409,
+     'format_header' => 'Content-Type: application/json',
+     'post_options' => ['{"location" : "loc2"}' ],
+     'json_field_substr_match' => {'error' => 'Partition already exists',
+                                  },
+    },
+
+
+    {
+     #lookup partitions 
+     'num' => 6,
+     'method' => 'GET',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/default/table/templetontest_parts/partition/?user.name=:UNAME:',
+     'status_code' => 200,
+     'json_field_match_object' => 
+     {
+      "partitions" => 
+      '[  
+                  {
+                     "name" : "dt=\'20120101\',country=\'IN\'",
+                     "values" : [
+		     {
+                       "columnName" : "dt",
+                        "columnValue" : "20120101"
+        	     },
+		     {
+                     "columnName" : "country",
+                     "columnValue" : "IN"
+                    }
+		    ]
+	          },
+		  {
+		      "name" : "dt=\'20120101\',country=\'US\'",
+		      "values" : [
+				  {
+				      "columnName" : "dt",
+				      "columnValue" : "20120101"
+				  },
+				  {
+				      "columnName" : "country",
+				      "columnValue" : "US"
+				   }
+				  ]
+		   }
+               ]'
+
+     },
+    },
+
+    {
+     #describe a partition
+     'num' => 7,
+     'method' => 'GET',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/default/table/templetontest_parts/partition/dt=\'20120101\',country=\'IN\'?user.name=:UNAME:',
+     'status_code' => 200,
+     'json_field_substr_match' => 
+     {
+      "database" => "default",
+      "table" => "templetontest_parts",
+      "partition" => "dt=\'20120101\',country=\'IN\'",
+
+     },
+     'json_field_match_object' => 
+     {
+      "columns" => '[
+		{
+		    "name" : "i",
+		    "type" : "int"
+		},
+	       {
+		   "name" : "j",
+		   "type" : "bigint"
+	       },
+	       {
+		   "comment" : "IP Address of the User",
+		   "name" : "ip",
+		   "type" : "string"
+	      }
+	    ]',
+
+                                   "partitionColumns" => '[
+	      {
+		  "name" : "dt",
+		  "type" : "string"
+	      },
+	      {
+		  "name" : "country",
+		  "type" : "string"
+	     }
+          ]',
+     },
+    },
+
+
+    {
+     #describe a partition - extended
+     'num' => 8,
+     'method' => 'GET',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/default/table/templetontest_parts/partition/dt=\'20120101\',country=\'IN\'?user.name=:UNAME:&format=extended',
+     'status_code' => 200,
+     'json_field_substr_match' => 
+     {
+
+      "outputFormat" => "org.apache.hadoop.hive.ql.io.RCFileOutputFormat",
+      "inputFormat" => "org.apache.hadoop.hive.ql.io.RCFileInputFormat",
+      "lastAccessTime" => 0,
+      "maxFileSize" => 0,
+      "location" => "loc2",
+      "totalNumberFiles" => 0,
+      "lastUpdateTime" => '\d{13}',
+      "minFileSize" => 0,
+      "partitioned" => 'true',
+      "totalFileSize" => 0,
+      "table" => "templetontest_parts"
+     },
+     'json_field_match_object' => 
+     {
+      "columns" => '[
+		{
+		    "name" : "i",
+		    "type" : "int"
+		},
+	       {
+		   "name" : "j",
+		   "type" : "bigint"
+	       },
+	       {
+		   "comment" : "IP Address of the User",
+		   "name" : "ip",
+		   "type" : "string"
+	      }
+	    ]',
+
+                                   "partitionColumns" => '[
+	      {
+		  "name" : "dt",
+		  "type" : "string"
+	      },
+	      {
+		  "name" : "country",
+		  "type" : "string"
+	     }
+          ]',
+     },
+    },
+
+    {
+     #delete partition 2
+     'num' => 9,
+     'method' => 'DELETE',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/default/table/templetontest_parts/partition/dt=%2720120101%27,country=%27IN%27?user.name=:UNAME:',
+     'status_code' => 200,
+     'json_field_substr_match' => {'database' => 'default',
+                                   'table' => 'templetontest_parts',
+                                  },
+    },
+
+    {
+     #delete partition 2 again
+     'num' => 10,
+     'method' => 'DELETE',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/default/table/templetontest_parts/partition/dt=%2720120101%27,country=%27IN%27?user.name=:UNAME:',
+     'status_code' => 200, #should return 404 when bug is fixed
+     'json_field_substr_match' => 
+     { 'database' => 'default',
+       'table' => 'templetontest_parts',
+     },
+    },
+    {
+     #lookup deleted partition 2
+     'num' => 11,
+     'method' => 'GET',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/default/table/templetontest_parts/partition/dt=%2720120101%27,country=%27IN%27?user.name=:UNAME:',
+     'status_code' => 500, #should return 404 when bug is fixed
+     'json_field_substr_match' => 
+       {
+        'error' => 'Partition.*for table templetontest_parts does not exist'
+       },
+    },
+
+   ]
+
+  },
+
+##=============================================================================================================
+
+  {
+   'name' => 'REST_DDL_COLUMN',
+   'tests' => 
+   [
+    {
+     #cleanup table 
+     #drop table if exists
+     'num' => 1,
+     'method' => 'DELETE',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/default/table/templeton_testcol_tab?user.name=:UNAME:',
+     'status_code' => 200,
+    },
+    {
+     #setup
+     #create table if not exists
+     'num' => 2,
+     'method' => 'POST',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl?user.name=:UNAME:',
+     'status_code' => 200,
+     'post_options' => ['user.name=:UNAME:','exec=create table if not exists templeton_testcol_tab
(i int comment "column with comment", j bigint) STORED AS rcfile;'],
+     'json_field_substr_match' => {'stderr' => 'OK'},
+    },
+    {
+     #get column
+     'num' => 3,
+     'method' => 'GET',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/default/table/templeton_testcol_tab/column/?user.name=:UNAME:',
+     'status_code' => 200,
+     'json_field_substr_match' => 
+     {
+      'database' => 'default',
+      'table' => 'templeton_testcol_tab',
+
+     },
+     'json_field_match_object' => 
+     {
+      'columns' => '[
+                 { "name" : "i", "type" : "int", "comment" : "column with comment"},
+                 { "name" : "j", "type" : "bigint" }
+           ]' 
+     },
+    },
+
+    {
+     #get specific column
+     'num' => 4,
+     'method' => 'GET',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/default/table/templeton_testcol_tab/column/i?user.name=:UNAME:',
+     'status_code' => 200,
+     'json_field_substr_match' => 
+     {
+      'database' => 'default',
+      'table' => 'templeton_testcol_tab',
+
+     },
+     'json_field_match_object' => 
+     {
+      'column' => '{ "name" : "i", "type" : "int", "comment" : "column with comment" }'

+     },
+    },
+
+    {
+     #create new column
+     'num' => 5,
+     'method' => 'PUT',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/default/table/templeton_testcol_tab/column/k?user.name=:UNAME:',
+     'status_code' => 200,
+     'format_header' => 'Content-Type: application/json',
+     'post_options' => ['{"type": "string", "comment": "The k column"}' ],
+     
+     'json_field_substr_match' => 
+     {
+      'database' => 'default',
+      'table' => 'templeton_testcol_tab',
+      'column' => 'k',
+     },
+    },
+    {
+     #create duplicate column
+     'num' => 6,
+     'method' => 'PUT',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/default/table/templeton_testcol_tab/column/k?user.name=:UNAME:',
+     'status_code' => 409,
+     'format_header' => 'Content-Type: application/json',
+     'post_options' => ['{"type": "string", "comment": "The k column"}' ],
+
+    },
+
+
+
+
+   ]
+
+  },
+##=============================================================================================================
+
+  {	       
+   'name' => 'REST_DDL_TABLE_PROPS',
+   'tests' => 
+   [
+  		  
+    {
+                                #cleanup 
+                                #drop table if exists
+     'num' => 1,
+     'method' => 'DELETE',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/default/table/templetontest_tprop?user.name=:UNAME:&ifExists=true',
+     'status_code' => 200,
+     'json_field_substr_match' => {'database' => 'default',  'table' => 'templetontest_tprop'},
+
+    },
+
+
+
+    {
+                                #setup
+                                #create table if not exists
+     'num' => 2,
+     'method' => 'PUT',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/default/table/templetontest_tprop?user.name=:UNAME:',
+     'status_code' => 200,
+     'format_header' => 'Content-Type: application/json',
+     'post_options' => [
+    	       
+             '{"ifNotExists": "true",
+              "columns": [
+                      { "name" : "i", "type" : "int" },
+                      { "name" : "j", "type" : "bigint" },
+                      { "name" : "ip", "type" : "string", "comment" : "IP Address of the
User" }
+              ], 
+  	          "format" : {  "storedAs" : "rcfile"},
+              "comment" : "This is the page view table",
+              "partitionedBy" : [ { "name" : "dt", "type" : "string"}, { "name" : "country",
"type" : "string"}  ],
+              "tableProperties" : {"prop1" : "val1" , "prop2" : "val2" }
+            }',
+      ],
+     'json_field_substr_match' => {'database' => 'default',  'table' => 'templetontest_tprop'},
+
+
+    },
+    {
+     
+     'num' => 3,
+     'method' => 'GET',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/default/table/templetontest_tprop/property?user.name=:UNAME:',
+     'status_code' => 200,
+      #using the substring match instead of  object match for properties because object contains
a property with timestamp value 
+     'json_field_substr_match' => 
+           {'database' => 'default',  
+            'table' => 'templetontest_tprop', 
+            'properties' => '(.*prop1.*val1|.*prop2.*val2)|(.*prop1.*val1|.*prop2.*val2)'
+           },
+    },
+    {
+     #add new property
+     'num' => 4,
+     'method' => 'PUT',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/default/table/templetontest_tprop/property/prop3?user.name=:UNAME:',
+     'status_code' => 200,
+     'json_field_substr_match' => 
+        {'database' => 'default',  'table' => 'templetontest_tprop', "property" =>
"prop3"},
+     'format_header' => 'Content-Type: application/json',
+     'post_options' => ['{"value" : "val3"}' ],
+
+    },
+    {
+     #get new property
+     'num' => 5,
+     'method' => 'GET',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/default/table/templetontest_tprop/property/prop3?user.name=:UNAME:',
+     'status_code' => 200,
+     'json_field_substr_match' => 
+        {'database' => 'default',  'table' => 'templetontest_tprop'},
+     'json_field_match_object' => 
+        { 'property' => '{"prop3" : "val3"}'},
+     'format_header' => 'Content-Type: application/json',
+
+    },
+    {
+     #add new property
+     'num' => 6,
+     'method' => 'PUT',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/default/table/templetontest_tprop/property/prop3?user.name=:UNAME:',
+     'status_code' => 200,
+     'json_field_substr_match' => 
+        {'database' => 'default',  'table' => 'templetontest_tprop', "property" =>
"prop3"},
+     'format_header' => 'Content-Type: application/json',
+     'post_options' => ['{"value" : "newval3"}' ],
+
+    },
+    {
+     #get new property
+     'num' => 7,
+     'method' => 'GET',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/default/table/templetontest_tprop/property/prop3?user.name=:UNAME:',
+     'status_code' => 200,
+     'json_field_substr_match' => 
+        {'database' => 'default',  'table' => 'templetontest_tprop'},
+     'json_field_match_object' => 
+        { 'property' => '{"prop3" : "newval3"}'},
+     'format_header' => 'Content-Type: application/json',
+
+    },
+
+
+    {
+                                #cleanup 
+                                #drop table if exists
+     'num' => 10,
+     'method' => 'DELETE',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/default/table/templetontest_tprop?user.name=:UNAME:&ifExists=true',
+     'status_code' => 200,
+     'json_field_substr_match' => {'database' => 'default',  'table' => 'templetontest_tprop'},
+
+    },
+  ]
+},
+
+##=============================================================================================================
+  {	       
+   'name' => 'REST_DDL_TABLE_GROUP_PERMS', #test the group and permission flags
+   'ignore' => 'these features are tested as part of hcat auth tests. current test cases
dont work with auth enabled',
+   'tests' => 
+   [
+  		  
+    {
+                                #cleanup 
+                                #drop table if exists
+     'num' => 1,
+     'method' => 'DELETE',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/default/table/templetontest_tgrouperm?user.name=:UNAME:&ifExists=true',
+     'status_code' => 200,
+     'json_field_substr_match' => {'database' => 'default',  'table' => 'templetontest_tgrouperm'},
+
+    },
+
+
+
+    {
+                                #create table -ve test - no such group
+     'num' => 2,
+     'method' => 'PUT',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/default/table/templetontest_tgrouperm?user.name=:UNAME:',
+     'status_code' => 500,
+     'format_header' => 'Content-Type: application/json',
+     'post_options' => [
+    	       
+             '{"ifNotExists": "true",
+               "group" : "nosuchgroupAAAABBB",
+              "columns": [
+                      { "name" : "i", "type" : "int" },
+                      { "name" : "j", "type" : "bigint" },
+                      { "name" : "ip", "type" : "string", "comment" : "IP Address of the
User" }
+              ], 
+  	          "format" : {  "storedAs" : "rcfile"},
+              "comment" : "This is the page view table",
+              "partitionedBy" : [ { "name" : "dt", "type" : "string"}, { "name" : "country",
"type" : "string"}  ],
+              "tableProperties" : {"prop1" : "val1" , "prop2" : "val2" }
+            }',
+      ],
+#     'json_field_substr_match' => {'database' => 'default',  'table' => 'templetontest_tgrouperm'},
+#TODO - add checks after error message is standardised 
+
+    },
+    {
+                                #create table with no permissions
+     'num' => 3,
+     'method' => 'PUT',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/default/table/templetontest_tgrouperm?user.name=:UNAME:',
+     'status_code' => 200,
+     'format_header' => 'Content-Type: application/json',
+     'post_options' => [
+    	       
+             '{"ifNotExists": "true",
+               "permissions" : "---------",
+              "columns": [
+                      { "name" : "i", "type" : "int" },
+                      { "name" : "j", "type" : "bigint" },
+                      { "name" : "ip", "type" : "string", "comment" : "IP Address of the
User" }
+              ], 
+  	          "format" : {  "storedAs" : "rcfile"},
+              "comment" : "This is the page view table",
+              "partitionedBy" : [ { "name" : "dt", "type" : "string"}, { "name" : "country",
"type" : "string"}  ],
+              "tableProperties" : {"prop1" : "val1" , "prop2" : "val2" }
+            }',
+      ],
+     'json_field_substr_match' => {'database' => 'default',  'table' => 'templetontest_tgrouperm'},
+
+
+    },
+
+    {
+     #create partition in table that does not have permissions
+     'num' => 4,
+     'method' => 'PUT',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/default/table/templetontest_tgrouperm/partition/dt=%2720120101%27,country=%27US%27?user.name=:UNAME:',
+     'status_code' => 500,
+     'format_header' => 'Content-Type: application/json',
+     'post_options' => ['{"location" : "loc1"}' ],
+     'json_field_substr_match' => {'database' => 'default',
+                                   'table' => 'templetontest_tgrouperm',
+                                   'error' => 'Permission denied',
+                                   'partition' => "dt='20120101',country='US'"
+                                  },
+    },
+
+
+  ]
+
+},
+
+##=============================================================================================================
+  {
+   'name' => 'HCAT_GROUP_PERMS',
+   'ignore' => 'these features are tested as part of hcat auth tests. current test cases
dont work with auth enabled',
+   'tests' => 
+   [
+    {
+                                #drop table if exists
+     'num' => 1,
+     'method' => 'POST',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl',
+     'status_code' => 200,
+     'post_options' => ['user.name=:UNAME:','exec=drop table if exists templetontest_hcatgp'],
+     'json_field_substr_match' => {'stderr' => 'OK'},
+
+    },
+    {
+                                #create table . -ve test
+     'num' => 2,
+     'method' => 'POST',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl',
+     'status_code' => 200,
+     'post_options' => ['user.name=:UNAME:',
+                        'group=no_such_group_AA',
+                        'exec=create table templetontest_hcatgp(i int, j bigint) STORED AS
rcfile;'],
+     'json_field_substr_match' => {'stderr' => 'User does not belong to no_such_group_AA',
'exitcode' => '^1$'}
+    },
+    {
+                                #create table with no permissions
+     'num' => 3,
+     'method' => 'POST',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl',
+     'status_code' => 200,
+     'post_options' => ['user.name=:UNAME:',
+                        'permissions=---------',
+                        'exec=create table templetontest_hcatgp(i int, j bigint)  
+                         PARTITIONED BY(dt STRING, country STRING)
+                         STORED AS rcfile;'
+                       ],
+     'json_field_substr_match' => {'stderr' => 'OK', 'exitcode' => '^0$'}
+    },
+
+    {
+     #create partition in table that does not have permissions
+     'num' => 4,
+     'method' => 'PUT',
+     'url' => ':TEMPLETON_URL:/templeton/v1/ddl/database/default/table/templetontest_hcatgp/partition/dt=%2720120101%27,country=%27US%27?user.name=:UNAME:',
+     'status_code' => 500,
+     'format_header' => 'Content-Type: application/json',
+     'post_options' => ['{"location" : "loc1"}' ],
+     'json_field_substr_match' => {'database' => 'default',
+                                   'table' => 'templetontest_hcatgp',
+                                   'error' => 'Permission denied',
+                                   'partition' => "dt='20120101',country='US'"
+                                  },
+    },
+
+  ]
+
+}
+
+
+
+
+
+ ]
+},
+  ;
+



Mime
View raw message