From 455be0330112864fd873258ba0d7890385c71e78 Mon Sep 17 00:00:00 2001 From: Chamila Adhikarinayake Date: Thu, 21 Dec 2023 10:28:57 +0530 Subject: [PATCH] OOM Test case --- .../tests/logging/OOMLogsCheckTest.java | 40 +++++++++++++++++++ .../src/test/resources/testng-server-mgt.xml | 1 + 2 files changed, 41 insertions(+) create mode 100644 modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/logging/OOMLogsCheckTest.java diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/logging/OOMLogsCheckTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/logging/OOMLogsCheckTest.java new file mode 100644 index 0000000000..364340e319 --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/logging/OOMLogsCheckTest.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.am.integration.tests.logging; + +import static org.junit.Assert.assertFalse; + +import java.io.File; + +import org.testng.annotations.Test; +import org.wso2.am.integration.tests.api.lifecycle.APIManagerLifecycleBaseTest; +import org.wso2.carbon.utils.ServerConstants; + +public class OOMLogsCheckTest extends APIManagerLifecycleBaseTest { + @Test(groups = { "wso2.am" }, description = "Test whether a heapdump is generated due to OOM issue") + public void testAvailabilityOfHeapDumpTestcase() throws Exception { + String heapdumpFile = System.getProperty(ServerConstants.CARBON_HOME) + File.separator + "repository" + + File.separator + "logs" + File.separator + "heap-dump.hprof"; + + File file = new File(heapdumpFile); + assertFalse("A Heapdump file is present in " + heapdumpFile + ". This possibly indicates an issue during startup / OSGi resolution.", file.exists()); + + } + +} diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/testng-server-mgt.xml b/modules/integration/tests-integration/tests-backend/src/test/resources/testng-server-mgt.xml index d34e32ebd0..09cfbfd0c7 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/resources/testng-server-mgt.xml +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/testng-server-mgt.xml @@ -24,6 +24,7 @@ +