Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add vendor-specific tests for jdk builds #2140

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ functional
!functional/security
!functional/SyntheticGCWorkload
!functional/MBCS_Tests
!functional/BuildTestsForSpecificVendors

Utils
systemtest_prereqs/*
Expand Down
69 changes: 69 additions & 0 deletions functional/BuildTestsForSpecificVendors/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Vendor-Specific Testing

## Build Tests

### 1) Contents
1) Contents
2) Purpose
3) Usage
4) Current Tests
5) Adding new tests
6) FAQ

### 2) Purpose

The purpose of the Vendor Specific "Build" tests are to verify specific aspects of an OpenJDK build from a
specific vendor (like Adopt).

Specifically, tests which only verify quality when testing a build from that vendor. A build from a different
vendor cannot be said to be good or bad as a result of passing or failing these tests.

E.g. Adopt may decline to bundle an optional library with its builds. Builds from other providers can be
perfectly ok both with and without this library, but an Adopt build could only be said to be "good" if
the example lib was successfully excluded. So an adopt-specific test is created to test for the lib's absence

### 3) Usage

The commands needed to run these tests locally can be found inside the playlist.xml file in this directory.

When run on a regular basis, these should be run alongside the existing functional tests as part of
a standard suite of post-build functional validation testing.

### 4) Current Tests

- **CUDA enabled test (AdoptOpenJDK)**: Tests that the CUDA functionality has been enabled in JDKs on supported platforms.

- **Freetype Absence test (AdoptOpenJDK)**: Tests for the absence of a bundled freetype library in any Linux JDK.

### 5) Adding new tests

To add a new test, follow these steps:

1) Add a title and brief description of your test to the "Current Tests" section above, including
the name/s of any vendors whose JDK builds you intend to test with this.

2) Add the test source (ideally testng) to:
```./src/net/\<vendor name\>/test/build/\<test name \(dir\)\>/```
Note: A test template is available for reference or copying, and can be found at:
```./src/net/adoptopenjdk/test/build/TestTemplate.java```

3) (Testng tests only) Add an entry to testng.xml for your test.

3) (Non-testng tests) If not a testng test, add a test execution command to the playlist.xml file in this directory, using other \<test\> elements as reference.

4) (Optional) If the test requires special treatment for building, modify the build.xml file as needed. Most java-based tests should require no changes.

### 5) FAQ

Q1) What happens if I run one of these tests against a non-Adopt build, or a build too old for what it's testing?
A1) The test (if appropriate) should automatically pass if:
- The build was not produced by the relevant vendor.
- The test is being run on the wrong JDK major version.
- The test is being run on a build that's too old for what we're testing.
Note: from: ./src/net/adoptopenjdk/test/build/common/BuildIs.java

Q2) Can I put tests for non-AdoptOpenJDK vendor builds in here?
A2) Yes, though you should ensure the vendor name in the source path is set correctly.

Q3) Where can I ask questions?
A3) The #testing Slack channel at AdoptOpenJDK is a good place to ask questions.
71 changes: 71 additions & 0 deletions functional/BuildTestsForSpecificVendors/build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?xml version="1.0"?>

<!--
# Licensed 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
#
# https://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.
-->

<project name="Build Tests For Specific Vendors" default="build" basedir=".">
<taskdef resource="net/sf/antcontrib/antlib.xml" />
<description>
Build Tests For Specific Vendors
</description>
<import file="${TEST_ROOT}/functional/build.xml"/>

<!-- set global properties for this build -->
<property name="DEST" value="${BUILD_ROOT}/functional/BuildTestsForSpecificVendors" />

<!--Properties for this particular build-->
<property name="src" location="./src" />
<property name="build" location="./bin" />

<target name="init">
<mkdir dir="${DEST}" />
<mkdir dir="${build}" />
</target>

<target name="compile" depends="init" description="Using java ${JDK_VERSION} to compile the source ">
<echo>Ant version is ${ant.version}</echo>
<echo>============COMPILER SETTINGS============</echo>
<echo>===fork: yes</echo>
<echo>===executable: ${compiler.javac}</echo>
<echo>===debug: on</echo>
<echo>===destdir: ${DEST}</echo>
<javac srcdir="${src}" destdir="${build}" debug="true" fork="true" executable="${compiler.javac}" includeAntRuntime="false" encoding="ISO-8859-1">
<src path="${src}" />
<classpath>
<pathelement location="${LIB_DIR}/testng.jar"/>
<pathelement location="${LIB_DIR}/jcommander.jar"/>
</classpath>
</javac>
</target>

<target name="dist" depends="compile,dist_functional" description="generate the distribution">
<jar jarfile="${DEST}/BuildTestsForSpecificVendors.jar" filesonly="true">
<fileset dir="${build}" />
<fileset dir="${src}/../" includes="*.properties,*.xml" />
</jar>
<copy todir="${DEST}">
<fileset dir="${src}/../" includes="*.xml" />
<fileset dir="${src}/../" includes="*.mk" />
</copy>
</target>

<target name="clean" depends="dist" description="clean up">
<!-- Delete the ${build} directory trees -->
<delete dir="${build}" />
</target>

<target name="build" >
<antcall target="clean" inheritall="true" />
</target>
</project>
28 changes: 28 additions & 0 deletions functional/BuildTestsForSpecificVendors/playlist.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version='1.0' encoding='UTF-8'?>
<!--
# Licensed 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
#
# https://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.
-->

<playlist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../TKG/playlist.xsd">
<test>
<testCaseName>BuildTestsForSpecificVendors</testCaseName>
<command>$(JAVA_COMMAND) $(JVM_OPTIONS) -cp $(Q)$(RESOURCES_DIR)$(P)$(TESTNG)$(P)$(TEST_RESROOT)$(D)BuildTestsForSpecificVendors.jar$(Q) org.testng.TestNG $(Q)$(TEST_RESROOT)$(D)testng.xml$(Q) -d $(REPORTDIR) -testnames BuildTestsForSpecificVendors -groups $(TEST_GROUP) -excludegroups $(DEFAULT_EXCLUDE); \
$(TEST_STATUS)</command>
<levels>
<level>sanity</level>
</levels>
<groups>
<group>functional</group>
</groups>
</test>
</playlist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package net.adoptopenjdk.test.build;

import net.adoptopenjdk.test.build.common.BuildIs;
import org.testng.Assert;
import org.testng.annotations.Test;
import org.testng.log4testng.Logger;

/*
* Test description goes here.
*/
@Test(groups={ "level.sanity" })
public class TestTemplate {

private static Logger logger = Logger.getLogger(TestTemplate.class);

/**
* Returns true if, and only if, we're running on a build & platform this test
* is relevant to.
*/
private boolean rightEnvForTest() {
// BuildIs methods are used like asserts.
return BuildIs.createdByThisVendor("AdoptOpenJDK")
&& BuildIs.thisMajorVersion(8)
&& BuildIs.moreRecentThanOrEqualToVersion("1.8.0_250+b20");
}

@Test
public void testTemplateExample() {
if(!rightEnvForTest()) {
logger.info("Wrong environment for test. Skipped!");
return;
}
logger.info("Test template test starting.");
String whatWeGot = "aaa";
String whatWeWant = "aaa";
Assert.assertEquals(whatWeGot, whatWeWant, "Print this message if those two strings don't match.");
logger.info("Test completed successfully.");
}

}
Loading