Skip to content

Commit

Permalink
WIP - updates for new concurrency tck
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleAure committed Aug 8, 2022
1 parent 2294e83 commit b771c7f
Show file tree
Hide file tree
Showing 18 changed files with 417 additions and 108 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Subsystem-Name: Jakarta EE Web Profile 10.0
io.openliberty.appSecurity-5.0, \
io.openliberty.appAuthentication-3.0, \
io.openliberty.jsonb-3.0, \
io.openliberty.concurrent-3.0, \
io.openliberty.enterpriseBeansLite-4.0, \
io.openliberty.websocket-2.1, \
com.ibm.websphere.appserver.jdbc-4.2; ibm.tolerates:="4.3", \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,21 @@

import static org.junit.Assert.assertEquals;

import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.testng.xml.XmlPackage;
import org.testng.xml.XmlSuite;
import org.testng.xml.XmlSuite.FailurePolicy;
import org.testng.xml.XmlTest;

import com.ibm.websphere.simplicity.PortType;
import com.ibm.websphere.simplicity.log.Log;

import componenttest.annotation.AllowedFFDC;
import componenttest.annotation.MinimumJavaLevel;
import componenttest.annotation.Server;
import componenttest.custom.junit.runner.FATRunner;
import componenttest.custom.junit.runner.Mode;
import componenttest.custom.junit.runner.TestModeFilter;
import componenttest.topology.impl.LibertyServer;
import componenttest.topology.utils.MvnUtils;

