80 lines
2.2 KiB
Java
80 lines
2.2 KiB
Java
/**
|
|
*
|
|
*/
|
|
package org.gcube.aggregator.plugin;
|
|
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
import java.util.UUID;
|
|
|
|
import org.gcube.accounting.aggregator.plugin.AccountingAggregatorPluginDeclaration;
|
|
import org.gcube.testutility.ScopedTest;
|
|
import org.gcube.vremanagement.executor.api.types.LaunchParameter;
|
|
import org.gcube.vremanagement.executor.api.types.Scheduling;
|
|
import org.gcube.vremanagement.executor.client.plugins.ExecutorPlugin;
|
|
import org.gcube.vremanagement.executor.client.proxies.SmartExecutorProxy;
|
|
import org.junit.Assert;
|
|
import org.junit.Before;
|
|
import org.junit.Test;
|
|
import org.quartz.CronExpression;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
public class AggregatorAccountingPluginSmartExecutorSchedulerTest extends ScopedTest {
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(AggregatorAccountingPluginSmartExecutorSchedulerTest.class);
|
|
|
|
private SmartExecutorProxy proxy;
|
|
|
|
@Before
|
|
public void before() throws Exception{
|
|
proxy = ExecutorPlugin.getExecutorProxy(AccountingAggregatorPluginDeclaration.NAME).build();
|
|
Assert.assertNotNull(proxy);
|
|
|
|
}
|
|
|
|
private Map<String, Object> getInputs() throws Exception {
|
|
Map<String, Object> inputs = new HashMap<String, Object>();
|
|
|
|
|
|
return inputs;
|
|
}
|
|
|
|
private UUID launch(Scheduling scheduling) throws Exception {
|
|
Map<String, Object> inputs = new HashMap<String, Object>();
|
|
|
|
LaunchParameter launchParameter = new LaunchParameter(AccountingAggregatorPluginDeclaration.NAME, inputs);
|
|
launchParameter.setScheduling(scheduling);
|
|
|
|
try {
|
|
String uuidString = proxy.launch(launchParameter);
|
|
logger.debug("Launched with UUID : {}", uuidString);
|
|
return UUID.fromString(uuidString);
|
|
}catch (Exception e) {
|
|
logger.error("Error while launching {}", e);
|
|
throw e;
|
|
}
|
|
}
|
|
|
|
@Test
|
|
public void cronExpPreviousMustBeTerminated() throws Exception {
|
|
CronExpression cronExpression = new CronExpression("0 0 2 * * ?"); // every day at 2:00
|
|
Scheduling scheduling = new Scheduling(cronExpression, true);
|
|
scheduling.setGlobal(true);
|
|
UUID uuid = launch(scheduling);
|
|
|
|
}
|
|
|
|
|
|
@Test
|
|
public void unSchedule() throws Exception {
|
|
//proxy.unSchedule("", true);
|
|
}
|
|
|
|
@Test
|
|
public void stop() throws Exception {
|
|
proxy.stop(AccountingAggregatorPluginDeclaration.NAME);
|
|
}
|
|
|
|
}
|