Skip to content
This repository has been archived by the owner on Oct 29, 2019. It is now read-only.

Commit

Permalink
Fix Shutdown through SigTerm
Browse files Browse the repository at this point in the history
- Fix Shutdown through Sigterm (add Junit too)
- Fix Commander incorrect request to get Submitted tasks
  • Loading branch information
fredericBregier committed Aug 19, 2019
1 parent 944b89e commit 515a94d
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 71 deletions.
29 changes: 28 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,34 @@
<version>1.10.6</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jnr-posix</artifactId>
<version>3.0.50</version>
<!-- For Testing purpose but could be used in production too -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<version>1.10.6</version>
<!-- For Testing purpose but could be used in production too -->
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>Waarp</groupId>
<artifactId>WaarpCommon</artifactId>
<classifier>tests</classifier>
<type>test-jar</type>
<version>3.1.1</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1550,7 +1550,7 @@ public static DbTaskRunner[] getSelectFromInfoPrepareStatement(
List<Filter> filters = new ArrayList<Filter>(3);
filters.add(new Filter(DBTransferDAO.UPDATED_INFO_FIELD, "=",
org.waarp.openr66.pojo.UpdatedInfo.fromLegacy(info).ordinal()));
filters.add(new Filter(DBTransferDAO.TRANSFER_START_FIELD, "=",
filters.add(new Filter(DBTransferDAO.TRANSFER_START_FIELD, "<=",
new Timestamp(System.currentTimeMillis())));
filters.add(new Filter(DBTransferDAO.OWNER_REQUEST_FIELD, "=",
Configuration.configuration.getHOST_ID()));
Expand Down
68 changes: 0 additions & 68 deletions src/test/java/org/waarp/openr66/protocol/junit/AllTasksTest.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,20 @@
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;
import org.apache.thrift.transport.TTransportException;
import org.apache.tools.ant.Project;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import org.waarp.common.command.exception.CommandAbstractException;
import org.waarp.common.database.DbPreparedStatement;
import org.waarp.common.database.exception.WaarpDatabaseException;
import org.waarp.common.database.exception.WaarpDatabaseNoConnectionException;
import org.waarp.common.database.exception.WaarpDatabaseSqlException;
import org.waarp.common.digest.FilesystemBasedDigest;
import org.waarp.common.utility.Processes;
import org.waarp.openr66.client.Message;
import org.waarp.openr66.client.MultipleDirectTransfer;
import org.waarp.openr66.client.MultipleSubmitTransfer;
Expand All @@ -50,6 +53,7 @@
import org.waarp.openr66.context.ErrorCode;
import org.waarp.openr66.context.R66FiniteDualStates;
import org.waarp.openr66.context.R66Result;
import org.waarp.openr66.context.task.exception.OpenR66RunnerErrorException;
import org.waarp.openr66.context.task.test.TestExecJavaTask;
import org.waarp.openr66.database.DbConstant;
import org.waarp.openr66.database.data.DbHostAuth;
Expand Down Expand Up @@ -83,10 +87,12 @@
import org.waarp.openr66.protocol.test.TestRecvThroughClient;
import org.waarp.openr66.protocol.test.TestRecvThroughClient.TestRecvThroughHandler;
import org.waarp.openr66.protocol.test.TestSendThroughClient;
import org.waarp.openr66.protocol.test.TestTasks;
import org.waarp.openr66.protocol.test.TestTransaction;
import org.waarp.openr66.protocol.test.TestTransferNoDb;
import org.waarp.openr66.protocol.utils.ChannelUtils;
import org.waarp.openr66.protocol.utils.R66Future;
import org.waarp.openr66.server.R66Server;
import org.waarp.thrift.r66.Action;
import org.waarp.thrift.r66.R66Request;
import org.waarp.thrift.r66.R66Service;
Expand Down Expand Up @@ -1427,4 +1433,42 @@ public void test90_RestR66() throws Exception {
logger.info("Key filename: {}", HttpTestRestR66Client.keydesfilename);
HttpTestRestR66Client.main(new String[] { "1" });
}

@Test
public void test98_Tasks() throws IOException, OpenR66RunnerErrorException,
CommandAbstractException {
System.err.println("Start Tasks");
File totest = new File("/tmp/R66/in/testTask.txt");
FileWriter fileWriter = new FileWriter(totest);
fileWriter.write("Test content");
fileWriter.flush();
fileWriter.close();
TestTasks.main(new String[] {
new File(dir, "config-serverA-minimal.xml").getAbsolutePath(),
"/tmp/R66/in",
"/tmp/R66/out", totest.getName()
});
System.err.println("End Tasks");
}

@Test
public void test99_SigTermR66() throws InterruptedException {
// global ant project settings
final Project project = Processes.getProject(homeDir);
final String[] argsServer = {
new File(dir, "config-serverA-minimal.xml").getAbsolutePath()
};
int pid = Processes.executeJvm(project, homeDir, R66Server.class,
argsServer, true);
Thread.sleep(1000);
logger.warn("PID found is {}", pid);
logger.warn("PID is running: {}", Processes.exists(pid));
assertTrue("Process should still exists... " + pid, Processes.exists(pid));
Processes.kill(pid, true);
while (Processes.exists(pid)) {
logger.warn("{} still running", pid);
Thread.sleep(1000);
}
Processes.finalizeProject(project);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public abstract class TestAbstract extends TestAbstractMinimal {

protected static NetworkTransaction networkTransaction = null;
private static Project project;
private static File homeDir;
static File homeDir;

public static void setUpDbBeforeClass() throws Exception {
deleteBase();
Expand Down

0 comments on commit 515a94d

Please sign in to comment.