Expand All @@ -52,22 +39,21 @@
*/
@RunWith(FATRunner.class)
@MinimumJavaLevel(javaLevel = 11)
public class ConcurrentTckLauncher {
public class ConcurrentTckLauncherFull {

final static Map<String, String> additionalProps = new HashMap<>();

private static String suiteXmlFile = "tck-suite.xml"; //Default value
private static String suiteXmlFile = "tck-suite-full.xml"; //Default value

@Server("ConcurrentTCKServer")
@Server("ConcurrentTCKFullServer")
public static LibertyServer server;

@BeforeClass
public static void setUp() throws Exception {
//UNCOMMENT - To test against a local snapshot of TCK
//additionalProps.put("jakarta.concurrent.tck.groupid", "jakarta.enterprise.concurrent");
//additionalProps.put("jakarta.concurrent.tck.version", "3.0.0-SNAPSHOT");

suiteXmlFile = createSuiteXML();
additionalProps.put("jakarta.concurrent.tck.version", "3.0.2-SNAPSHOT"); //TODO comment out once 3.0.2 is on maven central
additionalProps.put("jakarta.run.full.profile", "false"); //TODO comment out once 3.0.2 is on maven central

//username and password for Arquillian to authenticate to restConnect
additionalProps.put("tck_username", "arquillian");
Expand Down Expand Up @@ -109,6 +95,8 @@ public static void tearDown() throws Exception {
@AllowedFFDC // The tested exceptions cause FFDC so we have to allow for this.
public void launchConcurrentTCK() throws Exception {

suiteXmlFile = FATSuite.createSuiteXML(FATSuite.PROFILE.FULL);

Map<String, String> resultInfo = MvnUtils.getResultInfo(server);

/**
Expand All @@ -127,82 +115,8 @@ public void launchConcurrentTCK() throws Exception {

resultInfo.put("results_type", "Jakarta");
resultInfo.put("feature_name", "Concurrency");
resultInfo.put("feature_version", "3.0");
resultInfo.put("feature_version", "3.0-full");
MvnUtils.preparePublicationFile(resultInfo);
assertEquals(0, result);
}

/**
* Programmatically create a tck-suite-programmatic.xml file based on environment variables
*
* @return String suite file name
* @throws IOException if we are unable to write contents of tck-suite-programmatic.xml to filesystem
*/
public static String createSuiteXML() throws IOException {
XmlSuite suite = new XmlSuite();
suite.setFileName("tck-suite-programmatic.xml");
suite.setName("jakarta-concurrency");
suite.setVerbose(2);
suite.setConfigFailurePolicy(FailurePolicy.CONTINUE);

XmlTest test = new XmlTest(suite);
test.setName("jakarta-concurrency-programmatic");

XmlPackage apiPackage = new XmlPackage();
XmlPackage specPackage = new XmlPackage();

apiPackage.setName("ee.jakarta.tck.concurrent.api.*");
specPackage.setName("ee.jakarta.tck.concurrent.spec.*");

Set<String> apiExcludes = new HashSet<>();
Set<String> specExcludes = new HashSet<>();

/**
* Exclude certain tests when running in lite mode
*/
if (TestModeFilter.FRAMEWORK_TEST_MODE != Mode.TestMode.FULL) {
Log.info(ConcurrentTckLauncher.class, "createSuiteXML", "Modifying API and Spec packages to exclude specific tests for lite mode.");
apiExcludes.add("ee.jakarta.tck.concurrent.api.Trigger");
specExcludes.addAll(Arrays.asList("ee.jakarta.tck.concurrent.spec.ManagedScheduledExecutorService.inheritedapi",
"ee.jakarta.tck.concurrent.spec.ManagedScheduledExecutorService.inheritedapi_servlet"));
}

/**
* Skip signature testing on Windows
* So far as I can tell the signature test plugin is not supported on windows
* Opened an issue against jsonb tck https://github.com/eclipse-ee4j/jsonb-api/issues/327
*/
if (System.getProperty("os.name").contains("Windows")) {
Log.info(ConcurrentTckLauncher.class, "createSuiteXML", "Skipping Signature Tests on Windows");
specExcludes.add("ee.jakarta.tck.concurrent.spec.signature");
}

/**
* If JDK is not in the supported list for signature testing, skip it.
*/
int javaSpecVersion = Integer.parseInt(System.getProperty("java.specification.version"));
if (!(javaSpecVersion == 11 || javaSpecVersion == 17)) {
Log.info(ConcurrentTckLauncher.class, "createSuiteXML", "Skipping Signature Tests on unsupported JDK");
specExcludes.add("ee.jakarta.tck.concurrent.spec.signature");
}

apiPackage.setExclude(new ArrayList<String>(apiExcludes));
specPackage.setExclude(new ArrayList<String>(specExcludes));

test.setPackages(Arrays.asList(apiPackage, specPackage));

suite.setTests(Arrays.asList(test));

Log.info(ConcurrentTckLauncher.class, "createSuiteXML", suite.toXml());

//When this code runs it is running as part of an ant task already in the autoFVT directory.
//Therefore, use a relative path to this file.
String suiteXmlFileLocation = "publish/tckRunner/tck/" + suite.getFileName();
try (FileWriter suiteXmlWriter = new FileWriter(suiteXmlFileLocation);) {
suiteXmlWriter.write(suite.toXml());
Log.info(ConcurrentTckLauncher.class, "createSuiteXML", "Wrote to " + suiteXmlFileLocation);
}

return suite.getFileName();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/*******************************************************************************
* Copyright (c) 2022 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package io.openliberty.jakarta.enterprise.concurrent.tck;

import static org.junit.Assert.assertEquals;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;

import com.ibm.websphere.simplicity.PortType;

import componenttest.annotation.AllowedFFDC;
import componenttest.annotation.MinimumJavaLevel;
import componenttest.annotation.Server;
import componenttest.custom.junit.runner.FATRunner;
import componenttest.topology.impl.LibertyServer;
import componenttest.topology.utils.MvnUtils;

/**
* This is a test class that runs the whole Jakarta Concurrency TCK. The TCK results
* are copied in the results/junit directory before the Simplicity FAT framework
* generates the html report - so there is detailed information on individual
* tests as if they were running as simplicity junit FAT tests in the standard
* location.
*/
@RunWith(FATRunner.class)
@MinimumJavaLevel(javaLevel = 11)
public class ConcurrentTckLauncherWeb {

final static Map<String, String> additionalProps = new HashMap<>();

private static String suiteXmlFile = "tck-suite-web.xml"; //Default value

@Server("ConcurrentTCKWebServer")
public static LibertyServer server;

@BeforeClass
public static void setUp() throws Exception {
//UNCOMMENT - To test against a local snapshot of TCK
//additionalProps.put("jakarta.concurrent.tck.groupid", "jakarta.enterprise.concurrent");
additionalProps.put("jakarta.concurrent.tck.version", "3.0.2-SNAPSHOT"); //TODO comment out once 3.0.2 is on maven central

//username and password for Arquillian to authenticate to restConnect
additionalProps.put("tck_username", "arquillian");
additionalProps.put("tck_password", "arquillianPassword");

//Logging properties for java.util.logging to use for mvn output
additionalProps.put("java.util.logging.config.file", server.getServerRoot() + "/resources/logging/logging.properties");

//username and password to set on quickStartSecurity
server.addEnvVar("tck_username", "arquillian");
server.addEnvVar("tck_password", "arquillianPassword");

//Ports liberty should be using for testing
server.addEnvVar("tck_port", "" + server.getPort(PortType.WC_defaulthost));
server.addEnvVar("tck_port_secure", "" + server.getPort(PortType.WC_defaulthost_secure));

Map<String, String> opts = server.getJvmOptionsAsMap();
//Path that jimage will output modules for signature testing
opts.put("-Djimage.dir", server.getServerSharedPath() + "jimage/output/");
server.setJvmOptions(opts);

//Finally start the server
server.startServer();
}

@AfterClass
public static void tearDown() throws Exception {
server.stopServer(
"WLTC0032W", //Transaction rollback warning.
"WLTC0033W", //Transaction rollback warning.
"CWWKS0901E" //Quickstart security
);
}

/**
* Run the TCK (controlled by autoFVT/publish/tckRunner/tck/*)
*/
@Test
@AllowedFFDC // The tested exceptions cause FFDC so we have to allow for this.
public void launchConcurrentTCK() throws Exception {

suiteXmlFile = FATSuite.createSuiteXML(FATSuite.PROFILE.WEB);

Map<String, String> resultInfo = MvnUtils.getResultInfo(server);

/**
* The runTCKMvnCmd will set the following properties for use by arquillian
* [ wlp, tck_server, tck_port, tck_failSafeUndeployment, tck_appDeployTimeout, tck_appUndeployTimeout ]
* and then run the mvn test command.
*/
int result = MvnUtils.runTCKMvnCmd(
server, //server to run on
"io.openliberty.jakarta.concurrency.3.0_fat_tck", //bucket name
this.getClass() + ":launchConcurrentTCK", //launching method
suiteXmlFile, //tck suite
additionalProps, //additional props
Collections.emptySet() //additional jars
);

resultInfo.put("results_type", "Jakarta");
resultInfo.put("feature_name", "Concurrency");
resultInfo.put("feature_version", "3.0-Web");
MvnUtils.preparePublicationFile(resultInfo);
assertEquals(0, result);
}
}
Loading

0 comments on commit b771c7f

Please sign in to comment.