From 3244a0c5eb1962f58d2981bddabc927a2c1d970b Mon Sep 17 00:00:00 2001 From: Frederic Bregier Date: Sat, 10 Aug 2019 13:02:14 +0200 Subject: [PATCH] Fix Shutdown through SigTerm --- pom.xml | 29 +++++++- .../openr66/protocol/junit/AllTasksTest.java | 68 ------------------- .../protocol/junit/NetworkClientTest.java | 44 ++++++++++++ .../openr66/protocol/junit/TestAbstract.java | 2 +- 4 files changed, 73 insertions(+), 70 deletions(-) delete mode 100644 src/test/java/org/waarp/openr66/protocol/junit/AllTasksTest.java diff --git a/pom.xml b/pom.xml index fbf0b0e47..14bce770f 100644 --- a/pom.xml +++ b/pom.xml @@ -236,7 +236,34 @@ 1.10.6 test - + + com.github.jnr + jnr-posix + 3.0.50 + + test + + + org.apache.ant + ant + 1.10.6 + + test + + + com.sun + tools + + + + + Waarp + WaarpCommon + tests + test-jar + 3.1.1 + test + diff --git a/src/test/java/org/waarp/openr66/protocol/junit/AllTasksTest.java b/src/test/java/org/waarp/openr66/protocol/junit/AllTasksTest.java deleted file mode 100644 index 78fefdc5d..000000000 --- a/src/test/java/org/waarp/openr66/protocol/junit/AllTasksTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * This file is part of Waarp Project (named also Waarp or GG). - * - * Copyright (c) 2019, Waarp SAS, and individual contributors by the @author - * tags. See the COPYRIGHT.txt in the distribution for a full listing of - * individual contributors. - * - * All Waarp Project is free software: you can redistribute it and/or - * modify it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. - * - * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with - * Waarp . If not, see . - ******************************************************************************/ - -/** - * - */ -package org.waarp.openr66.protocol.junit; - -import org.junit.BeforeClass; -import org.junit.FixMethodOrder; -import org.junit.Test; -import org.junit.runners.MethodSorters; -import org.waarp.common.command.exception.CommandAbstractException; -import org.waarp.openr66.context.task.exception.OpenR66RunnerErrorException; -import org.waarp.openr66.protocol.test.TestTasks; - -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; - -/** - * @author frederic - * - */ -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class AllTasksTest extends TestAbstract { - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - setUpBeforeClassMinimal("Linux/config/config-serverInitB.xml"); - setUpDbBeforeClass(); - } - - @Test - public void test_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"); - } - -} diff --git a/src/test/java/org/waarp/openr66/protocol/junit/NetworkClientTest.java b/src/test/java/org/waarp/openr66/protocol/junit/NetworkClientTest.java index d5bc6f5b4..26bdcf200 100644 --- a/src/test/java/org/waarp/openr66/protocol/junit/NetworkClientTest.java +++ b/src/test/java/org/waarp/openr66/protocol/junit/NetworkClientTest.java @@ -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; @@ -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; @@ -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; @@ -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); + } } diff --git a/src/test/java/org/waarp/openr66/protocol/junit/TestAbstract.java b/src/test/java/org/waarp/openr66/protocol/junit/TestAbstract.java index d75e4d095..8da673185 100644 --- a/src/test/java/org/waarp/openr66/protocol/junit/TestAbstract.java +++ b/src/test/java/org/waarp/openr66/protocol/junit/TestAbstract.java @@ -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();