Skip to content

Commit

Permalink
Add workflow
Browse files Browse the repository at this point in the history
Update workflow

Update workflow

Update workflow latest

Update workflow latest

Update workflow

Replace java.util.concurrent.TimeUnit with java.time.Duration

Replace java.util.concurrent.TimeUnit with java.time.Duration

Replace java.util.concurrent.TimeUnit with java.time.Duration

update waiting time

Update script

Remove unwanted changes

Replace java.util.concurrent.TimeUnit with java.time.Duration

Replace timeunit with duration

Replace timeunit with duration

Update time to wait

Update time to wait

Add exception in the method signature

Update workflow

Add exception in the method signature
  • Loading branch information
kalaiyarasiganeshalingam committed Nov 12, 2024
1 parent e9339ee commit f1a5a9f
Show file tree
Hide file tree
Showing 19 changed files with 132 additions and 58 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/cluster-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,12 @@ jobs:
with:
distribution: 'temurin'
java-version: '17.0.6'
- name: Cluster Tests
- name: Cluster Tests with JDK 17
run: mvn -B clean install --file integration/pom.xml -P cluster-tests
- name: Set up JDK 21
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '21.0.4'
- name: Cluster Tests with JDK 21
run: mvn -B clean install --file integration/pom.xml -P cluster-tests
51 changes: 51 additions & 0 deletions .github/workflows/jdk-21-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Integration tests (Ubuntu, OpenJDK17)

on: [push, pull_request]

jobs:
ubuntu:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- id: 1
profile: tests-mediators_tests-other_tests-sample
- id: 2
profile: tests-service_tests-patches_service-samples
- id: 3
profile: tests-transport_tests-platform
- id: 4
profile: management-api_dss-tests
fail-fast: false
steps:
- uses: actions/checkout@v3
- name: Cache Maven packages
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2
restore-keys: ${{ runner.os }}-m2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '11.0.12+7'
- name: check mvn version
run: echo "MAVEN_VERSION=$(mvn -v)"
- name: check java version
run: echo "JAVA_VERSION=$(java -version)"
- name: Build in jdk11
run: mvn -B clean install -DskipTests --file pom.xml
- name: Set up JDK 21
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '21.0.4'
- name: check mvn version
run: echo "MAVEN_VERSION=$(mvn -v)"
- name: check java version
run: echo "JAVA_VERSION=$(java -version)"
- name: Print segment
run: echo "Running build for segment ${{ matrix.profile }}"
- name: JDK 21 Tests
run: mvn -B clean install --file integration/pom.xml -P ${{ matrix.profile }} -fae
24 changes: 21 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,36 @@ jobs:
path: ~/.m2
key: ${{ runner.os }}-m2
restore-keys: ${{ runner.os }}-m2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '11.0.12+7'
- name: check mvn version
run: echo "MAVEN_VERSION=$(mvn -v)"
continue-on-error: true
- name: check java version
run: echo "JAVA_VERSION=$(java -version)"
continue-on-error: true
- name: Build in jdk11
run: mvn -B clean install -DskipTests --file pom.xml
- name: Set up JDK 21
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '21.0.4'
- name: check mvn version
run: echo "MAVEN_VERSION=$(mvn -v)"
continue-on-error: true
- name: check java version
run: echo "JAVA_VERSION=$(java -version)"
- name: Build in jdk21
run: mvn -B clean install -DskipTests --file pom.xml
continue-on-error: true
# - name: Build in jdk21
# run: mvn -B clean install -DskipTests --file pom.xml
# continue-on-error: true
- name: Print segment
run: echo "Running build for segment ${{ matrix.profile }}"
continue-on-error: true
- name: JDK 21 Tests
run: mvn -B clean install --file integration/pom.xml -P ${{ matrix.profile }} -fae
run: mvn -B clean install --file integration/pom.xml
continue-on-error: true
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Please follow the steps below to build WSO2 Micro Integrator from the source cod
2. Run the maven command `mvn clean install` from the root directory of the repository.
3. The generated Micro Integrator distribution can be found at `micro-integrator/distribution/target/wso2mi-<version>.zip`.

Please note that the product can be build using only JDK 11 but the integration tests can be run in either JDK 11 or 17.
Please note that the product can be build using only JDK 11 but the integration tests can be run in either JDK 11, 17 or 21.

#### Building the Docker image

Expand Down
2 changes: 1 addition & 1 deletion distribution/src/scripts/micro-integrator.bat
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ goto supportedJdk

