Skip to content

Commit

Permalink
imply-5072-test-stage-job (#98)
Browse files Browse the repository at this point in the history
* Adding tests to stage job, style cleanup
  • Loading branch information
Agustin Gonzalez authored Dec 3, 2020
1 parent e9f6d82 commit 2f8ae7e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
package io.imply.druid.ingest.server;

import com.google.common.base.Function;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.inject.Inject;
Expand Down Expand Up @@ -168,7 +167,9 @@ public Response stageIngestJob(
@PathParam("table") String tableName
)
{
Preconditions.checkArgument(metadataStore.druidTableExists(tableName));
if (!metadataStore.druidTableExists(tableName)) {
return Response.status(Response.Status.NOT_FOUND).build();
}
// make jobId uuid, generate URL for file dropoff
// write staging job to somewhere with 'staged' state
final JobRunner jobTypeToUse = jobType != null ? jobType : new BatchAppendJobRunner();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import java.net.URISyntaxException;
import java.util.Map;


public class TablesResourceTest
{
private static final String TABLE = "test";
Expand Down Expand Up @@ -100,7 +99,7 @@ public void teardown()
}

@Test
public void testStageJob() throws URISyntaxException
public void testStageJobShoulWorkWhenTableExists() throws URISyntaxException
{
// expectAuthorizationTokenCheck(); see resource filter annotations are not called when testing in this manner
// see https://github.com/apache/druid/issues/6685
Expand All @@ -123,7 +122,25 @@ public void testStageJob() throws URISyntaxException

Assert.assertEquals(200, response.getStatus());
}


@Test
public void testStageJobShoulReturn404WhenTableDoesNotExist()
{
// expectAuthorizationTokenCheck(); see resource filter annotations are not called when testing in this manner
// see https://github.com/apache/druid/issues/6685
String id = UUIDUtils.generateUuid();
EasyMock.expect(metadataStore.druidTableExists(EasyMock.eq(TABLE))).andReturn(false).once();

EasyMock.replay(fileStore, metadataStore, req);

Response response = tablesResource.stageIngestJob(null, TABLE);

Map<String, Object> responseEntity = (Map<String, Object>) response.getEntity();

Assert.assertEquals(404, response.getStatus());
}


@Test
public void testScheduleIngestJobShouldSucceedWhenJobExists()
{
Expand Down

0 comments on commit 2f8ae7e

Please sign in to comment.