-
Notifications
You must be signed in to change notification settings - Fork 535
8525 ingest optional skip #8532
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8b9e706
b9b2efe
e504bfc
0943258
d0c70e7
46d07ce
3f92d83
5cbe6a7
f0123ec
1a040a6
8457911
d5090b7
2da5d2d
eea514e
3170ef2
9b04c9c
3589b4c
4fc0a35
2163fdc
3cf56e8
fe9e7e6
ecc9ffc
47c1413
66b774b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Tabular ingest can be skipped via API. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,8 +3,9 @@ | |
| import com.jayway.restassured.RestAssured; | ||
| import com.jayway.restassured.response.Response; | ||
| import java.util.logging.Logger; | ||
| import org.junit.BeforeClass; | ||
|
|
||
| import org.junit.Test; | ||
| import org.junit.BeforeClass; | ||
| import com.jayway.restassured.path.json.JsonPath; | ||
| import com.jayway.restassured.path.xml.XmlPath; | ||
| import static edu.harvard.iq.dataverse.api.AccessIT.apiToken; | ||
|
|
@@ -39,11 +40,10 @@ | |
| import static org.hamcrest.CoreMatchers.startsWith; | ||
| import static org.hamcrest.CoreMatchers.nullValue; | ||
| import org.hamcrest.Matchers; | ||
| import org.junit.AfterClass; | ||
|
|
||
| import static org.junit.Assert.assertNotNull; | ||
| import static org.junit.Assert.assertNull; | ||
| import static org.junit.Assert.assertTrue; | ||
| import org.junit.Ignore; | ||
|
|
||
| public class FilesIT { | ||
|
|
||
|
|
@@ -1784,4 +1784,58 @@ public void testRange() throws IOException { | |
|
|
||
| } | ||
|
|
||
| @Test | ||
| public void testAddFileToDatasetSkipTabIngest() throws IOException, InterruptedException { | ||
|
|
||
| Response createUser = UtilIT.createRandomUser(); | ||
| assertEquals(200, createUser.getStatusCode()); | ||
| String username = UtilIT.getUsernameFromResponse(createUser); | ||
| String apiToken = UtilIT.getApiTokenFromResponse(createUser); | ||
|
|
||
| Response createDataverseResponse = UtilIT.createRandomDataverse(apiToken); | ||
| assertEquals(201, createDataverseResponse.getStatusCode()); | ||
| String dataverseAlias = UtilIT.getAliasFromResponse(createDataverseResponse); | ||
|
|
||
| Response createDatasetResponse = UtilIT.createRandomDatasetViaNativeApi(dataverseAlias, apiToken); | ||
| assertEquals(201, createDatasetResponse.getStatusCode()); | ||
| Integer datasetIdInt = JsonPath.from(createDatasetResponse.body().asString()).getInt("data.id"); | ||
|
|
||
| String pathToFile = "src/test/resources/sav/dct.sav"; | ||
| String jsonAsString = "{\"description\":\"My description.\",\"directoryLabel\":\"data/subdir1\",\"categories\":[\"Data\"], \"restrict\":\"false\", \"tabIngest\":\"false\"}"; | ||
| Response r = UtilIT.uploadFileViaNative(datasetIdInt.toString(), pathToFile, jsonAsString, apiToken); | ||
| logger.info(r.prettyPrint()); | ||
| assertEquals(200, r.getStatusCode()); | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry to keep bugging you but, since this hasn't been merged yet, could you please insert another sleepForLock statement here? (Otherwise, if the ingest somehow ends up happening, despite the Thanks. (I should've thought about this sooner of course).
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added sleep for lock.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great, thanks. |
||
| assertTrue("Failed test if Ingest Lock exceeds max duration " + pathToFile, UtilIT.sleepForLock(datasetIdInt, "Ingest", apiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION)); | ||
|
|
||
| Long dataFileId = JsonPath.from(r.body().asString()).getLong("data.files[0].dataFile.id"); | ||
| Response fileMeta = UtilIT.getDataFileMetadataDraft(dataFileId, apiToken); | ||
| String label = JsonPath.from(fileMeta.body().asString()).getString("label"); | ||
| assertEquals("dct.sav", label); | ||
|
|
||
| pathToFile = "src/test/resources/sav/frequency-test.sav"; | ||
| jsonAsString = "{\"description\":\"My description.\",\"directoryLabel\":\"data/subdir1\",\"categories\":[\"Data\"], \"restrict\":\"false\" }"; | ||
| Response rTabIngest = UtilIT.uploadFileViaNative(datasetIdInt.toString(), pathToFile, jsonAsString, apiToken); | ||
| logger.info(rTabIngest.prettyPrint()); | ||
| assertEquals(200, rTabIngest.getStatusCode()); | ||
|
|
||
| assertTrue("Failed test if Ingest Lock exceeds max duration " + pathToFile, UtilIT.sleepForLock(datasetIdInt, "Ingest", apiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION)); | ||
|
|
||
| Long ingDataFileId = JsonPath.from(rTabIngest.body().asString()).getLong("data.files[0].dataFile.id"); | ||
| Response ingFileMeta = UtilIT.getDataFileMetadataDraft(ingDataFileId, apiToken); | ||
| String ingLabel = JsonPath.from(ingFileMeta.body().asString()).getString("label"); | ||
| assertEquals("frequency-test.tab", ingLabel); | ||
|
|
||
| //cleanup | ||
| Response destroyDatasetResponse = UtilIT.destroyDataset(datasetIdInt, apiToken); | ||
| assertEquals(200, destroyDatasetResponse.getStatusCode()); | ||
|
|
||
| Response deleteDataverseResponse = UtilIT.deleteDataverse(dataverseAlias, apiToken); | ||
| assertEquals(200, deleteDataverseResponse.getStatusCode()); | ||
|
|
||
| Response deleteUserResponse = UtilIT.deleteUser(username); | ||
| assertEquals(200, deleteUserResponse.getStatusCode()); | ||
|
|
||
| } | ||
|
|
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.