:unknownJdk
echo Starting WSO2 MI (in unsupported JDK %JAVA_VERSION%)
echo [ERROR] WSO2 MI is supported only between JDK 11 and JDK 17"
echo [ERROR] WSO2 MI is supported only between JDK 11 and JDK 21"
goto end

:supportedJdk
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void serviceDeployment() throws Exception {
}

@Test(groups = "wso2.dss", description = "dbConsole available test case")
public void dbConsoleAvailableTest() throws XPathExpressionException, IOException {
public void dbConsoleAvailableTest() throws XPathExpressionException, IOException, InterruptedException {
String webAppUrl = dssContext.getContextUrls().getWebAppURL();
String url = webAppUrl + "/" + "dbconsole/login.jsp?region=region5&item=dbconsole";
Map<String, String> headers = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@
import org.testng.annotations.Test;
import org.wso2.ei.dataservice.integration.test.DSSIntegrationTest;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static org.wso2.ei.dataservice.integration.test.odata.ODataTestUtils.getETag;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@
import org.testng.annotations.Test;
import org.wso2.ei.dataservice.integration.test.DSSIntegrationTest;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static org.wso2.ei.dataservice.integration.test.odata.ODataTestUtils.sendDELETE;
Expand Down Expand Up @@ -61,6 +58,7 @@ public void validateNavigationPropertyReferencesTestCase() throws Exception {
Map<String, String> headers = new HashMap<>();
headers.put("Accept", "application/json");
Object[] response = sendGET(endpoint, headers);
Thread.sleep(1000);
Assert.assertEquals(response[0], ODataTestUtils.OK);
Assert.assertTrue(
response[1].toString().contains("FILERECORDS(1)") && response[1].toString().contains("FILERECORDS(4)"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,28 +43,28 @@ public void run() {
case "POST":
try {
ODataTestUtils.sendPOST(endpoint, content, headers);
} catch (IOException e) {
} catch (IOException|InterruptedException e) {
e.printStackTrace();
}
break;
case "PUT":
try {
ODataTestUtils.sendPUT(endpoint, content, headers);
} catch (IOException e) {
} catch (IOException|InterruptedException e) {
e.printStackTrace();
}
break;
case "PATCH":
try {
ODataTestUtils.sendPATCH(endpoint, content, headers);
} catch (IOException e) {
} catch (IOException|InterruptedException e) {
e.printStackTrace();
}
break;
case "DELETE":
try {
ODataTestUtils.sendDELETE(endpoint, headers);
} catch (IOException e) {
} catch (IOException|InterruptedException e) {
e.printStackTrace();
}
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class ODataTestUtils {
public static final int PRE_CONDITION_FAILED = 412;
public static final int NOT_FOUND = 404;

public static Object[] sendPOST(String endpoint, String content, Map<String, String> headers) throws IOException {
public static Object[] sendPOST(String endpoint, String content, Map<String, String> headers) throws IOException, InterruptedException {
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(endpoint);
for (String headerType : headers.keySet()) {
Expand All @@ -62,6 +62,7 @@ public static Object[] sendPOST(String endpoint, String content, Map<String, Str
httpPost.setEntity(httpEntity);
}
HttpResponse httpResponse = httpClient.execute(httpPost);
Thread.sleep(1000);
if (httpResponse.getEntity() != null) {
BufferedReader reader = new BufferedReader(new InputStreamReader(httpResponse.getEntity().getContent()));
String inputLine;
Expand All @@ -77,13 +78,14 @@ public static Object[] sendPOST(String endpoint, String content, Map<String, Str
}
}

public static Object[] sendGET(String endpoint, Map<String, String> headers) throws IOException {
public static Object[] sendGET(String endpoint, Map<String, String> headers) throws IOException, InterruptedException {
HttpClient httpClient = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(endpoint);
for (String headerType : headers.keySet()) {
httpGet.setHeader(headerType, headers.get(headerType));
}
HttpResponse httpResponse = httpClient.execute(httpGet);
Thread.sleep(1000);
if (httpResponse.getEntity() != null) {
BufferedReader reader = new BufferedReader(new InputStreamReader(httpResponse.getEntity().getContent()));
String inputLine;
Expand All @@ -99,7 +101,7 @@ public static Object[] sendGET(String endpoint, Map<String, String> headers) thr
}
}

public static int sendPUT(String endpoint, String content, Map<String, String> headers) throws IOException {
public static int sendPUT(String endpoint, String content, Map<String, String> headers) throws IOException, InterruptedException {
HttpClient httpClient = new DefaultHttpClient();
HttpPut httpPut = new HttpPut(endpoint);
for (String headerType : headers.keySet()) {
Expand All @@ -113,10 +115,11 @@ public static int sendPUT(String endpoint, String content, Map<String, String> h
httpPut.setEntity(httpEntity);
}
HttpResponse httpResponse = httpClient.execute(httpPut);
Thread.sleep(1000);
return httpResponse.getStatusLine().getStatusCode();
}

public static int sendPATCH(String endpoint, String content, Map<String, String> headers) throws IOException {
public static int sendPATCH(String endpoint, String content, Map<String, String> headers) throws IOException, InterruptedException {
HttpClient httpClient = new DefaultHttpClient();
HttpPatch httpPatch = new HttpPatch(endpoint);
for (String headerType : headers.keySet()) {
Expand All @@ -130,16 +133,18 @@ public static int sendPATCH(String endpoint, String content, Map<String, String>
httpPatch.setEntity(httpEntity);
}
HttpResponse httpResponse = httpClient.execute(httpPatch);
Thread.sleep(1000);
return httpResponse.getStatusLine().getStatusCode();
}

public static int sendDELETE(String endpoint, Map<String, String> headers) throws IOException {
public static int sendDELETE(String endpoint, Map<String, String> headers) throws IOException, InterruptedException {
HttpClient httpClient = new DefaultHttpClient();
HttpDelete httpDelete = new HttpDelete(endpoint);
for (String headerType : headers.keySet()) {
httpDelete.setHeader(headerType, headers.get(headerType));
}
HttpResponse httpResponse = httpClient.execute(httpDelete);
Thread.sleep(1000);
return httpResponse.getStatusLine().getStatusCode();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,14 @@ private void addDataSources() throws Exception {

echoSampleSourceMetaInfo.setDefinition(echoSampleDSDefinition);
dataSourceAdminClient.addDataSource(echoSampleSourceMetaInfo);
Thread.sleep(1000);
Thread.sleep(5000);
}

private void removeDataSources() throws Exception {
NDataSourceAdminServiceClient dataSourceAdminClient = new NDataSourceAdminServiceClient(
dssContext.getContextUrls().getBackEndUrl(), sessionCookie);
dataSourceAdminClient.deleteDataSource("IN_MEMORY_SAMPLE_DS");
dataSourceAdminClient.deleteDataSource("ECHO_SAMPLE_DS");
Thread.sleep(1000);
Thread.sleep(5000);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ public void testServiceCatalogMetadataWithEnv()

@Test(groups = {"wso2.esb"},
description = "Test the ZIP file created by the service catalog", priority = 7)
public void testServiceCatalogZipFile() throws CarbonException, FileNotFoundException {
File extracted = chekAndExtractPayloadZip();
public void testServiceCatalogZipFile() throws CarbonException, FileNotFoundException, InterruptedException {
File extracted = checkAndExtractPayloadZip();
assertTrue(extracted.exists(), "Error occurred while extracting the ZIP");
File metadataFile = new File(extracted, "healthcare_v1.0.0-SNAPSHOT");
File yamlFile = new File(metadataFile, "metadata.yaml");
Expand All @@ -244,7 +244,7 @@ public void testUploadOnlyNewAPIs()
File.separator + TOML_FILE));
assertTrue(Utils.checkForLog(carbonLogReader,
"Successfully updated the service catalog", 10), "Did not receive the expected info log");
File extracted = chekAndExtractPayloadZip();
File extracted = checkAndExtractPayloadZip();
assertTrue(extracted.exists(), "Error occurred while extracting the ZIP");
assertFalse(checkMetadataFileExists(extracted, "healthcare_v1.0.0-SNAPSHOT"),
"healthcare API should not be uploaded again");
Expand All @@ -269,7 +269,7 @@ public void testUploadOnlyModifiedAPIs()
File.separator + TOML_FILE));
assertTrue(Utils.checkForLog(carbonLogReader,
"Successfully updated the service catalog", 10), "Did not receive the expected info log");
File extracted = chekAndExtractPayloadZip();
File extracted = checkAndExtractPayloadZip();
assertTrue(extracted.exists(), "Error occurred while extracting the ZIP");
assertFalse(checkMetadataFileExists(extracted, "healthcare_v1.0.0-SNAPSHOT"),
"healthcare API should not be uploaded again");
Expand Down Expand Up @@ -316,7 +316,7 @@ public void testServiceCatalogProxyServiceMetadata()
serverConfigurationManager.restartMicroIntegrator();
assertTrue(Utils.checkForLog(carbonLogReader,
"Successfully updated the service catalog", 10), "Did not receive the expected info log");
File extracted = chekAndExtractPayloadZip();
File extracted = checkAndExtractPayloadZip();
assertTrue(extracted.exists(), "Error occurred while extracting the ZIP");
File metadataFile = new File(extracted, "SampleProxyService_proxy_v1.0.0");
File yamlFile = new File(metadataFile, "metadata.yaml");
Expand All @@ -326,7 +326,8 @@ public void testServiceCatalogProxyServiceMetadata()
}
}

private static File chekAndExtractPayloadZip() throws CarbonException {
private static File checkAndExtractPayloadZip() throws CarbonException, InterruptedException {
Thread.sleep(1000);
String payloadZipPath = CarbonBaseUtils.getCarbonHome() + File.separator + "tmp" + File.separator +
SERVICE_CATALOG_FOLDER_NAME + File.separator + ZIP_FILE_NAME;
File zipFile = new File(payloadZipPath);
Expand Down Expand Up @@ -354,7 +355,7 @@ public void destroy() throws Exception {
serverConfigurationManager.restartGracefully();
}

private class FirstController implements HttpHandler {
private static class FirstController implements HttpHandler {
@Override
public void handle(HttpExchange exchange) throws IOException {
try (OutputStream responseBody = exchange.getResponseBody()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
import org.wso2.esb.integration.common.utils.CarbonLogReader;
import org.wso2.esb.integration.common.utils.ESBIntegrationTest;

import java.util.concurrent.TimeUnit;

import static org.testng.Assert.assertFalse;

public class ESBJAVA4470StoreMediatorEmptyOMArraySerializeException extends ESBIntegrationTest {
Expand All @@ -42,7 +40,7 @@ public void testStoreMediatorEmptyOMArrayPropertySerialize() throws Exception {
String url = getApiInvocationURL("SerializeProperty") + "/serializeOMArray";
SimpleHttpClient httpClient = new SimpleHttpClient();
httpClient.doGet(url, null);
TimeUnit.SECONDS.sleep(10);
Thread.sleep(10000);

boolean logFound = carbonLogReader.checkForLog("Index: 0, Size: 0", DEFAULT_TIMEOUT) &&
carbonLogReader.checkForLog("ERROR", DEFAULT_TIMEOUT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,9 @@ fi
# ---------- Handle the SSL Issue with proper JDK version --------------------
java_version=$("$JAVACMD" -version 2>&1 | awk -F '"' '/version/ {print $2}')
java_version_formatted=$(echo "$java_version" | awk -F. '{printf("%02d%02d",$1,$2);}')
if [ $java_version_formatted -lt 1100 ] || [ $java_version_formatted -gt 1700 ]; then
if [ $java_version_formatted -lt 1100 ] || [ $java_version_formatted -gt 2100 ]; then
echo " Starting WSO2 MI (in unsupported JDK)"
echo " [ERROR] WSO2 MI is supported only between JDK 11 and JDK 17"
echo " [ERROR] WSO2 MI is supported only between JDK 11 and JDK 21"
exit 0
fi

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ goto supportedJdk

:unknownJdk
echo Starting WSO2 MI (in unsupported JDK %JAVA_VERSION%)
echo [ERROR] WSO2 MI is supported only between JDK 11 and JDK 17"
echo [ERROR] WSO2 MI is supported only between JDK 11 and JDK 21"
goto end

:supportedJdk
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,9 @@ fi
# ---------- Handle the SSL Issue with proper JDK version --------------------
java_version=$("$JAVACMD" -version 2>&1 | awk -F '"' '/version/ {print $2}')
java_version_formatted=$(echo "$java_version" | awk -F. '{printf("%02d%02d",$1,$2);}')
if [ $java_version_formatted -lt 1100 ] || [ $java_version_formatted -gt 1700 ]; then
if [ $java_version_formatted -lt 1100 ] || [ $java_version_formatted -gt 2100 ]; then
echo " Starting WSO2 MI (in unsupported JDK)"
echo " [ERROR] WSO2 MI is supported only between JDK 11 and JDK 17"
echo " [ERROR] WSO2 MI is supported only between JDK 11 and JDK 21"
exit 0
fi

Expand Down
Loading

0 comments on commit f1a5a9f

Please sign in to comment.