Skip to content

Testing Uploads

Dwayne Jeng edited this page Feb 26, 2021 · 3 revisions

You can either call Bridge through raw HTTP requests using an HTTP tool such as Postman

Or you can write a script using Java. See UploadTest.java for an example.

This doc will also contain code links if you want to follow along in the code to see how this works internally.

Testing Uploads with HTTP Requests

  1. If needed, create a consented user account as per https://github.com/Sage-Bionetworks/BridgeServer2/wiki/Creating-Accounts#creating-consented-participants

  2. Find file legacy-survey-encrypted in Integration Tests.

  3. Request an upload session from Bridge. Entry Point

    POST http://localhost:9000/v3/uploads
    {
      "name":"legacy-survey-encrypted",
      "contentLength":1453,
      "contentType":"application/zip",
      "contentMd5":"c4LAe/36wqQAMXPyKnKm6w=="
    }
    

    This will return an upload ID and an S3 URL. This will also create an entry in the local-(username)-Upload2 table in DynamoDB.

  4. PUT this file (legacy-survey-encrypted) to the S3 URL. Your request needs to include the following headers, all of which need to match the values from the previous step

    • Content-Type
    • Content-MD5
  5. POST http://localhost:9000/v3/uploads/{uploadId}/complete Entry Point

    This will kick off an asynchronous request to process your upload. You can follow along the logs to see if it's successful, or you can GET http://localhost:9000/v3/uploadstatuses/{uploadId}. This will update the entry in DynamoDB table local-(username)-Upload2 and create a corresponding entry in local-(username)-HealthDataRecord3.

When you've completed these steps, you'll have uploaded some test data to Bridge. Knowing how to do this will be useful for testing upload stuff end to end. If you find yourself uploading a lot of test data (which is likely), feel free to write a script to simplify the process.

To create your own upload, you'll need to know how to zip, encrypt, and find the MD5 hash of your file. This is a little bit trickier to do from the commandline. For a Java example, see ExportTest.java

Testing the Health Data Submission API

  1. If needed, create a consented user account as per https://github.com/Sage-Bionetworks/BridgeServer2/wiki/Creating-Accounts#creating-consented-participants

  2. Submit Health Data to Bridge Entry Point

    POST http://localhost:9000/v3/healthdata
    {
      "appVersion":"version 1.0.0, build 2",
      "createdOn":"2018-08-25T15:34:13.084+0900",
      "phoneInfo":"MacBook Air (11-inch, Early 2015); OS X 10.10.5",
      "schemaId":"legacy-survey",
      "schemaRevision":1,
      "data":{
        "AAA":["Yes"],
        "BBB":["fencing", "running", 3]
      }
    }
    

    This will synchronously process the submitted health data and return the processed health data, with the record ID, status, and parsed fields (if any). The health data record will also be persisted in DynamoDB as an entry in local-(username)-HealthDataRecord3.

Upload Documentation