You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by gr...@apache.org on 2015/02/11 01:11:11 UTC

incubator-usergrid git commit: Removed uploading using a sub directory seeing as import will no longer checks the directory structure. Added additional tests that check to see how multiple files are handled in import.

Repository: incubator-usergrid
Updated Branches:
  refs/heads/two-dot-o-import 450ba09df -> 15be01015


Removed uploading using a sub directory seeing as import will no longer checks the directory structure.
Added additional tests that check to see how multiple files are handled in import.


Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/15be0101
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/15be0101
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/15be0101

Branch: refs/heads/two-dot-o-import
Commit: 15be01015cc48cb55147ddb832aa006ac29c54ef
Parents: 450ba09
Author: grey <gr...@apigee.com>
Authored: Tue Feb 10 16:11:10 2015 -0800
Committer: grey <gr...@apigee.com>
Committed: Tue Feb 10 16:11:10 2015 -0800

----------------------------------------------------------------------
 .../rest/management/ImportResourceIT.java       | 99 +++++++++++++++++++-
 .../usergrid/management/importer/S3Upload.java  |  2 +-
 2 files changed, 95 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/15be0101/stack/rest/src/test/java/org/apache/usergrid/rest/management/ImportResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/ImportResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/ImportResourceIT.java
index 0de6b98..862f1e4 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/ImportResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/ImportResourceIT.java
@@ -458,10 +458,55 @@ public class ImportResourceIT extends AbstractRestIT {
 
         assertNotNull( importGet );
 
+        assertEquals( "FINISHED",importGet.get( "state" ) );
+        assertEquals( 1, importGet.get("fileCount") );
+
+        Collection collection = this.app().collection( "things" ).get();
+
+         assertNotNull( collection );
+         assertEquals( 1, collection.getNumOfEntities() );
+         assertEquals( "thing0" ,collection.getResponse().getEntities().get( 0 ).get( "name" ) );
+
+
+
+    //TODO: make sure it checks the actual imported entities. And the progress they have made.
+
+}
+
+    /**
+     * TODO: Test that importing bad JSON will result in an informative error message.
+     */
+    @Test
+    public void testImportOneGoodOneBad() throws Exception{
+        // import from a bad JSON file
+        Assume.assumeTrue( configured );
+
+        String org = clientSetup.getOrganizationName();
+        String app = clientSetup.getAppName();
+
+
+        //list out all the files in the resource directory you want uploaded
+        List<String> filenames = new ArrayList<>( 1 );
+
+        filenames.add( "testImportCorrect.testCol.1.json" );
+        filenames.add( "testImport.testApplication.2.json" );
+        // create 10 applications each with collection of 10 things, export all to S3
+        S3Upload s3Upload = new S3Upload();
+        s3Upload.copyToS3( System.getProperty(SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR), System.getProperty(SDKGlobalConfiguration.SECRET_KEY_ENV_VAR),
+            bucketName, filenames );
+
+        // import all those exports from S3 into the default test application
+
+        Entity importEntity = importCollection( );
+
+        Entity importGet = this.management().orgs().organization( org ).app().addToPath( app )
+                               .addToPath( "import" ).addToPath( ( String ) importEntity.get( "Import Entity" ) ).get();
 
-//        assertNull( importGet.get( "errorMessage" ) );
-//        assertNotNull( importGet.get( "state" ) );
-//        assertEquals("import",importGet.get( "type" ));
+
+        assertNotNull( importGet );
+
+        assertEquals( "FAILED",importGet.get( "state" ) );
+        assertEquals( 2, importGet.get("fileCount") );
 
         Collection collection = this.app().collection( "things" ).get();
 
@@ -469,7 +514,52 @@ public class ImportResourceIT extends AbstractRestIT {
         assertEquals( 1, collection.getNumOfEntities() );
         assertEquals( "thing0" ,collection.getResponse().getEntities().get( 0 ).get( "name" ) );
 
-//TODO: make sure it checks the actual imported entities. And the progress they have made.
+
+
+
+    }
+
+    /**
+     * TODO: Test that importing bad JSON will result in an informative error message.
+     */
+    @Test
+    public void testImportOneBadFile() throws Exception{
+        // import from a bad JSON file
+        Assume.assumeTrue( configured );
+
+        String org = clientSetup.getOrganizationName();
+        String app = clientSetup.getAppName();
+
+
+        //list out all the files in the resource directory you want uploaded
+        List<String> filenames = new ArrayList<>( 1 );
+
+        filenames.add( "testImport.testApplication.2.json" );
+        // create 10 applications each with collection of 10 things, export all to S3
+        S3Upload s3Upload = new S3Upload();
+        s3Upload.copyToS3( System.getProperty(SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR), System.getProperty(SDKGlobalConfiguration.SECRET_KEY_ENV_VAR),
+            bucketName, filenames );
+
+        // import all those exports from S3 into the default test application
+
+        Entity importEntity = importCollection( );
+
+        Entity importGet = this.management().orgs().organization( org ).app().addToPath( app )
+                               .addToPath( "import" ).addToPath( ( String ) importEntity.get( "Import Entity" ) ).get();
+
+
+        assertNotNull( importGet );
+
+        assertEquals( "FAILED",importGet.get( "state" ) );
+        assertEquals( 1, importGet.get("fileCount") );
+
+
+        Collection collection = this.app().collection( "things" ).get();
+
+        assertNotNull( collection );
+        assertEquals( 0, collection.getNumOfEntities() );
+
+
 
     }
 //export with two files and import the two files.
@@ -485,7 +575,6 @@ public class ImportResourceIT extends AbstractRestIT {
         String org = clientSetup.getOrganizationName();
         String app = clientSetup.getAppName();
 
-
         //list out all the files in the resource directory you want uploaded
         List<String> filenames = new ArrayList<>( 1 );
         filenames.add( "testImportInvalidJson.testApplication.3.json" );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/15be0101/stack/services/src/test/java/org/apache/usergrid/management/importer/S3Upload.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/importer/S3Upload.java b/stack/services/src/test/java/org/apache/usergrid/management/importer/S3Upload.java
index c556bfd..16a326f 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/importer/S3Upload.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/importer/S3Upload.java
@@ -78,7 +78,7 @@ public class S3Upload {
             InputStream fileStream = S3Upload.class.getResourceAsStream( "/" + filename );
             try {
                 BlobStore blobStore = context.getBlobStore();
-                BlobBuilder blobBuilder = blobStore.blobBuilder( "testorganization/"+filename ).payload( fileStream ).calculateMD5()
+                BlobBuilder blobBuilder = blobStore.blobBuilder( filename ).payload( fileStream ).calculateMD5()
                                                    .contentType( "application/json" );
                 Blob blob = blobBuilder.build();