mirror of
https://github.com/apache/sqoop.git
synced 2025-05-09 00:29:40 +08:00
SQOOP-2734: Sqoop2: Use job name in shell
(Colin Ma via Jarek Jarcec Cecho)
This commit is contained in:
parent
81778c37a4
commit
a53e682f08
@ -47,16 +47,16 @@ public class CloneJobFunction extends SqoopFunction {
|
||||
@SuppressWarnings("static-access")
|
||||
public CloneJobFunction() {
|
||||
this.addOption(OptionBuilder
|
||||
.withDescription(resourceString(Constants.RES_PROMPT_JOB_ID))
|
||||
.withLongOpt(Constants.OPT_JID)
|
||||
.withDescription(resourceString(Constants.RES_PROMPT_JOB_NAME))
|
||||
.withLongOpt(Constants.OPT_NAME)
|
||||
.isRequired()
|
||||
.hasArg()
|
||||
.create(Constants.OPT_JID_CHAR));
|
||||
.create(Constants.OPT_NAME_CHAR));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object executeFunction(CommandLine line, boolean isInteractive) throws IOException {
|
||||
return cloneJob(line.getOptionValue(Constants.OPT_JID), line.getArgList(), isInteractive);
|
||||
return cloneJob(line.getOptionValue(Constants.OPT_NAME), line.getArgList(), isInteractive);
|
||||
}
|
||||
|
||||
private Status cloneJob(String jobArg, List<String> args, boolean isInteractive) throws IOException {
|
||||
|
@ -131,7 +131,7 @@ private Status createJob(String fromLinkArg, String toLinkArg, List<String> args
|
||||
}
|
||||
|
||||
ConfigDisplayer.displayConfigWarning(job);
|
||||
printlnResource(Constants.RES_CREATE_JOB_SUCCESSFUL, status.name(), job.getPersistenceId());
|
||||
printlnResource(Constants.RES_CREATE_JOB_SUCCESSFUL, status.name(), job.getName());
|
||||
|
||||
return status;
|
||||
}
|
||||
|
@ -34,16 +34,16 @@ public class DeleteJobFunction extends SqoopFunction {
|
||||
@SuppressWarnings("static-access")
|
||||
public DeleteJobFunction() {
|
||||
this.addOption(OptionBuilder
|
||||
.withDescription(resourceString(Constants.RES_PROMPT_JOB_ID))
|
||||
.withLongOpt(Constants.OPT_JID)
|
||||
.withDescription(resourceString(Constants.RES_PROMPT_JOB_NAME))
|
||||
.withLongOpt(Constants.OPT_NAME)
|
||||
.isRequired()
|
||||
.hasArg()
|
||||
.create(Constants.OPT_JID_CHAR));
|
||||
.create(Constants.OPT_NAME_CHAR));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object executeFunction(CommandLine line, boolean isInteractive) {
|
||||
client.deleteJob(line.getOptionValue(Constants.OPT_JID));
|
||||
client.deleteJob(line.getOptionValue(Constants.OPT_NAME));
|
||||
return Status.OK;
|
||||
}
|
||||
}
|
||||
|
@ -34,16 +34,16 @@ public class DisableJobFunction extends SqoopFunction {
|
||||
@SuppressWarnings("static-access")
|
||||
public DisableJobFunction() {
|
||||
this.addOption(OptionBuilder
|
||||
.withDescription(resourceString(Constants.RES_PROMPT_JOB_ID))
|
||||
.withLongOpt(Constants.OPT_JID)
|
||||
.withDescription(resourceString(Constants.RES_PROMPT_JOB_NAME))
|
||||
.withLongOpt(Constants.OPT_NAME)
|
||||
.hasArg()
|
||||
.create('j'));
|
||||
.create(Constants.OPT_NAME_CHAR));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validateArgs(CommandLine line) {
|
||||
if (!line.hasOption(Constants.OPT_JID)) {
|
||||
printlnResource(Constants.RES_ARGS_JID_MISSING);
|
||||
if (!line.hasOption(Constants.OPT_NAME)) {
|
||||
printlnResource(Constants.RES_ARGS_NAME_MISSING);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -51,7 +51,7 @@ public boolean validateArgs(CommandLine line) {
|
||||
|
||||
@Override
|
||||
public Object executeFunction(CommandLine line, boolean isInteractive) {
|
||||
client.enableJob(line.getOptionValue(Constants.OPT_JID), false);
|
||||
client.enableJob(line.getOptionValue(Constants.OPT_NAME), false);
|
||||
return Status.OK;
|
||||
}
|
||||
}
|
||||
|
@ -34,16 +34,16 @@ public class EnableJobFunction extends SqoopFunction {
|
||||
@SuppressWarnings("static-access")
|
||||
public EnableJobFunction() {
|
||||
this.addOption(OptionBuilder
|
||||
.withDescription(resourceString(Constants.RES_PROMPT_JOB_ID))
|
||||
.withLongOpt(Constants.OPT_JID)
|
||||
.withDescription(resourceString(Constants.RES_PROMPT_JOB_NAME))
|
||||
.withLongOpt(Constants.OPT_NAME)
|
||||
.isRequired()
|
||||
.hasArg()
|
||||
.create('j'));
|
||||
.create(Constants.OPT_NAME_CHAR));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object executeFunction(CommandLine line, boolean isInteractive) {
|
||||
client.enableJob(line.getOptionValue(Constants.OPT_JID), true);
|
||||
client.enableJob(line.getOptionValue(Constants.OPT_NAME), true);
|
||||
return Status.OK;
|
||||
}
|
||||
}
|
||||
|
@ -51,10 +51,10 @@ public ShowJobFunction() {
|
||||
.withDescription(resourceString(Constants.RES_SHOW_PROMPT_DISPLAY_JOBS_CN))
|
||||
.withLongOpt(Constants.OPT_CONNECTOR_NAME)
|
||||
.create(Constants.OPT_CONNECTOR_NAME_CHAR));
|
||||
this.addOption(OptionBuilder.hasArg().withArgName(Constants.OPT_JID)
|
||||
.withDescription(resourceString(Constants.RES_SHOW_PROMPT_DISPLAY_JOB_JID))
|
||||
.withLongOpt(Constants.OPT_JID)
|
||||
.create(Constants.OPT_JID_CHAR));
|
||||
this.addOption(OptionBuilder.hasArg().withArgName(Constants.OPT_NAME)
|
||||
.withDescription(resourceString(Constants.RES_SHOW_PROMPT_DISPLAY_JOB_NAME))
|
||||
.withLongOpt(Constants.OPT_NAME)
|
||||
.create(Constants.OPT_NAME_CHAR));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -63,8 +63,8 @@ public Object executeFunction(CommandLine line, boolean isInteractive) {
|
||||
showJobs(null);
|
||||
} else if (line.hasOption(Constants.OPT_CONNECTOR_NAME)) {
|
||||
showJobs(line.getOptionValue(Constants.OPT_CONNECTOR_NAME));
|
||||
} else if (line.hasOption(Constants.OPT_JID)) {
|
||||
showJob(line.getOptionValue(Constants.OPT_JID));
|
||||
} else if (line.hasOption(Constants.OPT_NAME)) {
|
||||
showJob(line.getOptionValue(Constants.OPT_NAME));
|
||||
} else {
|
||||
showSummary();
|
||||
}
|
||||
@ -126,7 +126,6 @@ private void displayJob(MJob job) {
|
||||
|
||||
printlnResource(
|
||||
Constants.RES_SHOW_PROMPT_JOB_INFO,
|
||||
job.getPersistenceId(),
|
||||
job.getName(),
|
||||
job.getEnabled(),
|
||||
job.getCreationUser(),
|
||||
|
@ -34,16 +34,16 @@ public class ShowJobStatusFunction extends SqoopFunction {
|
||||
|
||||
@SuppressWarnings("static-access")
|
||||
public ShowJobStatusFunction() {
|
||||
this.addOption(OptionBuilder.hasArg().withArgName(Constants.OPT_JID)
|
||||
.withDescription(resourceString(Constants.RES_PROMPT_JOB_ID))
|
||||
.withLongOpt(Constants.OPT_JID)
|
||||
.create(Constants.OPT_JID_CHAR));
|
||||
this.addOption(OptionBuilder.hasArg().withArgName(Constants.OPT_NAME)
|
||||
.withDescription(resourceString(Constants.RES_PROMPT_JOB_NAME))
|
||||
.withLongOpt(Constants.OPT_NAME)
|
||||
.create(Constants.OPT_NAME_CHAR));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object executeFunction(CommandLine line, boolean isInteractive) {
|
||||
if (line.hasOption(Constants.OPT_JID)) {
|
||||
MSubmission submission = client.getJobStatus(line.getOptionValue(Constants.OPT_JID));
|
||||
if (line.hasOption(Constants.OPT_NAME)) {
|
||||
MSubmission submission = client.getJobStatus(line.getOptionValue(Constants.OPT_NAME));
|
||||
if(submission.getStatus().isFailure() || submission.getStatus().equals(SubmissionStatus.SUCCEEDED)) {
|
||||
SubmissionDisplayer.displayHeader(submission);
|
||||
SubmissionDisplayer.displayFooter(submission);
|
||||
|
@ -40,23 +40,23 @@ public ShowSubmissionFunction() {
|
||||
.withDescription(resourceString(Constants.RES_SHOW_PROMPT_DISPLAY_ALL_SUBMISSIONS))
|
||||
.withLongOpt(Constants.OPT_DETAIL)
|
||||
.create(Constants.OPT_DETAIL_CHAR));
|
||||
this.addOption(OptionBuilder.hasArg().withArgName(Constants.OPT_JID)
|
||||
.withDescription(resourceString(Constants.RES_SHOW_PROMPT_DISPLAY_ALL_SUBMISSIONS_JOB_ID))
|
||||
.withLongOpt(Constants.OPT_JID)
|
||||
.create(Constants.OPT_JID_CHAR));
|
||||
this.addOption(OptionBuilder.hasArg().withArgName(Constants.OPT_WITH_JOB)
|
||||
.withDescription(resourceString(Constants.RES_SHOW_PROMPT_DISPLAY_ALL_SUBMISSIONS_JN))
|
||||
.withLongOpt(Constants.OPT_WITH_JOB)
|
||||
.create(Constants.OPT_WITH_JOB_CHAR));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object executeFunction(CommandLine line, boolean isInteractive) {
|
||||
if (line.hasOption(Constants.OPT_DETAIL)) {
|
||||
if (line.hasOption(Constants.OPT_JID)) {
|
||||
showSubmissions(line.getOptionValue(Constants.OPT_JID));
|
||||
if (line.hasOption(Constants.OPT_WITH_JOB)) {
|
||||
showSubmissions(line.getOptionValue(Constants.OPT_WITH_JOB));
|
||||
} else {
|
||||
showSubmissions(null);
|
||||
}
|
||||
} else {
|
||||
if (line.hasOption(Constants.OPT_JID)) {
|
||||
showSummary(line.getOptionValue(Constants.OPT_JID));
|
||||
if (line.hasOption(Constants.OPT_WITH_JOB)) {
|
||||
showSummary(line.getOptionValue(Constants.OPT_WITH_JOB));
|
||||
} else {
|
||||
showSummary(null);
|
||||
}
|
||||
|
@ -39,10 +39,10 @@ public class StartJobFunction extends SqoopFunction {
|
||||
|
||||
@SuppressWarnings("static-access")
|
||||
public StartJobFunction() {
|
||||
this.addOption(OptionBuilder.hasArg().withArgName(Constants.OPT_JID)
|
||||
.withDescription(resourceString(Constants.RES_PROMPT_JOB_ID))
|
||||
.withLongOpt(Constants.OPT_JID)
|
||||
.create(Constants.OPT_JID_CHAR));
|
||||
this.addOption(OptionBuilder.hasArg().withArgName(Constants.OPT_NAME)
|
||||
.withDescription(resourceString(Constants.RES_PROMPT_JOB_NAME))
|
||||
.withLongOpt(Constants.OPT_NAME)
|
||||
.create(Constants.OPT_NAME_CHAR));
|
||||
this.addOption(OptionBuilder
|
||||
.withDescription(resourceString(Constants.RES_PROMPT_SYNCHRONOUS))
|
||||
.withLongOpt(Constants.OPT_SYNCHRONOUS)
|
||||
@ -52,18 +52,16 @@ public StartJobFunction() {
|
||||
@Override
|
||||
public Object executeFunction(CommandLine line, boolean isInteractive) {
|
||||
// Poll until finished
|
||||
if (line.hasOption(Constants.OPT_SYNCHRONOUS) && line.hasOption(Constants.OPT_JID)) {
|
||||
if (line.hasOption(Constants.OPT_SYNCHRONOUS) && line.hasOption(Constants.OPT_NAME)) {
|
||||
long pollTimeout = getPollTimeout();
|
||||
|
||||
try {
|
||||
//client.startJob(getLong(line, Constants.OPT_JID), callback, pollTimeout);
|
||||
client.startJob(line.getOptionValue(Constants.OPT_JID), new SJFCallback(), pollTimeout);
|
||||
client.startJob(line.getOptionValue(Constants.OPT_NAME), new SJFCallback(), pollTimeout);
|
||||
} catch (InterruptedException e) {
|
||||
throw new SqoopException(ShellError.SHELL_0007, e);
|
||||
}
|
||||
} else if (line.hasOption(Constants.OPT_JID)) {
|
||||
//MSubmission submission = client.startJob(getLong(line, Constants.OPT_JID));
|
||||
MSubmission submission = client.startJob(line.getOptionValue(Constants.OPT_JID));
|
||||
} else if (line.hasOption(Constants.OPT_NAME)) {
|
||||
MSubmission submission = client.startJob(line.getOptionValue(Constants.OPT_NAME));
|
||||
if(submission.getStatus().isFailure()) {
|
||||
SubmissionDisplayer.displayFooter(submission);
|
||||
} else {
|
||||
|
@ -33,17 +33,16 @@ public class StopJobFunction extends SqoopFunction {
|
||||
|
||||
@SuppressWarnings("static-access")
|
||||
public StopJobFunction() {
|
||||
this.addOption(OptionBuilder.hasArg().withArgName(Constants.OPT_JID)
|
||||
.withDescription(resourceString(Constants.RES_PROMPT_JOB_ID))
|
||||
.withLongOpt(Constants.OPT_JID)
|
||||
.create(Constants.OPT_JID_CHAR));
|
||||
this.addOption(OptionBuilder.hasArg().withArgName(Constants.OPT_NAME)
|
||||
.withDescription(resourceString(Constants.RES_PROMPT_JOB_NAME))
|
||||
.withLongOpt(Constants.OPT_NAME)
|
||||
.create(Constants.OPT_NAME_CHAR));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object executeFunction(CommandLine line, boolean isInteractive) {
|
||||
if (line.hasOption(Constants.OPT_JID)) {
|
||||
//MSubmission submission = client.stopJob(getLong(line, Constants.OPT_JID));
|
||||
MSubmission submission = client.stopJob(line.getOptionValue(Constants.OPT_JID));
|
||||
if (line.hasOption(Constants.OPT_NAME)) {
|
||||
MSubmission submission = client.stopJob(line.getOptionValue(Constants.OPT_NAME));
|
||||
if(submission.getStatus().isFailure()) {
|
||||
SubmissionDisplayer.displayFooter(submission);
|
||||
} else {
|
||||
|
@ -47,17 +47,17 @@ public class UpdateJobFunction extends SqoopFunction {
|
||||
@SuppressWarnings("static-access")
|
||||
public UpdateJobFunction() {
|
||||
this.addOption(OptionBuilder
|
||||
.withDescription(resourceString(Constants.RES_PROMPT_JOB_ID))
|
||||
.withLongOpt(Constants.OPT_JID)
|
||||
.withDescription(resourceString(Constants.RES_PROMPT_JOB_NAME))
|
||||
.withLongOpt(Constants.OPT_NAME)
|
||||
.isRequired()
|
||||
.hasArg()
|
||||
.create(Constants.OPT_JID_CHAR));
|
||||
.create(Constants.OPT_NAME_CHAR));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object executeFunction(CommandLine line, boolean isInteractive) throws IOException {
|
||||
return updateJob(line.getOptionValue(Constants.OPT_JID), line.getArgList(), isInteractive);
|
||||
return updateJob(line.getOptionValue(Constants.OPT_NAME), line.getArgList(), isInteractive);
|
||||
}
|
||||
|
||||
private Status updateJob(String jobArg, List<String> args, boolean isInteractive) throws IOException {
|
||||
|
@ -38,7 +38,6 @@ public class Constants {
|
||||
public static final String OPT_FROM = "from";
|
||||
public static final String OPT_TO = "to";
|
||||
public static final String OPT_ALL = "all";
|
||||
public static final String OPT_JID = "jid";
|
||||
public static final String OPT_NAME = "name";
|
||||
public static final String OPT_CONNECTOR_NAME = "connector";
|
||||
public static final String OPT_VALUE = "value";
|
||||
@ -60,12 +59,12 @@ public class Constants {
|
||||
public static final String OPT_PRINCIPAL = "principal";
|
||||
public static final String OPT_PRINCIPAL_TYPE = "principal-type";
|
||||
public static final String OPT_WITH_GRANT = "with-grant";
|
||||
public static final String OPT_WITH_JOB = "job";
|
||||
|
||||
public static final char OPT_LID_CHAR = 'l';
|
||||
public static final char OPT_FROM_CHAR = 'f';
|
||||
public static final char OPT_TO_CHAR = 't';
|
||||
public static final char OPT_ALL_CHAR = 'a';
|
||||
public static final char OPT_JID_CHAR = 'j';
|
||||
public static final char OPT_NAME_CHAR = 'n';
|
||||
public static final char OPT_CONNECTOR_NAME_CHAR = 'c';
|
||||
public static final char OPT_VALUE_CHAR = 'v';
|
||||
@ -82,6 +81,7 @@ public class Constants {
|
||||
public static final char OPT_ROLE_CHAR = 'r';
|
||||
public static final char OPT_ACTION_CHAR = 'a';
|
||||
public static final char OPT_WITH_GRANT_CHAR = 'g';
|
||||
public static final char OPT_WITH_JOB_CHAR = 'j';
|
||||
|
||||
// Resource keys for various commands, command options,
|
||||
// functions and descriptions
|
||||
@ -164,8 +164,8 @@ public class Constants {
|
||||
|
||||
public static final String RES_PROMPT_LINK_ID =
|
||||
"prompt.link_id";
|
||||
public static final String RES_PROMPT_JOB_ID =
|
||||
"prompt.job_id";
|
||||
public static final String RES_PROMPT_JOB_NAME =
|
||||
"prompt.job_name";
|
||||
public static final String RES_CONNECTOR_NAME =
|
||||
"prompt.connector_name";
|
||||
public static final String RES_PROMPT_UPDATE_LINK_CONFIG =
|
||||
@ -288,8 +288,8 @@ public class Constants {
|
||||
"show.prompt_display_all_jobs";
|
||||
public static final String RES_SHOW_PROMPT_DISPLAY_JOBS_CN =
|
||||
"show.prompt_display_all_jobs_cn";
|
||||
public static final String RES_SHOW_PROMPT_DISPLAY_JOB_JID =
|
||||
"show.prompt_display_job_jid";
|
||||
public static final String RES_SHOW_PROMPT_DISPLAY_JOB_NAME =
|
||||
"show.prompt_display_job_name";
|
||||
public static final String RES_SHOW_PROMPT_JOBS_TO_SHOW =
|
||||
"show.prompt_jobs_to_show";
|
||||
public static final String RES_SHOW_PROMPT_JOB_INFO =
|
||||
@ -301,8 +301,8 @@ public class Constants {
|
||||
|
||||
public static final String RES_SHOW_PROMPT_DISPLAY_ALL_SUBMISSIONS =
|
||||
"show.prompt_display_all_submissions";
|
||||
public static final String RES_SHOW_PROMPT_DISPLAY_ALL_SUBMISSIONS_JOB_ID =
|
||||
"show.prompt_display_all_submissions_jid";
|
||||
public static final String RES_SHOW_PROMPT_DISPLAY_ALL_SUBMISSIONS_JN =
|
||||
"show.prompt_display_all_submissions_jn";
|
||||
|
||||
public static final String RES_SHOW_PROMPT_DISPLAY_ALL_SERVERS =
|
||||
"show.prompt_display_all_servers";
|
||||
|
@ -43,7 +43,7 @@ args.value_missing = Required argument --value is missing.
|
||||
## Generic description of various ids, types etc
|
||||
prompt.link_id = Link Id
|
||||
prompt.connector_name = Connector Name
|
||||
prompt.job_id = Job Id
|
||||
prompt.job_name = Job Name
|
||||
prompt.job_type = Job type
|
||||
|
||||
## Prompt messages for updating, filling entity info
|
||||
@ -58,7 +58,7 @@ job object
|
||||
# Update command
|
||||
update.description = Update objects in Sqoop repository
|
||||
update.link = Updating link with id {0}
|
||||
update.job = Updating job with id {0}
|
||||
update.job = Updating job with name {0}
|
||||
update.link_successful = link was successfully updated with status {0}
|
||||
update.job_successful = Job was successfully updated with status {0}
|
||||
|
||||
@ -69,14 +69,14 @@ clone.link.successful = link was successfully created with validation \
|
||||
clone.job.successful = Job was successfully created with validation \
|
||||
status {0} and persistent id {1}
|
||||
clone.cloning_link = Cloning link with id {0}
|
||||
clone.cloning_job = Cloning job with id {0}
|
||||
clone.cloning_job = Cloning job with name {0}
|
||||
|
||||
# Create command
|
||||
create.description = Create new object in Sqoop repository
|
||||
create.link_successful = New link was successfully created with \
|
||||
validation status {0} and persistent id {1}
|
||||
create.job_successful = New job was successfully created with validation \
|
||||
status {0} and persistent id {1}
|
||||
status {0} and name {1}
|
||||
create.role_successful = New role was successfully created with name {0}
|
||||
create.creating_link = Creating link for connector with name {0}
|
||||
create.creating_job = Creating job for links with from id {0} and to id {1}
|
||||
@ -149,15 +149,15 @@ show.prompt_driver_opts = @|bold Driver specific options: |@\nPersistent id: {0}
|
||||
|
||||
show.prompt_display_all_jobs = Display all jobs
|
||||
show.prompt_display_all_jobs_cn = Display all jobs with given connector name
|
||||
show.prompt_display_job_jid = Display job with given jid
|
||||
show.prompt_display_job_name = Display job with given name
|
||||
show.job_usage = Usage: show job
|
||||
show.prompt_jobs_to_show = @|bold {0} job(s) to show: |@
|
||||
show.prompt_job_info = Job with id {0} and name {1} (Enabled: {2}, Created by {3} at {4}, Updated by {5} at {6})
|
||||
show.prompt_job_info = Job with name {0} (Enabled: {1}, Created by {2} at {3}, Updated by {4} at {5})
|
||||
show.prompt_job_from_lid_info = From link: {0}
|
||||
show.prompt_job_to_lid_info = To link: {0}
|
||||
|
||||
show.prompt_display_all_submissions = Display all submissions
|
||||
show.prompt_display_all_submissions_jid = Display all submissions given jid
|
||||
show.prompt_display_all_submissions_jn = Display all submissions given job name
|
||||
|
||||
show.prompt_display_all_servers = Display all server information
|
||||
show.prompt_display_server_host = Display server host name
|
||||
|
@ -165,23 +165,23 @@ public void testCloneJob() {
|
||||
when(client.saveJob(job)).thenReturn(Status.OK);
|
||||
when(client.getConnector(any(Long.class))).thenReturn(new MConnector("", "", "", null, null, null));
|
||||
|
||||
// clone job -jid job_test
|
||||
Status status = (Status) cloneCmd.execute(Arrays.asList(Constants.FN_JOB, "-jid", "job_test"));
|
||||
// clone job -name job_test
|
||||
Status status = (Status) cloneCmd.execute(Arrays.asList(Constants.FN_JOB, "-name", "job_test"));
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
|
||||
// Missing argument for option jid
|
||||
// Missing argument for option name
|
||||
try {
|
||||
cloneCmd.execute(Arrays.asList(Constants.FN_JOB, "-jid"));
|
||||
cloneCmd.execute(Arrays.asList(Constants.FN_JOB, "-name"));
|
||||
fail("Update job should fail as parameters aren't complete!");
|
||||
} catch (SqoopException e) {
|
||||
assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
assertTrue(e.getMessage().contains("Missing argument for option"));
|
||||
}
|
||||
|
||||
// Missing option jid
|
||||
// Missing option name
|
||||
try {
|
||||
cloneCmd.execute(Arrays.asList(Constants.FN_JOB));
|
||||
fail("Update job should fail as option jid is missing");
|
||||
fail("Update job should fail as option name is missing");
|
||||
} catch (SqoopException e) {
|
||||
assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
assertTrue(e.getMessage().contains("Missing required option"));
|
||||
@ -201,7 +201,7 @@ public void testCloneJobInteractive() {
|
||||
when(client.getDriverConfigBundle()).thenReturn(resourceBundle);
|
||||
when(client.saveJob(job)).thenReturn(Status.OK);
|
||||
|
||||
// clone job -jid job_test
|
||||
// clone job -name job_test
|
||||
initData("jobname\r" + // job name
|
||||
// From job config
|
||||
"abc\r" + // for input with name "String"
|
||||
@ -232,7 +232,7 @@ public void testCloneJobInteractive() {
|
||||
"0\r" + // for input with name "Enum"
|
||||
"l1\rl2\rl3\r\r" + // for input with name "List"
|
||||
"7654321\r"); // for input with name "DateTime"
|
||||
Status status = (Status) cloneCmd.execute(Arrays.asList(Constants.FN_JOB, "-jid", "job_test"));
|
||||
Status status = (Status) cloneCmd.execute(Arrays.asList(Constants.FN_JOB, "-name", "job_test"));
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
assertEquals(job.getName(), "jobname");
|
||||
// check from job config
|
||||
|
@ -84,14 +84,14 @@ public void testDeleteLinkWithNonExistingLink() {
|
||||
public void testDeleteJob() {
|
||||
doNothing().when(client).deleteJob("job_test");
|
||||
|
||||
// delete job -j job_test
|
||||
Status status = (Status) deleteCmd.execute(Arrays.asList(Constants.FN_JOB, "-j", "job_test"));
|
||||
// delete job -name job_test
|
||||
Status status = (Status) deleteCmd.execute(Arrays.asList(Constants.FN_JOB, "-name", "job_test"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
|
||||
// Missing argument for option jid
|
||||
// Missing argument for option name
|
||||
try {
|
||||
status = (Status) deleteCmd.execute(Arrays.asList(Constants.FN_JOB, "-jid"));
|
||||
Assert.fail("Delete job should fail as job id/name is missing!");
|
||||
status = (Status) deleteCmd.execute(Arrays.asList(Constants.FN_JOB, "-name"));
|
||||
Assert.fail("Delete job should fail as job name is missing!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
Assert.assertTrue(e.getMessage().contains("Missing argument for option"));
|
||||
@ -103,7 +103,7 @@ public void testDeleteJobWithNonExistingJob() {
|
||||
doThrow(new SqoopException(TestShellError.TEST_SHELL_0000, "job doesn't exist")).when(client).deleteJob(any(String.class));
|
||||
|
||||
try {
|
||||
deleteCmd.execute(Arrays.asList(Constants.FN_JOB, "-jid", "job_test"));
|
||||
deleteCmd.execute(Arrays.asList(Constants.FN_JOB, "-name", "job_test"));
|
||||
Assert.fail("Delete job should fail as requested job doesn't exist!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(TestShellError.TEST_SHELL_0000, e.getErrorCode());
|
||||
|
@ -84,13 +84,13 @@ public void testDisableJob() {
|
||||
doNothing().when(client).enableJob("job_test", false);
|
||||
|
||||
// disable job -j job_test
|
||||
Status status = (Status) disableCmd.execute(Arrays.asList(Constants.FN_JOB, "-j", "job_test"));
|
||||
Status status = (Status) disableCmd.execute(Arrays.asList(Constants.FN_JOB, "-name", "job_test"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
|
||||
// Missing argument for option jid
|
||||
// Missing argument for option name
|
||||
try {
|
||||
status = (Status) disableCmd.execute(Arrays.asList(Constants.FN_JOB, "-jid"));
|
||||
Assert.fail("Disable job should fail as job id/name is missing!");
|
||||
status = (Status) disableCmd.execute(Arrays.asList(Constants.FN_JOB, "-name"));
|
||||
Assert.fail("Disable job should fail as job name is missing!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
Assert.assertTrue(e.getMessage().contains("Missing argument for option"));
|
||||
@ -102,7 +102,7 @@ public void testDisableJobWithNonExistingJob() {
|
||||
doThrow(new SqoopException(TestShellError.TEST_SHELL_0000, "job doesn't exist")).when(client).enableJob(any(String.class), any(Boolean.class));
|
||||
|
||||
try {
|
||||
disableCmd.execute(Arrays.asList(Constants.FN_JOB, "-jid", "job_test"));
|
||||
disableCmd.execute(Arrays.asList(Constants.FN_JOB, "-name", "job_test"));
|
||||
Assert.fail("Disable job should fail as requested job doesn't exist!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(TestShellError.TEST_SHELL_0000, e.getErrorCode());
|
||||
|
@ -84,12 +84,12 @@ public void testEnableJob() {
|
||||
doNothing().when(client).enableJob("job_test", true);
|
||||
|
||||
// enable job -j job_test
|
||||
Status status = (Status) enableCmd.execute(Arrays.asList(Constants.FN_JOB, "-j", "job_test"));
|
||||
Status status = (Status) enableCmd.execute(Arrays.asList(Constants.FN_JOB, "-name", "job_test"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
|
||||
// Missing argument for option jid
|
||||
// Missing argument for option name
|
||||
try {
|
||||
status = (Status) enableCmd.execute(Arrays.asList(Constants.FN_JOB, "-jid"));
|
||||
status = (Status) enableCmd.execute(Arrays.asList(Constants.FN_JOB, "-name"));
|
||||
Assert.fail("Enable job should fail as job id/name is missing!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
@ -102,7 +102,7 @@ public void testEnableJobWithNonExistingJob() {
|
||||
doThrow(new SqoopException(TestShellError.TEST_SHELL_0000, "job doesn't exist")).when(client).enableJob(any(String.class), any(Boolean.class));
|
||||
|
||||
try {
|
||||
enableCmd.execute(Arrays.asList(Constants.FN_JOB, "-jid", "job_test"));
|
||||
enableCmd.execute(Arrays.asList(Constants.FN_JOB, "-name", "job_test"));
|
||||
Assert.fail("Enable job should fail as requested job doesn't exist!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(TestShellError.TEST_SHELL_0000, e.getErrorCode());
|
||||
|
@ -233,7 +233,7 @@ public void testShowLink() {
|
||||
public void testShowJob() {
|
||||
when(client.getJobs()).thenReturn(new ArrayList<MJob>());
|
||||
when(client.getConnector(any(Long.class))).thenReturn(new MConnector("", "", "", null, null, null));
|
||||
when(client.getJob("1")).thenReturn(new MJob("fromConnectorName", "toConnectorName", "linkName1", "linkName2",
|
||||
when(client.getJob("jobName")).thenReturn(new MJob("fromConnectorName", "toConnectorName", "linkName1", "linkName2",
|
||||
new MFromConfig(new ArrayList<MConfig>(), new ArrayList<MValidator>()),
|
||||
new MToConfig(new ArrayList<MConfig>(), new ArrayList<MValidator>()),
|
||||
new MDriverConfig(new ArrayList<MConfig>(), new ArrayList<MValidator>())));
|
||||
@ -260,12 +260,12 @@ public void testShowJob() {
|
||||
str = new String(out.toByteArray());
|
||||
Assert.assertTrue(str.contains("job(s) to show:"));
|
||||
|
||||
// show job -jid 1
|
||||
// show job -name jobName
|
||||
out.reset();
|
||||
status = (Status) showCmd.execute(Arrays.asList(Constants.FN_JOB, "-jid", "1"));
|
||||
status = (Status) showCmd.execute(Arrays.asList(Constants.FN_JOB, "-name", "jobName"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
str = new String(out.toByteArray());
|
||||
Assert.assertTrue(str.contains("Job with id"));
|
||||
Assert.assertTrue(str.contains("Job with name"));
|
||||
|
||||
// show job -connector fromConnectorName
|
||||
out.reset();
|
||||
@ -280,9 +280,9 @@ public void testShowSubmission() {
|
||||
when(client.getSubmissions()).thenReturn(Arrays.asList(new MSubmission(1L)));
|
||||
when(client.getSubmissionsForJob(any(String.class))).thenReturn(Arrays.asList(new MSubmission(1L)));
|
||||
|
||||
// show submission -details -jid 1
|
||||
// show submission -details -name jobName
|
||||
out.reset();
|
||||
Status status = (Status) showCmd.execute(Arrays.asList(Constants.FN_SUBMISSION, "-detail", "-jid", "1"));
|
||||
Status status = (Status) showCmd.execute(Arrays.asList(Constants.FN_SUBMISSION, "-detail", "-name", "jobName"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
String str = new String(out.toByteArray());
|
||||
Assert.assertTrue(str.contains("Submission details"));
|
||||
@ -294,9 +294,9 @@ public void testShowSubmission() {
|
||||
str = new String(out.toByteArray());
|
||||
Assert.assertTrue(str.contains("Submission details"));
|
||||
|
||||
// show submission -jid 1
|
||||
// show submission -job jobName
|
||||
out.reset();
|
||||
status = (Status) showCmd.execute(Arrays.asList(Constants.FN_SUBMISSION, "-jid", "1"));
|
||||
status = (Status) showCmd.execute(Arrays.asList(Constants.FN_SUBMISSION, "-job", "jobName"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
str = new String(out.toByteArray());
|
||||
Assert.assertTrue(str.contains("Job Id"));
|
||||
|
@ -55,13 +55,13 @@ public void testStartJobSynchronousDisabled() throws InterruptedException {
|
||||
MSubmission submission = new MSubmission();
|
||||
when(client.startJob(any(String.class))).thenReturn(submission);
|
||||
|
||||
// start job -jid job_test
|
||||
Status status = (Status) startCmd.execute(Arrays.asList(Constants.FN_JOB, "-jid", "job_test"));
|
||||
// start job -name job_test
|
||||
Status status = (Status) startCmd.execute(Arrays.asList(Constants.FN_JOB, "-name", "job_test"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
|
||||
// Missing argument for jid
|
||||
// Missing argument for name
|
||||
try {
|
||||
startCmd.execute(Arrays.asList(Constants.FN_JOB, "-jid"));
|
||||
startCmd.execute(Arrays.asList(Constants.FN_JOB, "-name"));
|
||||
Assert.fail("Start job should fail as parameters aren't complete!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
@ -73,8 +73,8 @@ public void testStartJobSynchronousDisabled() throws InterruptedException {
|
||||
public void testStartJobSynchronousEnabled() throws InterruptedException {
|
||||
when(client.startJob(any(String.class), any(SubmissionCallback.class), any(Long.class))).thenReturn(null);
|
||||
|
||||
// start job -jid job_test -synchronous
|
||||
Status status = (Status) startCmd.execute(Arrays.asList(Constants.FN_JOB, "-jid", "job_test", "-synchronous"));
|
||||
// start job -name job_test -synchronous
|
||||
Status status = (Status) startCmd.execute(Arrays.asList(Constants.FN_JOB, "-name", "job_test", "-synchronous"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
}
|
||||
}
|
||||
|
@ -54,13 +54,13 @@ public void testGetJobStatus() {
|
||||
MSubmission submission = new MSubmission();
|
||||
when(client.getJobStatus(any(String.class))).thenReturn(submission);
|
||||
|
||||
// status job -jid job_test
|
||||
Status status = (Status) statusCmd.execute(Arrays.asList(Constants.FN_JOB, "-jid", "job_test"));
|
||||
// status job -name job_test
|
||||
Status status = (Status) statusCmd.execute(Arrays.asList(Constants.FN_JOB, "-name", "job_test"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
|
||||
// Missing argument for jid
|
||||
// Missing argument for name
|
||||
try {
|
||||
statusCmd.execute(Arrays.asList(Constants.FN_JOB, "-jid"));
|
||||
statusCmd.execute(Arrays.asList(Constants.FN_JOB, "-name"));
|
||||
Assert.fail("Get job status should fail as parameters aren't complete!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
|
@ -54,13 +54,13 @@ public void testStopJob() {
|
||||
MSubmission submission = new MSubmission();
|
||||
when(client.stopJob(any(String.class))).thenReturn(submission);
|
||||
|
||||
// stop job -jid job_test
|
||||
Status status = (Status) stopCmd.execute(Arrays.asList(Constants.FN_JOB, "-jid", "job_test"));
|
||||
// stop job -name job_test
|
||||
Status status = (Status) stopCmd.execute(Arrays.asList(Constants.FN_JOB, "-name", "job_test"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
|
||||
// Missing argument for jid
|
||||
// Missing argument for name
|
||||
try {
|
||||
stopCmd.execute(Arrays.asList(Constants.FN_JOB, "-jid"));
|
||||
stopCmd.execute(Arrays.asList(Constants.FN_JOB, "-name"));
|
||||
Assert.fail("Stop job should fail as parameters aren't complete!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
|
@ -183,23 +183,23 @@ public void testUpdateJob() throws InterruptedException {
|
||||
when(client.getDriverConfigBundle()).thenReturn(new MapResourceBundle(new HashMap()));
|
||||
when(client.updateJob(job)).thenReturn(Status.OK);
|
||||
|
||||
// update job -jid job_test
|
||||
Status status = (Status) updateCmd.execute(Arrays.asList(Constants.FN_JOB, "-jid", "job_test"));
|
||||
// update job -name job_test
|
||||
Status status = (Status) updateCmd.execute(Arrays.asList(Constants.FN_JOB, "-name", "job_test"));
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
|
||||
// Missing argument for option jid
|
||||
// Missing argument for option name
|
||||
try {
|
||||
updateCmd.execute(Arrays.asList(Constants.FN_JOB, "-jid"));
|
||||
updateCmd.execute(Arrays.asList(Constants.FN_JOB, "-name"));
|
||||
fail("Update job should fail as parameters aren't complete!");
|
||||
} catch (SqoopException e) {
|
||||
assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
assertTrue(e.getMessage().contains("Missing argument for option"));
|
||||
}
|
||||
|
||||
// Missing option jid
|
||||
// Missing option name
|
||||
try {
|
||||
updateCmd.execute(Arrays.asList(Constants.FN_JOB));
|
||||
fail("Update job should fail as option jid is missing");
|
||||
fail("Update job should fail as option name is missing");
|
||||
} catch (SqoopException e) {
|
||||
assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
assertTrue(e.getMessage().contains("Missing required option"));
|
||||
@ -220,7 +220,7 @@ public void testUpdateJobInteractive() {
|
||||
when(client.getDriverConfigBundle()).thenReturn(resourceBundle);
|
||||
when(client.updateJob(job)).thenReturn(Status.OK);
|
||||
|
||||
// update job -jid job_test
|
||||
// update job -name job_test
|
||||
initData("jobname\r" + // job name
|
||||
// From job config
|
||||
"abc\r" + // for input with name "String"
|
||||
@ -251,7 +251,7 @@ public void testUpdateJobInteractive() {
|
||||
"0\r" + // for input with name "Enum"
|
||||
"l1\rl2\rl3\r\r" + // for input with name "List"
|
||||
"7654321\r"); // for input with name "DateTime"
|
||||
Status status = (Status) updateCmd.execute(Arrays.asList(Constants.FN_JOB, "-jid", "job_test"));
|
||||
Status status = (Status) updateCmd.execute(Arrays.asList(Constants.FN_JOB, "-name", "job_test"));
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
assertEquals(job.getName(), "jobname");
|
||||
// check from job config
|
||||
|
Loading…
Reference in New Issue
Block a user