1) Fix Issue 198 (Metadata tests need to be rewritten - added additional tests, cleaned existing) 
2) Metadata tests now use the new test framework. 


git-svn-id: https://asterixdb.googlecode.com/svn/branches/asterix_stabilization@950 eaa15691-b419-025a-1212-ee371bd00084
diff --git a/asterix-app/src/test/resources/metadata/queries/meta01.aql b/asterix-app/src/test/resources/metadata/queries/basic/meta01.aql
similarity index 78%
rename from asterix-app/src/test/resources/metadata/queries/meta01.aql
rename to asterix-app/src/test/resources/metadata/queries/basic/meta01.aql
index 15b7de8..5ce47ad 100644
--- a/asterix-app/src/test/resources/metadata/queries/meta01.aql
+++ b/asterix-app/src/test/resources/metadata/queries/basic/meta01.aql
@@ -7,7 +7,9 @@
 drop dataverse testdv if exists;
 create dataverse testdv;
 
-write output to nc1:"rttest/meta01.adm";
+write output to nc1:"mdtest/basic_meta01.adm";
 
 for $l in dataset('Metadata.Dataverse')
 return $l
+
+drop dataverse testdv;
diff --git a/asterix-app/src/test/resources/metadata/queries/meta02.aql b/asterix-app/src/test/resources/metadata/queries/basic/meta02.aql
similarity index 77%
rename from asterix-app/src/test/resources/metadata/queries/meta02.aql
rename to asterix-app/src/test/resources/metadata/queries/basic/meta02.aql
index f6686b1..8bfc240 100644
--- a/asterix-app/src/test/resources/metadata/queries/meta02.aql
+++ b/asterix-app/src/test/resources/metadata/queries/basic/meta02.aql
@@ -7,9 +7,9 @@
 drop dataverse testdv if exists;
 create dataverse testdv;
 
-write output to nc1:"rttest/meta02.adm";
+write output to nc1:"mdtest/basic_meta02.adm";
 
