use of org.pentaho.di.job.entry.JobEntryCopy in project pentaho-kettle by pentaho.
the class JobEntryColumnsExistTest method setUp.
@Before
public void setUp() {
Job parentJob = new Job(null, new JobMeta());
jobEntry = spy(new JobEntryColumnsExist(""));
parentJob.getJobMeta().addJobEntry(new JobEntryCopy(jobEntry));
parentJob.setStopped(false);
jobEntry.setParentJob(parentJob);
parentJob.setLogLevel(LogLevel.NOTHING);
DatabaseMeta dbMeta = mock(DatabaseMeta.class);
jobEntry.setDatabase(dbMeta);
db = spy(new Database(jobEntry, dbMeta));
jobEntry.setParentJob(parentJob);
jobEntry.setTablename(TABLENAME);
jobEntry.setArguments(COLUMNS);
jobEntry.setSchemaname(SCHEMANAME);
}
use of org.pentaho.di.job.entry.JobEntryCopy in project pentaho-kettle by pentaho.
the class JobEntryTransIntIT method testPDI14676.
/*
* Tests whether the job can force a transformation to stop, when the job is asked to stop.
* A timeout parameter is required, to avoid a failed unit test from running forever.
*/
@Test(timeout = 30000)
public void testPDI14676() throws KettleException, IOException, InterruptedException {
String transFilename = createPDI14676Transformation();
// Setup Job
JobEntrySpecial startEntry = new JobEntrySpecial("Start", true, false);
JobEntryCopy startCopy = new JobEntryCopy(startEntry);
startCopy.setLocation(50, 50);
startCopy.setDrawn();
JobEntryTrans transEntry = new JobEntryTrans("PDI-13676 example");
transEntry.setSpecificationMethod(ObjectLocationSpecificationMethod.FILENAME);
transEntry.setFileName(transFilename);
JobEntryCopy transCopy = new JobEntryCopy(transEntry);
transCopy.setLocation(200, 50);
transCopy.setDrawn();
JobMeta jobMeta = new JobMeta();
jobMeta.addJobEntry(startCopy);
jobMeta.addJobEntry(transCopy);
jobMeta.addJobHop(new JobHopMeta(startCopy, transCopy));
// Run job
Job jobInstance = new Job(null, jobMeta);
jobInstance.start();
// Allow job startup time
while (!jobInstance.isActive()) {
if (jobInstance.isStopped() || jobInstance.isFinished()) {
break;
}
Thread.sleep(10);
}
// Let the job run for a short period
Thread.sleep(300);
assertFalse(jobInstance.isStopped());
assertFalse(jobInstance.isFinished());
// Tell the job to stop.
jobInstance.stopAll();
assertTrue(jobInstance.isStopped());
// Allow the job's thread to stop and be cleaned up
while (!jobInstance.isFinished() || jobInstance.isActive()) {
Thread.sleep(10);
}
// Ensure that the job and the thread have both stopped
assertTrue(jobInstance.isFinished());
assertFalse(jobInstance.isAlive());
}
use of org.pentaho.di.job.entry.JobEntryCopy in project pentaho-kettle by pentaho.
the class RunConfigurationDelegateTest method testUpdateLoadedJobs_PDI16777.
@Test
public void testUpdateLoadedJobs_PDI16777() {
JobEntryTrans trans = new JobEntryTrans();
trans.setRunConfiguration("key");
JobMeta meta = new JobMeta();
meta.addJobEntry(new JobEntryCopy(trans));
JobMeta[] jobs = new JobMeta[] { meta };
doReturn(jobs).when(spoon).getLoadedJobs();
DefaultRunConfiguration config = new DefaultRunConfiguration();
config.setName("Test");
config.setServer("localhost");
delegate.updateLoadedJobs("key", config);
assertEquals("Test", trans.getRunConfiguration());
assertEquals("localhost", trans.getRemoteSlaveServerName());
}
use of org.pentaho.di.job.entry.JobEntryCopy in project pentaho-kettle by pentaho.
the class RunConfigurationImportExtensionPoint method createSlaveServerRunConfigurations.
private List<RunConfiguration> createSlaveServerRunConfigurations(List<String> existingConfigurationNames, AbstractMeta abstractMeta) {
List<RunConfiguration> runConfigurations = new ArrayList<>();
if (abstractMeta instanceof JobMeta) {
JobMeta jobMeta = (JobMeta) abstractMeta;
Map<String, List<JobEntryTrans>> slaveServerGroups = jobMeta.getJobCopies().stream().map(JobEntryCopy::getEntry).filter(entry -> entry instanceof JobEntryTrans).map(entry -> (JobEntryTrans) entry).filter(entry -> Utils.isEmpty(entry.getRunConfiguration())).filter(entry -> !Utils.isEmpty(entry.getRemoteSlaveServerName())).collect(Collectors.groupingBy(JobEntryTrans::getRemoteSlaveServerName));
slaveServerGroups.forEach((remoteServerName, entries) -> {
String runConfigurationName = createRunConfigurationName(existingConfigurationNames, remoteServerName);
DefaultRunConfiguration runConfiguration = createRunConfiguration(runConfigurationName, remoteServerName);
runConfigurations.add(runConfiguration);
entries.forEach(e -> e.setRunConfiguration(runConfiguration.getName()));
});
}
return runConfigurations;
}
use of org.pentaho.di.job.entry.JobEntryCopy in project pentaho-kettle by pentaho.
the class RunConfigurationImportExtensionPointTest method shouldCreateRunConfigurationsForSlaveServer.
@Test
public void shouldCreateRunConfigurationsForSlaveServer() throws Exception {
JobMeta jobMeta = mock(JobMeta.class);
JobEntryCopy jobEntryCopy1 = mock(JobEntryCopy.class);
JobEntryCopy jobEntryCopy2 = mock(JobEntryCopy.class);
JobEntryCopy jobEntryCopy3 = mock(JobEntryCopy.class);
JobEntryTrans trans1 = mock(JobEntryTrans.class);
JobEntryTrans trans2 = mock(JobEntryTrans.class);
JobEntryTrans trans3 = mock(JobEntryTrans.class);
ArgumentCaptor<DefaultRunConfiguration> rcCaptor = ArgumentCaptor.forClass(DefaultRunConfiguration.class);
when(jobMeta.getEmbeddedMetaStore()).thenReturn(embeddedMetaStore);
when(jobMeta.getSlaveServers()).thenReturn(Arrays.asList(new SlaveServer("carte1", "host1", "1234", "user", "passw"), new SlaveServer("carte2", "host2", "1234", "user", "passw")));
when(jobMeta.getJobCopies()).thenReturn(Arrays.asList(jobEntryCopy1, jobEntryCopy2, jobEntryCopy3));
when(jobEntryCopy1.getEntry()).thenReturn(trans1);
when(jobEntryCopy2.getEntry()).thenReturn(trans2);
when(jobEntryCopy3.getEntry()).thenReturn(trans3);
when(trans1.getRemoteSlaveServerName()).thenReturn("carte1");
when(trans2.getRemoteSlaveServerName()).thenReturn("carte1");
when(trans3.getRemoteSlaveServerName()).thenReturn("carte2");
when(trans1.getRunConfiguration()).thenReturn(null);
when(trans2.getRunConfiguration()).thenReturn(null);
when(trans3.getRunConfiguration()).thenReturn(null);
when(runConfigurationManager.getNames()).thenReturn(Collections.singletonList("pentaho_auto_carte1_config"));
runConfigurationImportExtensionPoint.callExtensionPoint(log, jobMeta);
verify(runConfigurationManager, times(2)).save(rcCaptor.capture());
verify(trans1).setRunConfiguration("pentaho_auto_carte1_config_1");
verify(trans2).setRunConfiguration("pentaho_auto_carte1_config_1");
verify(trans3).setRunConfiguration("pentaho_auto_carte2_config");
List<DefaultRunConfiguration> allValues = rcCaptor.getAllValues();
DefaultRunConfiguration runConfiguration1 = allValues.get(0);
assertEquals("pentaho_auto_carte1_config_1", runConfiguration1.getName());
assertEquals("carte1", runConfiguration1.getServer());
DefaultRunConfiguration runConfiguration2 = allValues.get(1);
assertEquals("pentaho_auto_carte2_config", runConfiguration2.getName());
assertEquals("carte2", runConfiguration2.getServer());
}
Aggregations