From 073104e1cb1a230fe571133ca6921a4f810592a0 Mon Sep 17 00:00:00 2001 From: Andrew Pielage Date: Tue, 19 Oct 2021 11:49:15 +0100 Subject: [PATCH] Merge pull request #5448 from Pandrex247/FISH-5753 FISH-5753 Corba Read Timeout in Buffer Manager --- .../samples/corba-read-timeout/pom.xml | 73 +++++++++++++++ .../read/timeout/TimeoutTestService.java | 47 ++++++++++ .../read/timeout/TimeoutTestServiceBean.java | 54 +++++++++++ .../read/timeout/TimeoutTestClientIT.java | 90 +++++++++++++++++++ .../tests/payara-samples/samples/pom.xml | 2 + 5 files changed, 266 insertions(+) create mode 100644 appserver/tests/payara-samples/samples/corba-read-timeout/pom.xml create mode 100644 appserver/tests/payara-samples/samples/corba-read-timeout/src/main/java/fish/payara/samples/corba/read/timeout/TimeoutTestService.java create mode 100644 appserver/tests/payara-samples/samples/corba-read-timeout/src/main/java/fish/payara/samples/corba/read/timeout/TimeoutTestServiceBean.java create mode 100644 appserver/tests/payara-samples/samples/corba-read-timeout/src/test/java/fish/payara/samples/corba/read/timeout/TimeoutTestClientIT.java diff --git a/appserver/tests/payara-samples/samples/corba-read-timeout/pom.xml b/appserver/tests/payara-samples/samples/corba-read-timeout/pom.xml new file mode 100644 index 00000000000..4548654e639 --- /dev/null +++ b/appserver/tests/payara-samples/samples/corba-read-timeout/pom.xml @@ -0,0 +1,73 @@ + + + + + payara-samples-profiled-tests + fish.payara.samples + 5.2021.8-SNAPSHOT + + 4.0.0 + + corba-read-timeout + Payara Samples - CORBA Read Timeout + + + + fish.payara.samples + samples-test-utils + + + jakarta.ejb + jakarta.ejb-api + provided + + + fish.payara.server.appclient + gf-client + ${project.version} + test + + + + + \ No newline at end of file diff --git a/appserver/tests/payara-samples/samples/corba-read-timeout/src/main/java/fish/payara/samples/corba/read/timeout/TimeoutTestService.java b/appserver/tests/payara-samples/samples/corba-read-timeout/src/main/java/fish/payara/samples/corba/read/timeout/TimeoutTestService.java new file mode 100644 index 00000000000..568f0d893bd --- /dev/null +++ b/appserver/tests/payara-samples/samples/corba-read-timeout/src/main/java/fish/payara/samples/corba/read/timeout/TimeoutTestService.java @@ -0,0 +1,47 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2021 Payara Foundation and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://github.com/payara/Payara/blob/master/LICENSE.txt + * See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at glassfish/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * The Payara Foundation designates this particular file as subject to the "Classpath" + * exception as provided by the Payara Foundation in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package fish.payara.samples.corba.read.timeout; + +import javax.ejb.Remote; + +@Remote +public interface TimeoutTestService { + byte[] getBytes(int size); +} \ No newline at end of file diff --git a/appserver/tests/payara-samples/samples/corba-read-timeout/src/main/java/fish/payara/samples/corba/read/timeout/TimeoutTestServiceBean.java b/appserver/tests/payara-samples/samples/corba-read-timeout/src/main/java/fish/payara/samples/corba/read/timeout/TimeoutTestServiceBean.java new file mode 100644 index 00000000000..b1090c19073 --- /dev/null +++ b/appserver/tests/payara-samples/samples/corba-read-timeout/src/main/java/fish/payara/samples/corba/read/timeout/TimeoutTestServiceBean.java @@ -0,0 +1,54 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2021 Payara Foundation and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://github.com/payara/Payara/blob/master/LICENSE.txt + * See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at glassfish/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * The Payara Foundation designates this particular file as subject to the "Classpath" + * exception as provided by the Payara Foundation in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package fish.payara.samples.corba.read.timeout; + +import javax.ejb.Stateless; + +@Stateless +public class TimeoutTestServiceBean implements TimeoutTestService { + public byte[] getBytes(int size) { + byte[] bytes = new byte[size]; + for (int i = 0; i < bytes.length; i++) { + bytes[i] = 0x42; + } + + return bytes; + } +} \ No newline at end of file diff --git a/appserver/tests/payara-samples/samples/corba-read-timeout/src/test/java/fish/payara/samples/corba/read/timeout/TimeoutTestClientIT.java b/appserver/tests/payara-samples/samples/corba-read-timeout/src/test/java/fish/payara/samples/corba/read/timeout/TimeoutTestClientIT.java new file mode 100644 index 00000000000..21a8b695e54 --- /dev/null +++ b/appserver/tests/payara-samples/samples/corba-read-timeout/src/test/java/fish/payara/samples/corba/read/timeout/TimeoutTestClientIT.java @@ -0,0 +1,90 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2021 Payara Foundation and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://github.com/payara/Payara/blob/master/LICENSE.txt + * See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at glassfish/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * The Payara Foundation designates this particular file as subject to the "Classpath" + * exception as provided by the Payara Foundation in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package fish.payara.samples.corba.read.timeout; + +import fish.payara.samples.NotMicroCompatible; +import fish.payara.samples.PayaraArquillianTestRunner; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.container.test.api.RunAsClient; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; + +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; + +@RunWith(PayaraArquillianTestRunner.class) +@RunAsClient +@NotMicroCompatible +public class TimeoutTestClientIT { + + @Deployment + public static WebArchive deploy() { + return ShrinkWrap.create(WebArchive.class).addClasses(TimeoutTestService.class, TimeoutTestServiceBean.class); + } + + @Test + public void shouldNotTimeoutIT() throws NamingException { + Context initialContext = new InitialContext(); + TimeoutTestService timeoutTestService = (TimeoutTestService) initialContext.lookup(TimeoutTestService.class.getName()); + + int tryNumber = 0; + boolean running = true; + long startTime = 0; + while (running) { + if (tryNumber > 10000) { + break; + } + try { + tryNumber++; + startTime = System.currentTimeMillis(); + timeoutTestService.getBytes(10000000); + } catch (Exception e) { + System.out.println("Error occured at try number: " + tryNumber + " after " + (System.currentTimeMillis() - startTime) + " millis"); + e.printStackTrace(); + running = false; + Assert.fail(); + } + } + } +} diff --git a/appserver/tests/payara-samples/samples/pom.xml b/appserver/tests/payara-samples/samples/pom.xml index 4aebd4a2bba..e411f085a7d 100644 --- a/appserver/tests/payara-samples/samples/pom.xml +++ b/appserver/tests/payara-samples/samples/pom.xml @@ -42,6 +42,8 @@ microprofile-rc-ft multiple-keystores client-certificate-validator + +