Skip to content
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

[Internal] Add integration tests for Jobs API #325

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import static org.junit.jupiter.api.Assertions.*;

import com.databricks.sdk.WorkspaceClient;
import com.databricks.sdk.core.error.platform.InvalidParameterValue;
import com.databricks.sdk.core.error.platform.ResourceDoesNotExist;
import com.databricks.sdk.integration.framework.CollectionUtils;
import com.databricks.sdk.integration.framework.EnvContext;
import com.databricks.sdk.integration.framework.EnvTest;
import com.databricks.sdk.service.jobs.BaseJob;
import com.databricks.sdk.service.jobs.ListJobsRequest;
import com.databricks.sdk.service.jobs.*;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

Expand All @@ -32,4 +32,112 @@ void getNonExistingJob(WorkspaceClient w) {
w.jobs().get(123456789);
});
}

@Test
void deleteNonExistingJob(WorkspaceClient w) {
assertThrowsExactly(
InvalidParameterValue.class,
() -> {
w.jobs().delete(123456789);
});
}

@Test
void resetNonExistingJob(WorkspaceClient w) {
assertThrowsExactly(
InvalidParameterValue.class,
() -> {
w.jobs().reset(123456789, new JobSettings());
});
}

@Test
void updateNonExistingJob(WorkspaceClient w) {
assertThrowsExactly(
InvalidParameterValue.class,
() -> {
w.jobs().update(123456789);
});
}

@Test
void runNonExistingJob(WorkspaceClient w) {
assertThrowsExactly(
InvalidParameterValue.class,
() -> {
w.jobs().runNow(123456789);
});
}

@Test
void listsRuns(WorkspaceClient w) {
Iterable<BaseRun> list = w.jobs().listRuns(new ListRunsRequest());

java.util.List<BaseRun> all = CollectionUtils.asList(list);

CollectionUtils.assertUnique(all);
}

@Test
void getNonExistingRun(WorkspaceClient w) {
assertThrowsExactly(
InvalidParameterValue.class,
() -> {
w.jobs().getRun(123456789);
});
}

@Test
void getOutputOfNonExistingRun(WorkspaceClient w) {
assertThrowsExactly(
InvalidParameterValue.class,
() -> {
w.jobs().getRunOutput(123456789);
});
}

@Test
void deleteNonExistingRun(WorkspaceClient w) {
assertThrowsExactly(
InvalidParameterValue.class,
() -> {
w.jobs().deleteRun(123456789);
});
}

@Test
void exportNonExistingRun(WorkspaceClient w) {
assertThrowsExactly(
InvalidParameterValue.class,
() -> {
w.jobs().exportRun(123456789);
});
}

@Test
void cancelingNonExistingRun(WorkspaceClient w) {
assertThrowsExactly(
InvalidParameterValue.class,
() -> {
w.jobs().cancelRun(123456789);
});
}

@Test
void cancelingAllRunsFromNonExistingJob(WorkspaceClient w) {
assertThrowsExactly(
InvalidParameterValue.class,
() -> {
w.jobs().cancelAllRuns(new CancelAllRuns().setJobId(123456789L));
});
}

@Test
void repairingANonExistingRun(WorkspaceClient w) {
assertThrowsExactly(
InvalidParameterValue.class,
() -> {
w.jobs().repairRun(123456789);
});
}
}
Loading