-create type test.testtype as open {
+create type testdv.testtype as open {
 id : int32
 }
 
@@ -18,3 +18,5 @@
 for $l in dataset('Metadata.Dataset')
 where $l.DataverseName = 'testdv' and $l.DatasetName = 'dst01'
 return $l
+
+drop dataverse testdv; 
diff --git a/asterix-app/src/test/resources/metadata/queries/meta03.aql b/asterix-app/src/test/resources/metadata/queries/basic/meta03.aql
similarity index 83%
rename from asterix-app/src/test/resources/metadata/queries/meta03.aql
rename to asterix-app/src/test/resources/metadata/queries/basic/meta03.aql
index 88c658c..0b876f2 100644
--- a/asterix-app/src/test/resources/metadata/queries/meta03.aql
+++ b/asterix-app/src/test/resources/metadata/queries/basic/meta03.aql
@@ -7,7 +7,7 @@
 drop dataverse testdv if exists;
 create dataverse testdv;
 
-write output to nc1:"rttest/meta03.adm";
+write output to nc1:"mdtest/basic_meta03.adm";
 
 create type testdv.testtype as closed {
 id : int32
@@ -16,3 +16,6 @@
 for $l in dataset('Metadata.Datatype')
 where $l.DataverseName='testdv' and $l.DatatypeName='testtype'
 return $l
+
+drop dataverse testdv;
+
diff --git a/asterix-app/src/test/resources/metadata/queries/meta04.aql b/asterix-app/src/test/resources/metadata/queries/basic/meta04.aql
similarity index 83%
rename from asterix-app/src/test/resources/metadata/queries/meta04.aql
rename to asterix-app/src/test/resources/metadata/queries/basic/meta04.aql
index fac73da..b2e7304 100644
--- a/asterix-app/src/test/resources/metadata/queries/meta04.aql
+++ b/asterix-app/src/test/resources/metadata/queries/basic/meta04.aql
@@ -7,7 +7,7 @@
 drop dataverse testdv if exists;
 create dataverse testdv;
 
-write output to nc1:"rttest/meta04.adm";
+write output to nc1:"mdtest/basic_meta04.adm";
 
 create type testdv.testtype as open {
 id : int32
@@ -16,3 +16,5 @@
 for $l in dataset('Metadata.Datatype')
 where $l.DataverseName='testdv' and $l.DatatypeName='testtype'
 return $l
+
+drop dataverse testdv;
diff --git a/asterix-app/src/test/resources/metadata/queries/meta05.aql b/asterix-app/src/test/resources/metadata/queries/basic/meta05.aql
similarity index 86%
rename from asterix-app/src/test/resources/metadata/queries/meta05.aql
rename to asterix-app/src/test/resources/metadata/queries/basic/meta05.aql
index 6a99187..9eb129d 100644
--- a/asterix-app/src/test/resources/metadata/queries/meta05.aql
+++ b/asterix-app/src/test/resources/metadata/queries/basic/meta05.aql
@@ -7,7 +7,7 @@
 drop dataverse testdv if exists;
 create dataverse testdv;
 
-write output to nc1:"rttest/meta05.adm";
+write output to nc1:"mdtest/basic_meta05.adm";
 
 create type testdv.testtype as open {
 id : int32,
@@ -21,3 +21,5 @@
 for $l in dataset('Metadata.Index')
 where $l.DataverseName='testdv' 
 return $l
+
+drop dataverse testdv;
diff --git a/asterix-app/src/test/resources/metadata/queries/meta06.aql b/asterix-app/src/test/resources/metadata/queries/basic/meta06.aql
similarity index 83%
rename from asterix-app/src/test/resources/metadata/queries/meta06.aql
rename to asterix-app/src/test/resources/metadata/queries/basic/meta06.aql
index c0b9a9b..6297561 100644
--- a/asterix-app/src/test/resources/metadata/queries/meta06.aql
+++ b/asterix-app/src/test/resources/metadata/queries/basic/meta06.aql
@@ -7,7 +7,7 @@
 drop dataverse testdv if exists;
 create dataverse testdv;
 
-write output to nc1:"rttest/meta06.adm";
+write output to nc1:"mdtest/basic_meta06.adm";
 
 create function testdv.fun01(){
 "This is an AQL Bodied UDF"
@@ -16,3 +16,4 @@
 for $l in dataset('Metadata.Function')
 return $l
 
+drop dataverse testdv;
diff --git a/asterix-app/src/test/resources/metadata/queries/meta07.aql b/asterix-app/src/test/resources/metadata/queries/basic/meta07.aql
similarity index 84%
rename from asterix-app/src/test/resources/metadata/queries/meta07.aql
rename to asterix-app/src/test/resources/metadata/queries/basic/meta07.aql
index 2455eeb..6544bca 100644
--- a/asterix-app/src/test/resources/metadata/queries/meta07.aql
+++ b/asterix-app/src/test/resources/metadata/queries/basic/meta07.aql
@@ -6,7 +6,7 @@
 
 // Please note this query was run on two nodes, i.e; two NCs
 
-write output to nc1:"rttest/meta07.adm";
+write output to nc1:"mdtest/basic_meta07.adm";
 
 for $l in dataset('Metadata.Node')
 return $l
diff --git a/asterix-app/src/test/resources/metadata/queries/meta08.aql b/asterix-app/src/test/resources/metadata/queries/basic/meta08.aql
similarity index 84%
rename from asterix-app/src/test/resources/metadata/queries/meta08.aql
rename to asterix-app/src/test/resources/metadata/queries/basic/meta08.aql
index e382c47..a7d536f 100644
--- a/asterix-app/src/test/resources/metadata/queries/meta08.aql
+++ b/asterix-app/src/test/resources/metadata/queries/basic/meta08.aql
@@ -6,7 +6,7 @@
 
 // Please note this query was run on two nodes, i.e; two NCs
 
-write output to nc1:"rttest/meta08.adm";
+write output to nc1:"mdtest/basic_meta08.adm";
 
 for $l in dataset('Metadata.Nodegroup')
 return $l
diff --git a/asterix-app/src/test/resources/metadata/queries/meta09.aql b/asterix-app/src/test/resources/metadata/queries/basic/meta09.aql
similarity index 92%
rename from asterix-app/src/test/resources/metadata/queries/meta09.aql
rename to asterix-app/src/test/resources/metadata/queries/basic/meta09.aql
index 4404707..28a3794 100644
--- a/asterix-app/src/test/resources/metadata/queries/meta09.aql
+++ b/asterix-app/src/test/resources/metadata/queries/basic/meta09.aql
@@ -7,7 +7,7 @@
 drop dataverse test if exists;
 create dataverse test;
 
-write output to nc1:"rttest/meta09.adm";
+write output to nc1:"mdtest/basic_meta09.adm";
 
 create type test.testtype as open {
 id:int32
@@ -29,3 +29,5 @@
 for $l in dataset('Metadata.Dataset')
 where $l.DataverseName='test' and $l.DatasetName='t1'
 return $l
+
+drop dataverse test; 
diff --git a/asterix-app/src/test/resources/metadata/queries/meta10.aql b/asterix-app/src/test/resources/metadata/queries/basic/meta10.aql
similarity index 77%
rename from asterix-app/src/test/resources/metadata/queries/meta10.aql
rename to asterix-app/src/test/resources/metadata/queries/basic/meta10.aql
index 6aae87b..452dcc3 100644
--- a/asterix-app/src/test/resources/metadata/queries/meta10.aql
+++ b/asterix-app/src/test/resources/metadata/queries/basic/meta10.aql
@@ -8,7 +8,10 @@
 create dataverse test;
 drop dataverse test if exists;
 
-write output to nc1:"rttest/meta10.adm";
+write output to nc1:"mdtest/basic_meta10.adm";
 
+count(
 for $l in dataset('Metadata.Dataverse')
+where $l.DataverseName='test'
 return $l
+)
diff --git a/asterix-app/src/test/resources/metadata/queries/meta11.aql b/asterix-app/src/test/resources/metadata/queries/basic/meta11.aql
similarity index 74%
rename from asterix-app/src/test/resources/metadata/queries/meta11.aql
rename to asterix-app/src/test/resources/metadata/queries/basic/meta11.aql
index a5ae81e..d781114 100644
--- a/asterix-app/src/test/resources/metadata/queries/meta11.aql
+++ b/asterix-app/src/test/resources/metadata/queries/basic/meta11.aql
@@ -7,7 +7,7 @@
 drop dataverse test if exists;
 create dataverse test;
 
-write output to nc1:"rttest/meta11.adm";
+write output to nc1:"mdtest/basic_meta11.adm";
 
 create type test.testtype as open {
 id : int32
@@ -17,5 +17,11 @@
 
 drop dataset test.dst01;
 
+count(
 for $l in dataset('Metadata.Dataset')
+where $l.DataverseName='test' and $l.DatasetName='dst01'
 return $l
+)
+
+drop dataverse test;
+
diff --git a/asterix-app/src/test/resources/metadata/queries/meta12.aql b/asterix-app/src/test/resources/metadata/queries/basic/meta12.aql
similarity index 85%
rename from asterix-app/src/test/resources/metadata/queries/meta12.aql
rename to asterix-app/src/test/resources/metadata/queries/basic/meta12.aql
index 481cc3a..1de7ac5 100644
--- a/asterix-app/src/test/resources/metadata/queries/meta12.aql
+++ b/asterix-app/src/test/resources/metadata/queries/basic/meta12.aql
@@ -4,12 +4,10 @@
  * Date         : Sep 17 2012
  */
 
-// This drop index test is broken for now.
-
 drop dataverse test if exists;
 create dataverse test;
 
-write output to nc1:"rttest/meta12.adm";
+write output to nc1:"mdtest/basic_meta12.adm";
 
 create type test.testtype as open {
 id : int32,
@@ -25,3 +23,5 @@
 for $l in dataset('Metadata.Index')
 where $l.DatasetName = 'dst01'
 return $l
+
+drop dataverse test;
diff --git a/asterix-app/src/test/resources/metadata/queries/meta13.aql b/asterix-app/src/test/resources/metadata/queries/basic/meta13.aql
similarity index 72%
rename from asterix-app/src/test/resources/metadata/queries/meta13.aql
rename to asterix-app/src/test/resources/metadata/queries/basic/meta13.aql
index 62d0964..0c0f627 100644
--- a/asterix-app/src/test/resources/metadata/queries/meta13.aql
+++ b/asterix-app/src/test/resources/metadata/queries/basic/meta13.aql
@@ -5,12 +5,10 @@
  * Date         : Sep 17 2012
  */
 
-// this test returns NPE today
-
 drop dataverse test if exists;
 create dataverse test;
 
-write output to nc1:"rttest/meta13.adm";
+write output to nc1:"mdtest/basic_meta13.adm";
 
 create function test.foo(){
 "drop this function"
@@ -18,6 +16,9 @@
 
 drop function test.foo@0;
 
+count(
 for $l in dataset('Metadata.Function')
-return $l;
+where $l.DataverseName='test' and $l.Name='foo' and $l.Arity=0
+return $l);
 
+drop dataverse test;
diff --git a/asterix-app/src/test/resources/metadata/queries/regress_04_drop_nested_type.aql b/asterix-app/src/test/resources/metadata/queries/basic/meta14.aql
similarity index 68%
rename from asterix-app/src/test/resources/metadata/queries/regress_04_drop_nested_type.aql
rename to asterix-app/src/test/resources/metadata/queries/basic/meta14.aql
index f8c8626..9103614 100644
--- a/asterix-app/src/test/resources/metadata/queries/regress_04_drop_nested_type.aql
+++ b/asterix-app/src/test/resources/metadata/queries/basic/meta14.aql
@@ -4,6 +4,7 @@
  * Expected Result  :  Success
  */
 
+
 drop dataverse test if exists;
 create dataverse test;
 use dataverse test;
@@ -12,10 +13,15 @@
    bar: int32?
 };
 
+
 drop type FooType;
 
-create type FooType as closed {
-   bar: int32?
-};
+write output to nc1:"mdtest/basic_meta14.adm";
 
-drop type FooType;
\ No newline at end of file
+count(
+for $x in dataset('Metadata.Datatype')
+where $x.DataverseName='test'
+return $x
+)
+
+drop dataverse test;
diff --git a/asterix-app/src/test/resources/metadata/queries/basic/meta15.aql b/asterix-app/src/test/resources/metadata/queries/basic/meta15.aql
new file mode 100644
index 0000000..91827ef
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/basic/meta15.aql
@@ -0,0 +1,11 @@
+/*
+ * Description  : Query Metadata dataset Adapter to verify to contents.
+ * Expected Res : Success
+ * Date         : 25 Nov 2012
+ */
+
+write output to nc1:"mdtest/basic_meta15.adm";
+
+for $l in dataset('Metadata.DatasourceAdapter')
+return $l
+
diff --git a/asterix-app/src/test/resources/metadata/queries/basic/meta16.aql b/asterix-app/src/test/resources/metadata/queries/basic/meta16.aql
new file mode 100644
index 0000000..8b69b4f
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/basic/meta16.aql
@@ -0,0 +1,9 @@
+use dataverse Metadata;
+
+write output to nc1:"mdtest/basic_meta16.adm";
+
+for $c in dataset('Dataset')
+return $c
+
+
+
diff --git a/asterix-app/src/test/resources/metadata/queries/basic/meta17.aql b/asterix-app/src/test/resources/metadata/queries/basic/meta17.aql
new file mode 100644
index 0000000..2cd25ee
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/basic/meta17.aql
@@ -0,0 +1,6 @@
+use dataverse Metadata;
+
+write output to nc1:"mdtest/basic_meta17.adm";
+     
+for $c in dataset('Datatype')
+return $c
diff --git a/asterix-app/src/test/resources/metadata/queries/basic/meta18.aql b/asterix-app/src/test/resources/metadata/queries/basic/meta18.aql
new file mode 100644
index 0000000..45f065a
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/basic/meta18.aql
@@ -0,0 +1,6 @@
+use dataverse Metadata;
+
+write output to nc1:"mdtest/basic_meta18.adm";
+
+for $c in dataset('Dataverse')
+return $c
diff --git a/asterix-app/src/test/resources/metadata/queries/metadata_index.aql b/asterix-app/src/test/resources/metadata/queries/basic/meta19.aql
similarity index 66%
rename from asterix-app/src/test/resources/metadata/queries/metadata_index.aql
rename to asterix-app/src/test/resources/metadata/queries/basic/meta19.aql
index cbe0109..21de582 100644
--- a/asterix-app/src/test/resources/metadata/queries/metadata_index.aql
+++ b/asterix-app/src/test/resources/metadata/queries/basic/meta19.aql
@@ -1,6 +1,6 @@
 use dataverse Metadata;
 
-write output to nc1:"rttest/metadata_index.adm";
+write output to nc1:"mdtest/basic_meta19.adm";
 
 for $c in dataset('Index')
 where $c.DataverseName='Metadata'
diff --git a/asterix-app/src/test/resources/metadata/queries/basic/meta20.aql b/asterix-app/src/test/resources/metadata/queries/basic/meta20.aql
new file mode 100644
index 0000000..259f23e
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/basic/meta20.aql
@@ -0,0 +1,6 @@
+use dataverse Metadata;    
+
+write output to nc1:"mdtest/basic_meta20.adm";
+
+for $c in dataset('Node')
+return $c
diff --git a/asterix-app/src/test/resources/metadata/queries/basic/meta21.aql b/asterix-app/src/test/resources/metadata/queries/basic/meta21.aql
new file mode 100644
index 0000000..b5f8110
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/basic/meta21.aql
@@ -0,0 +1,6 @@
+use dataverse Metadata;
+
+write output to nc1:"mdtest/basic_meta21.adm";
+     
+for $c in dataset('Nodegroup')
+return $c
diff --git a/asterix-app/src/test/resources/metadata/queries/basic/metadata_dataset.aql b/asterix-app/src/test/resources/metadata/queries/basic/metadata_dataset.aql
new file mode 100644
index 0000000..94f7a58
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/basic/metadata_dataset.aql
@@ -0,0 +1,9 @@
+use dataverse Metadata;
+
+write output to nc1:"rttest/basic_metadata_dataset.adm";
+
+for $c in dataset('Dataset')
+return $c
+
+
+
diff --git a/asterix-app/src/test/resources/metadata/queries/basic/metadata_datatype.aql b/asterix-app/src/test/resources/metadata/queries/basic/metadata_datatype.aql
new file mode 100644
index 0000000..4cc94de
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/basic/metadata_datatype.aql
@@ -0,0 +1,6 @@
+use dataverse Metadata;
+
+write output to nc1:"rttest/basic_metadata_datatype.adm";
+     
+for $c in dataset('Datatype')
+return $c
diff --git a/asterix-app/src/test/resources/metadata/queries/basic/metadata_dataverse.aql b/asterix-app/src/test/resources/metadata/queries/basic/metadata_dataverse.aql
new file mode 100644
index 0000000..d3edfed
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/basic/metadata_dataverse.aql
@@ -0,0 +1,6 @@
+use dataverse Metadata;
+
+write output to nc1:"rttest/basic_metadata_dataverse.adm";
+
+for $c in dataset('Dataverse')
+return $c
diff --git a/asterix-app/src/test/resources/metadata/queries/metadata_index.aql b/asterix-app/src/test/resources/metadata/queries/basic/metadata_index.aql
similarity index 63%
copy from asterix-app/src/test/resources/metadata/queries/metadata_index.aql
copy to asterix-app/src/test/resources/metadata/queries/basic/metadata_index.aql
index cbe0109..cb78758 100644
--- a/asterix-app/src/test/resources/metadata/queries/metadata_index.aql
+++ b/asterix-app/src/test/resources/metadata/queries/basic/metadata_index.aql
@@ -1,6 +1,6 @@
 use dataverse Metadata;
 
-write output to nc1:"rttest/metadata_index.adm";
+write output to nc1:"rttest/basic_metadata_index.adm";
 
 for $c in dataset('Index')
 where $c.DataverseName='Metadata'
diff --git a/asterix-app/src/test/resources/metadata/queries/basic/metadata_node.aql b/asterix-app/src/test/resources/metadata/queries/basic/metadata_node.aql
new file mode 100644
index 0000000..2d28ed6
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/basic/metadata_node.aql
@@ -0,0 +1,6 @@
+use dataverse Metadata;    
+
+write output to nc1:"rttest/basic_metadata_node.adm";
+
+for $c in dataset('Node')
+return $c
diff --git a/asterix-app/src/test/resources/metadata/queries/basic/metadata_nodegroup.aql b/asterix-app/src/test/resources/metadata/queries/basic/metadata_nodegroup.aql
new file mode 100644
index 0000000..86615e6
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/basic/metadata_nodegroup.aql
@@ -0,0 +1,6 @@
+use dataverse Metadata;
+
+write output to nc1:"rttest/basic_metadata_nodegroup.adm";
+     
+for $c in dataset('Nodegroup')
+return $c
diff --git a/asterix-app/src/test/resources/metadata/queries/custord_dataset.aql b/asterix-app/src/test/resources/metadata/queries/custord_dataset.aql
deleted file mode 100644
index 530c6c9..0000000
--- a/asterix-app/src/test/resources/metadata/queries/custord_dataset.aql
+++ /dev/null
@@ -1,10 +0,0 @@
-use dataverse Metadata;
-
-write output to nc1:"rttest/custord_dataset.adm";
-
-for $c in dataset('Dataset')
-where $c.DataverseName = "custord"
-return $c
-
-
-
diff --git a/asterix-app/src/test/resources/metadata/queries/custord_datatype.aql b/asterix-app/src/test/resources/metadata/queries/custord_datatype.aql
deleted file mode 100644
index 1525b93..0000000
--- a/asterix-app/src/test/resources/metadata/queries/custord_datatype.aql
+++ /dev/null
@@ -1,7 +0,0 @@
-use dataverse Metadata;
-
-write output to nc1:"rttest/custord_datatype.adm";
-     
-for $c in dataset('Datatype')
-where $c.DataverseName = "custord"
-return $c
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/metadata/queries/custord_dataverse.aql b/asterix-app/src/test/resources/metadata/queries/custord_dataverse.aql
deleted file mode 100644
index 277bf62..0000000
--- a/asterix-app/src/test/resources/metadata/queries/custord_dataverse.aql
+++ /dev/null
@@ -1,8 +0,0 @@
-use dataverse Metadata;
-
-write output to nc1:"rttest/custord_dataverse.adm";
-
-for $c in dataset('Dataverse')
-where $c.DataverseName = "custord"
-return $c
-
diff --git a/asterix-app/src/test/resources/metadata/queries/custord_index.aql b/asterix-app/src/test/resources/metadata/queries/custord_index.aql
deleted file mode 100644
index 95450da..0000000
--- a/asterix-app/src/test/resources/metadata/queries/custord_index.aql
+++ /dev/null
@@ -1,7 +0,0 @@
-use dataverse Metadata;
-
-write output to nc1:"rttest/custord_index.adm";
-
-for $c in dataset('Index')
-where $c.DataverseName = "custord"
-return $c
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/metadata/queries/custord_nodegroup.aql b/asterix-app/src/test/resources/metadata/queries/custord_nodegroup.aql
deleted file mode 100644
index 090c739..0000000
--- a/asterix-app/src/test/resources/metadata/queries/custord_nodegroup.aql
+++ /dev/null
@@ -1,6 +0,0 @@
-use dataverse Metadata;
-
-write output to nc1:"rttest/metadata_nodegroup.adm";
-     
-for $c in dataset('Nodegroup')
-return $c
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/metadata/queries/custord_q1.aql b/asterix-app/src/test/resources/metadata/queries/custord_q1.aql
deleted file mode 100644
index 4ba02b9..0000000
--- a/asterix-app/src/test/resources/metadata/queries/custord_q1.aql
+++ /dev/null
@@ -1,65 +0,0 @@
-drop dataverse custord if exists;
-
-create dataverse custord;
-
-use dataverse custord;
-
-create type StreetType as closed {
-  number: int32?,
-  name: string
-}
-
-create type AddressType as open {
-  street: StreetType,
-  city: string,
-  state: string,
-  zip: int16
-}
-
-create type CustomerType as closed {
-  cid: int32, 
-  name: string,
-  age: int32?,
-  address: AddressType?,
-  interests: {{string}},
-  children: [ {
-             name : string,
-             dob : string
-             } ]
-}
-
-create type OrderType as open {
-  oid: int32,
-  cid: int32,
-  orderstatus: string,
-  orderpriority: string,
-  clerk: string,
-  total: float,
-  items: [ {
-       number: int64,
-       storeIds: {{int8}} 
-       } ]
-}
-
-create nodegroup group1  if not exists on nc1, nc2;
-
-create dataset Customers(CustomerType)
-  partitioned by key cid, name on group1;
-
-load dataset Customers 
-using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
-(("path"="nc1://data/metadata/customerData.json"),("format"="adm"));
-        
-create dataset Orders(OrderType)
-  partitioned by key oid on group1;
-
-load dataset Orders 
-using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
-(("path"="nc1://data/metadata/orderData.json"),("format"="adm"));
-
-create index ordCustId if not exists on Orders(cid);
-
-create index custName if not exists on Customers(name, cid);
-
-create index ordClerkTotal if not exists on Orders(clerk, total);
-  
diff --git a/asterix-app/src/test/resources/metadata/queries/custord_q10.aql b/asterix-app/src/test/resources/metadata/queries/custord_q10.aql
deleted file mode 100644
index abe6041..0000000
--- a/asterix-app/src/test/resources/metadata/queries/custord_q10.aql
+++ /dev/null
@@ -1,7 +0,0 @@
-use dataverse Metadata;
-
-write output to nc1:"rttest/custord_q10.adm";
-
-for $c in dataset('Dataset')
-return $c
-
diff --git a/asterix-app/src/test/resources/metadata/queries/custord_q2.aql b/asterix-app/src/test/resources/metadata/queries/custord_q2.aql
deleted file mode 100644
index 291ca64..0000000
--- a/asterix-app/src/test/resources/metadata/queries/custord_q2.aql
+++ /dev/null
@@ -1,7 +0,0 @@
-use dataverse custord;
-     
-write output to nc1:"rttest/custord_q2.adm";
-      
-for $c in dataset('Customers')
-order by $c.cid
-return $c.address
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/metadata/queries/custord_q3.aql b/asterix-app/src/test/resources/metadata/queries/custord_q3.aql
deleted file mode 100644
index c093baa..0000000
--- a/asterix-app/src/test/resources/metadata/queries/custord_q3.aql
+++ /dev/null
@@ -1,6 +0,0 @@
-use dataverse custord;
-
-write output to nc1:"rttest/custord_q3.adm";
-      
-for $o in dataset('Orders')
-return {"id" : $o.oid, "total": $o.total} 
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/metadata/queries/custord_q4.aql b/asterix-app/src/test/resources/metadata/queries/custord_q4.aql
deleted file mode 100644
index 9bdf494..0000000
--- a/asterix-app/src/test/resources/metadata/queries/custord_q4.aql
+++ /dev/null
@@ -1,9 +0,0 @@
-use dataverse custord;
-
-write output to nc1:"rttest/custord_q4.adm";
-
-for $c in dataset('Customers')
-for $o in dataset('Orders')
-where $c.cid = $o.cid 
-order by $c.cid
-return {"cust_name":$c.name, "cust_age": $c.age, "order_total":$o.total} 
diff --git a/asterix-app/src/test/resources/metadata/queries/custord_q5.aql b/asterix-app/src/test/resources/metadata/queries/custord_q5.aql
deleted file mode 100644
index 716cce7..0000000
--- a/asterix-app/src/test/resources/metadata/queries/custord_q5.aql
+++ /dev/null
@@ -1,21 +0,0 @@
-drop nodegroup fuzzynodegroup if exists;
-
-drop dataverse fuzzyjoin if exists;
-
-use dataverse custord;
-
-create dataset Customers if not exists (CustomerType)
-  partitioned by key cid, name on group1;
-  
-drop dataset employees if exists;
-
-create index custName if not exists on Customers(name, cid);
-
-drop index Customers.custAddress if exists;
-
-create type StreetType if not exists as closed {
-  number: int32?,
-  name: string
-}
-
-drop type DBLPType if exists;
diff --git a/asterix-app/src/test/resources/metadata/queries/custord_q6.aql b/asterix-app/src/test/resources/metadata/queries/custord_q6.aql
deleted file mode 100644
index 231c410..0000000
--- a/asterix-app/src/test/resources/metadata/queries/custord_q6.aql
+++ /dev/null
@@ -1,7 +0,0 @@
-use dataverse custord;
-
-drop index Orders.ordClerkTotal;
-
-drop dataset Orders;
-
-drop type OrderType;
diff --git a/asterix-app/src/test/resources/metadata/queries/custord_q7.aql b/asterix-app/src/test/resources/metadata/queries/custord_q7.aql
deleted file mode 100644
index 247ed78..0000000
--- a/asterix-app/src/test/resources/metadata/queries/custord_q7.aql
+++ /dev/null
@@ -1,2 +0,0 @@
-drop dataverse custord;
- 
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/metadata/queries/exception/exception_drop_dataset.aql b/asterix-app/src/test/resources/metadata/queries/exception/exception_drop_dataset.aql
new file mode 100644
index 0000000..4cce09a
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/exception/exception_drop_dataset.aql
@@ -0,0 +1 @@
+drop dataset DBLP;
diff --git a/asterix-app/src/test/resources/metadata/queries/exception/exception_drop_dataverse.aql b/asterix-app/src/test/resources/metadata/queries/exception/exception_drop_dataverse.aql
new file mode 100644
index 0000000..b92618e
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/exception/exception_drop_dataverse.aql
@@ -0,0 +1 @@
+drop dataverse fuzzyjoin;
diff --git a/asterix-app/src/test/resources/metadata/queries/exception/exception_drop_index.aql b/asterix-app/src/test/resources/metadata/queries/exception/exception_drop_index.aql
new file mode 100644
index 0000000..386a71d
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/exception/exception_drop_index.aql
@@ -0,0 +1 @@
+drop index Cust.ord;
diff --git a/asterix-app/src/test/resources/metadata/queries/custord_q8.aql b/asterix-app/src/test/resources/metadata/queries/exception/exception_drop_nodegroup.aql
similarity index 95%
rename from asterix-app/src/test/resources/metadata/queries/custord_q8.aql
rename to asterix-app/src/test/resources/metadata/queries/exception/exception_drop_nodegroup.aql
index bb4225d..664f52f 100644
--- a/asterix-app/src/test/resources/metadata/queries/custord_q8.aql
+++ b/asterix-app/src/test/resources/metadata/queries/exception/exception_drop_nodegroup.aql
@@ -1,2 +1 @@
 drop nodegroup group1;
- 
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/metadata/queries/exception/exception_drop_type1.aql b/asterix-app/src/test/resources/metadata/queries/exception/exception_drop_type1.aql
new file mode 100644
index 0000000..4c6c7ae
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/exception/exception_drop_type1.aql
@@ -0,0 +1 @@
+drop type AddressType;
diff --git a/asterix-app/src/test/resources/metadata/queries/exception/exception_drop_type2.aql b/asterix-app/src/test/resources/metadata/queries/exception/exception_drop_type2.aql
new file mode 100644
index 0000000..b97b812
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/exception/exception_drop_type2.aql
@@ -0,0 +1 @@
+drop type CustomerType;
diff --git a/asterix-app/src/test/resources/metadata/queries/exception/exception_drop_type3.aql b/asterix-app/src/test/resources/metadata/queries/exception/exception_drop_type3.aql
new file mode 100644
index 0000000..3812745
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/exception/exception_drop_type3.aql
@@ -0,0 +1 @@
+drop type StreetType;
diff --git a/asterix-app/src/test/resources/metadata/queries/exceptions.aql b/asterix-app/src/test/resources/metadata/queries/exceptions.aql
deleted file mode 100644
index b6ec188..0000000
--- a/asterix-app/src/test/resources/metadata/queries/exceptions.aql
+++ /dev/null
@@ -1,21 +0,0 @@
-// Each statement (except for the second "use" statement) should throw an exception.
-
-//drop nodegroup group1;
-
-//drop dataverse fuzzyjoin;
-
-//use dataverse fuzzy;
-
-//use dataverse custord;
-
-//drop index Cust.ord;
-
-//drop index Customers.ord;
-
-//drop type AddressType;
-
-//drop type CustomerType;
-
-//drop type StreetType;
-
-//drop dataset DBLP;
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/metadata/queries/metadata_dataset.aql b/asterix-app/src/test/resources/metadata/queries/metadata_dataset.aql
deleted file mode 100644
index 723e65c..0000000
--- a/asterix-app/src/test/resources/metadata/queries/metadata_dataset.aql
+++ /dev/null
@@ -1,9 +0,0 @@
-use dataverse Metadata;
-
-write output to nc1:"rttest/metadata_dataset.adm";
-
-for $c in dataset('Dataset')
-return $c
-
-
-
diff --git a/asterix-app/src/test/resources/metadata/queries/metadata_datatype.aql b/asterix-app/src/test/resources/metadata/queries/metadata_datatype.aql
deleted file mode 100644
index a144f4f..0000000
--- a/asterix-app/src/test/resources/metadata/queries/metadata_datatype.aql
+++ /dev/null
@@ -1,6 +0,0 @@
-use dataverse Metadata;
-
-write output to nc1:"rttest/metadata_datatype.adm";
-     
-for $c in dataset('Datatype')
-return $c
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/metadata/queries/metadata_dataverse.aql b/asterix-app/src/test/resources/metadata/queries/metadata_dataverse.aql
deleted file mode 100644
index e7e1249..0000000
--- a/asterix-app/src/test/resources/metadata/queries/metadata_dataverse.aql
+++ /dev/null
@@ -1,6 +0,0 @@
-use dataverse Metadata;
-
-write output to nc1:"rttest/metadata_dataverse.adm";
-
-for $c in dataset('Dataverse')
-return $c
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/metadata/queries/metadata_node.aql b/asterix-app/src/test/resources/metadata/queries/metadata_node.aql
deleted file mode 100644
index ce28ac8..0000000
--- a/asterix-app/src/test/resources/metadata/queries/metadata_node.aql
+++ /dev/null
@@ -1,6 +0,0 @@
-use dataverse Metadata;    
-
-write output to nc1:"rttest/metadata_node.adm";
-
-for $c in dataset('Node')
-return $c
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/metadata/queries/metadata_nodegroup.aql b/asterix-app/src/test/resources/metadata/queries/metadata_nodegroup.aql
deleted file mode 100644
index 090c739..0000000
--- a/asterix-app/src/test/resources/metadata/queries/metadata_nodegroup.aql
+++ /dev/null
@@ -1,6 +0,0 @@
-use dataverse Metadata;
-
-write output to nc1:"rttest/metadata_nodegroup.adm";
-     
-for $c in dataset('Nodegroup')
-return $c
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/metadata/queries/regress_01_create_type.aql b/asterix-app/src/test/resources/metadata/queries/regress_01_create_type.aql
deleted file mode 100644
index e978572..0000000
--- a/asterix-app/src/test/resources/metadata/queries/regress_01_create_type.aql
+++ /dev/null
@@ -1,12 +0,0 @@
-drop dataverse test if exists;
-create dataverse test;
-use dataverse test;
-
-create nodegroup group1 if not exists on nc1, nc2;
-
-// Create a type in test dataverse.
-// This type will be referred to in a subsequent script.
-create type TestType as closed {
-  id: int32,
-  name: string
-}
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/metadata/queries/regress_02_refer_existing_type.aql b/asterix-app/src/test/resources/metadata/queries/regress_02_refer_existing_type.aql
deleted file mode 100644
index aeed866..0000000
--- a/asterix-app/src/test/resources/metadata/queries/regress_02_refer_existing_type.aql
+++ /dev/null
@@ -1,6 +0,0 @@
-use dataverse test;
-
-// Refer to existing type in test dataverse.
-create type UseTestType as closed {
-  test: TestType
-}
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/metadata/queries/regress_03_repeated_create_drop.aql b/asterix-app/src/test/resources/metadata/queries/regress_03_repeated_create_drop.aql
deleted file mode 100644
index 02009da..0000000
--- a/asterix-app/src/test/resources/metadata/queries/regress_03_repeated_create_drop.aql
+++ /dev/null
@@ -1,34 +0,0 @@
-drop dataverse test if exists;
-create dataverse test;
-use dataverse test;
-
-create type TypeOne as open {
-  f: int32
-}
-create nodegroup group1 if not exists on nc1, nc2;
-create dataset typeonedataset(TypeOne)
-partitioned by key f on group1;
-
-
-drop dataverse test if exists;  
-create dataverse test;
-use dataverse test;
-
-create type TypeTwo as open {
-  f: int32
-}
-create nodegroup group1 if not exists on nc1, nc2;
-create dataset typetwodataset(TypeTwo)
-partitioned by key f on group1;
-
-
-drop dataverse test if exists;  
-create dataverse test;
-use dataverse test;
-
-create type TypeThree as open {
-  f: int32
-}
-create nodegroup group1 if not exists on nc1, nc2;
-create dataset typethreedataset(TypeThree)
-partitioned by key f on group1;
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/metadata/queries/custord_q9.aql b/asterix-app/src/test/resources/metadata/queries/transaction/failure_previous_success.aql
similarity index 65%
rename from asterix-app/src/test/resources/metadata/queries/custord_q9.aql
rename to asterix-app/src/test/resources/metadata/queries/transaction/failure_previous_success.aql
index 2d3f960..5250eef 100644
--- a/asterix-app/src/test/resources/metadata/queries/custord_q9.aql
+++ b/asterix-app/src/test/resources/metadata/queries/transaction/failure_previous_success.aql
@@ -1,3 +1,9 @@
+/*
+ * Description  : Cause a failure by creating an existing type. Verify that rollback does not affect the pre-existing types.
+ *                Verification is done in a separate session (compilation unit).
+ * Expected Res : Success
+ * Date         : 24 Nov 2012
+ */
 drop dataverse custord if exists;
 
 create dataverse custord;
@@ -41,12 +47,8 @@
        } ]
 }
 
-create external dataset Customers(CustomerType)
-using "edu.uci.ics.asterix.external.dataset.adapter.HDFSAdapter"
-      (("hdfs"="hdfs://temp1/data1"),("n1"="v1"),("n2"="v2"), ("n3"="v3"));
-  
-create external dataset Orders(OrderType)
-using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
-(("path"="nc1:///tmp1/data1,nc2:///tmp2/data2"));
 
-
+create type StreetType as closed {
+  number: int32?,
+  name: string
+}
diff --git a/asterix-app/src/test/resources/metadata/queries/transaction/failure_subsequent_no_execution.aql b/asterix-app/src/test/resources/metadata/queries/transaction/failure_subsequent_no_execution.aql
new file mode 100644
index 0000000..d4678f2
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/transaction/failure_subsequent_no_execution.aql
@@ -0,0 +1,47 @@
+/*
+ * Description  : Create dataverse, types, nodegroup and a dataset. Cause exception by re-creating nodegroup. 
+ *                Subsequent statement(s) should not executed. This is verified in a separate session (compilation unit)
+ * Expected Res : Exception
+ * Date         : 24 Nov 2012
+ */
+drop dataverse custord if exists;
+
+create dataverse custord;
+
+use dataverse custord;
+
+create type StreetType as closed {
+  number: int32?,
+  name: string
+}
+
+create type AddressType as open {
+  street: StreetType,
+  city: string,
+  state: string,
+  zip: int16
+}
+
+create type CustomerType as closed {
+  cid: int32, 
+  name: string,
+  age: int32?,
+  address: AddressType?,
+  interests: {{string}},
+  children: [ {
+             name : string,
+             dob : string
+             } ]
+}
+
+create nodegroup group1 if not exists on nc1, nc2;
+
+create dataset Customers(CustomerType)
+  partitioned by key cid, name on group1;
+
+create nodegroup group1 on nc1, nc2;
+
+// the following statement should not get executed 
+// as the above statement causes an exception
+create index custName on Customers(name, cid);
+  
diff --git a/asterix-app/src/test/resources/metadata/queries/transaction/verify_failure_previous_success.aql b/asterix-app/src/test/resources/metadata/queries/transaction/verify_failure_previous_success.aql
new file mode 100644
index 0000000..351a9e4
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/transaction/verify_failure_previous_success.aql
@@ -0,0 +1,12 @@
+/*
+ * Description  : Verify the state of the Metadata adter the failure caused in failure_previous_success.aql 
+ * Expected Res : Success
+ * Date         : 24 Nov 2012
+ */
+use dataverse custord;
+
+write output to nc1:"mdtest/transaction_verify_failure_previous_success.adm";
+
+for $x in dataset('Metadata.Datatype')
+where $x.DataverseName='custord'
+return $x
diff --git a/asterix-app/src/test/resources/metadata/queries/transaction/verify_failure_subsequent_no_execution.aql b/asterix-app/src/test/resources/metadata/queries/transaction/verify_failure_subsequent_no_execution.aql
new file mode 100644
index 0000000..6505903
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/transaction/verify_failure_subsequent_no_execution.aql
@@ -0,0 +1,13 @@
+/*
+ * Description  : Verify the state of the metadata after the failure caused by failure_subsequent_no_execution.aql
+ * Expected Res : Success
+ * Date         : 24 Nov 2012
+ */
+
+use dataverse custord;
+
+write output to nc1:"mdtest/transaction_verify_failure_subsequent_no_execution.adm";
+
+for $x in dataset('Metadata.Index')
+where $x.DataverseName='custord'
+return $x