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

[NR-234870] GHA Update Unit Test Action #204

Merged
merged 28 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
bc09208
Updated unit-test to run UT on diff. java version
IshikaDawda Mar 6, 2024
a7d5f29
Updated unit-test to run UT on diff. java version
IshikaDawda Mar 6, 2024
323c6da
Add test config to jetty-12
lovesh-ap Mar 7, 2024
5d10a54
rerun UTs on failure
lovesh-ap Mar 7, 2024
b7d590a
Add java matrix to run on
lovesh-ap Mar 7, 2024
e66f304
remove incorrect strategy and run UT with versions
lovesh-ap Mar 7, 2024
8523916
fix incorrect use of input variable
lovesh-ap Mar 7, 2024
6fa9233
multiple runs for UTs
lovesh-ap Mar 7, 2024
4836288
use java tool chain to skip test on lower versions
lovesh-ap Mar 7, 2024
30da7d1
use file name instead
lovesh-ap Mar 7, 2024
81c5c7c
remove use of java version and -ptest
lovesh-ap Mar 7, 2024
37c97a4
added -ptest property to unit test action
IshikaDawda Mar 7, 2024
a2cba7b
added -ptest property to unit test action
IshikaDawda Mar 7, 2024
81613e1
try with -ptest
lovesh-ap Mar 7, 2024
4b2e6c8
added -ptest property to unit test action
IshikaDawda Mar 7, 2024
c1134aa
Merge remote-tracking branch 'origin/GHA/NR-234870' into GHA/NR-234870
IshikaDawda Mar 7, 2024
b8eb23c
added -ptest property to unit test action
IshikaDawda Mar 7, 2024
49364e1
use continue-on-error
lovesh-ap Mar 7, 2024
471d006
added -ptest property to unit test action
IshikaDawda Mar 7, 2024
f52bf76
Merge branch 'develop' into GHA/NR-234870
lovesh-ap Mar 7, 2024
28162cc
add test config to jsp-3
IshikaDawda Mar 7, 2024
09814c1
add names to steps in unit test action
IshikaDawda Mar 7, 2024
a216ff4
add names to steps in unit test action
IshikaDawda Mar 7, 2024
f2ed744
Updated lettuce unit test env
IshikaDawda Mar 7, 2024
2f01a69
mark jersey tests to incompatible above java 8
IshikaDawda Mar 7, 2024
2a38ddc
mark UTs incompatible for some java versions
IshikaDawda Mar 8, 2024
4c6373c
added java 21 setup-env action
IshikaDawda Mar 8, 2024
b35538e
mark UTs incompatible for some java versions
IshikaDawda Mar 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/actions/setup-environment-inst-verifier/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ runs:
with:
distribution: 'temurin'
java-version: |
21
20
17
11
Expand All @@ -29,7 +30,8 @@ runs:
sed -i -e "s|jdk8=8|jdk8=${JAVA_HOME_8_X64}|
s|jdk11=11|jdk11=${JAVA_HOME_11_X64}|
s|jdk17=17|jdk17=${JAVA_HOME_17_X64}|
s|jdk20=20|jdk20=${JAVA_HOME_20_X64}|" gradle.properties.gha
s|jdk20=20|jdk20=${JAVA_HOME_20_X64}|
s|jdk21=21|jdk20=${JAVA_HOME_21_X64}|" gradle.properties.gha
cat gradle.properties.gha >> gradle.properties

- name: Setup Gradle
Expand Down
4 changes: 3 additions & 1 deletion .github/actions/setup-environment/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ runs:
with:
distribution: 'temurin'
java-version: |
21
20
17
11
Expand All @@ -48,7 +49,8 @@ runs:
sed -i -e "s|jdk8=8|jdk8=${JAVA_HOME_8_X64}|
s|jdk11=11|jdk11=${JAVA_HOME_11_X64}|
s|jdk17=17|jdk17=${JAVA_HOME_17_X64}|
s|jdk20=20|jdk20=${JAVA_HOME_20_X64}|" gradle.properties.gha
s|jdk20=20|jdk20=${JAVA_HOME_20_X64}|
s|jdk21=21|jdk21=${JAVA_HOME_21_X64}|" gradle.properties.gha
cat gradle.properties.gha >> gradle.properties

- name: Setup Gradle
Expand Down
39 changes: 37 additions & 2 deletions .github/actions/unit-test/action.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,45 @@
name: Instrumentation unit tests
description: Run all the instrumentation unit test.
inputs:
java-version:
description: 'The JVM Version to use'
required: true
default: '8'

runs:
using: composite

steps:
- name: Run instrumentation unit tests
- name: Run instrumentation unit tests on Java ${{ inputs.java-version }} attempt 1
id: run_tests_1
shell: bash
run: ./gradlew ${GRADLE_OPTIONS} --info test
continue-on-error: true
run: |
echo "Running attempt 1"
./gradlew ${GRADLE_OPTIONS} --info test -Ptest${{ inputs.java-version }} --continue

- name: Run instrumentation unit tests on Java ${{ inputs.java-version }} attempt 2
id: run_tests_2
shell: bash
continue-on-error: true
if: steps.run_tests_1.outcome == 'failure'
run: |
echo "Running attempt 2"
./gradlew ${GRADLE_OPTIONS} --info test -Ptest${{ inputs.java-version }} --continue

- name: Run instrumentation unit tests on Java ${{ inputs.java-version }} attempt 3
id: run_tests_3
shell: bash
continue-on-error: true
if: steps.run_tests_2.outcome == 'failure'
run: |
echo "Running attempt 3"
./gradlew ${GRADLE_OPTIONS} --info test -Ptest${{ inputs.java-version }} --continue

- name: Run instrumentation unit tests on Java ${{ inputs.java-version }} attempt 4
id: run_tests_4
shell: bash
if: steps.run_tests_3.outcome == 'failure'
run: |
echo "Running attempt 4"
./gradlew ${GRADLE_OPTIONS} --info test -Ptest${{ inputs.java-version }} --continue
8 changes: 7 additions & 1 deletion .github/workflows/X-Reusable-Build-Security-Agent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ jobs:
# this list is paginated and will be used in the verify-module job.
build-agent:
runs-on: ubuntu-20.04
strategy:
matrix:
java-version: [ 8, 11, 17 ]

steps:
- name: Checkout CSEC Repo
uses: actions/checkout@v3
Expand All @@ -79,4 +83,6 @@ jobs:

- name: Run CSEC unit tests
if: ${{ inputs.run-unit-test == 'true' }}
uses: ./.github/actions/unit-test
uses: ./.github/actions/unit-test
with:
java-version: ${{ matrix.java-version }}
7 changes: 7 additions & 0 deletions instrumentation-security/apache-log4j-3.0.0/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,10 @@ java {
languageVersion.set(JavaLanguageVersion.of(11))
}
}

test {
// These instrumentation tests only run on Java 11+ regardless of the -PtestN gradle property that is set.
onlyIf {
!project.hasProperty('test8')
}
}
4 changes: 3 additions & 1 deletion instrumentation-security/httpclient-jdk11/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ java {
}

test {
// These instrumentation tests only run on Java 11+ regardless of the -PtestN gradle property that is set.
onlyIf {
inputs.getProperties()["test.jdk"]!="jdk8"
!project.hasProperty('test8')
}
}


compileJava {
options.fork = true
options.bootstrapClasspath = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
import com.newrelic.agent.security.introspec.SecurityInstrumentationTestRunner;
import com.newrelic.agent.security.introspec.SecurityIntrospector;
import com.newrelic.api.agent.security.schema.SecurityMetaData;
import com.newrelic.security.test.marker.Java17IncompatibleTest;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;

Expand All @@ -31,6 +33,7 @@
@RunWith(SecurityInstrumentationTestRunner.class)
@InstrumentationTestConfig(includePrefixes = {"java.io","com.newrelic.agent.security.instrumentation.javaio"})
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Category({Java17IncompatibleTest.class})
public class InputStreamJdk8Test {
private static String FILE;
private static String FILE_TEMP;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ java {
}

test {
// These instrumentation tests only run on Java 9+ regardless of the -PtestN gradle property that is set.
// These instrumentation tests only run on Java 11+ regardless of the -PtestN gradle property that is set.
onlyIf {
java.toolchain.getLanguageVersion().get().asInt() > 10
!project.hasProperty('test8')
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.newrelic.agent.security.introspec.SecurityIntrospector;
import com.newrelic.api.agent.security.schema.SecurityMetaData;
import com.newrelic.security.test.marker.Java11IncompatibleTest;
import com.newrelic.security.test.marker.Java17IncompatibleTest;
import com.newrelic.security.test.marker.Java8IncompatibleTest;
import org.junit.AfterClass;
import org.junit.Assert;
Expand All @@ -30,7 +31,7 @@
import java.util.List;
import java.util.UUID;

@Category({ Java8IncompatibleTest.class, Java11IncompatibleTest.class })
@Category({ Java8IncompatibleTest.class, Java11IncompatibleTest.class, Java17IncompatibleTest.class })
@RunWith(SecurityInstrumentationTestRunner.class)
@InstrumentationTestConfig(includePrefixes = {"com.newrelic.agent.security.instrumentation.javaio.io","com.newrelic.agent.security.instrumentation.javaio"})
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
import com.newrelic.api.agent.security.schema.VulnerabilityCaseType;
import com.newrelic.api.agent.security.schema.operation.XPathOperation;
import com.newrelic.agent.security.instrumentation.xpath.javax.XPATHUtils;
import com.newrelic.security.test.marker.Java17IncompatibleTest;
import org.junit.Assert;
import org.junit.FixMethodOrder;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;
import org.w3c.dom.Document;
Expand All @@ -25,6 +27,7 @@
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@RunWith(SecurityInstrumentationTestRunner.class)
@InstrumentationTestConfig(includePrefixes = { "javax.xml.xpath", "com.sun.org.apache.xpath.internal" })
@Category({ Java17IncompatibleTest.class})
public class XPathTest {

private final String XML_DOC = "src/test/resources/Customer.xml";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.newrelic.api.agent.security.schema.AbstractOperation;
import com.newrelic.api.agent.security.schema.VulnerabilityCaseType;
import com.newrelic.api.agent.security.schema.operation.XPathOperation;
import com.newrelic.security.test.marker.Java17IncompatibleTest;
import com.sun.org.apache.xml.internal.utils.DefaultErrorHandler;
import com.sun.org.apache.xml.internal.utils.PrefixResolver;
import com.sun.org.apache.xml.internal.utils.PrefixResolverDefault;
Expand All @@ -16,6 +17,7 @@
import org.junit.Assert;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;
import org.w3c.dom.Document;
Expand All @@ -32,6 +34,7 @@
@RunWith(SecurityInstrumentationTestRunner.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@InstrumentationTestConfig(includePrefixes = { "javax.xml.xpath", "com.sun.org.apache.xpath.internal" })
@Category({ Java17IncompatibleTest.class})
public class XPathInternalTest {
private final String XML_DOC = "src/test/resources/Customer.xml";
private final String EXPRESSION = "/Customers/Customer";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
import com.newrelic.api.agent.security.schema.HttpResponse;
import com.newrelic.api.agent.security.schema.VulnerabilityCaseType;
import com.newrelic.api.agent.security.schema.operation.RXSSOperation;
import com.newrelic.security.test.marker.Java11IncompatibleTest;
import com.newrelic.security.test.marker.Java17IncompatibleTest;
import com.newrelic.security.test.marker.Java9IncompatibleTest;
import org.glassfish.grizzly.http.server.HttpServer;
import org.glassfish.grizzly.http.util.Header;
import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
Expand All @@ -26,6 +29,7 @@
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;

import javax.ws.rs.client.Client;
Expand Down Expand Up @@ -53,6 +57,7 @@

@RunWith(SecurityInstrumentationTestRunner.class)
@InstrumentationTestConfig(includePrefixes = {"com.newrelic.agent.security.instrumentation.jersey2", "org.glassfish.jersey"})
@Category({ Java9IncompatibleTest.class, Java11IncompatibleTest.class, Java17IncompatibleTest.class })
public class JerseyTests {

private static HttpServer server;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
import com.newrelic.api.agent.security.schema.HttpResponse;
import com.newrelic.api.agent.security.schema.VulnerabilityCaseType;
import com.newrelic.api.agent.security.schema.operation.RXSSOperation;
import com.newrelic.security.test.marker.Java11IncompatibleTest;
import com.newrelic.security.test.marker.Java17IncompatibleTest;
import com.newrelic.security.test.marker.Java9IncompatibleTest;
import org.glassfish.grizzly.http.server.HttpServer;
import org.glassfish.grizzly.http.util.Header;
import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
Expand All @@ -26,6 +29,7 @@
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;

import javax.ws.rs.client.Client;
Expand Down Expand Up @@ -53,6 +57,7 @@

@RunWith(SecurityInstrumentationTestRunner.class)
@InstrumentationTestConfig(includePrefixes = {"com.newrelic.agent.security.instrumentation.jersey2", "org.glassfish.jersey"})
@Category({ Java9IncompatibleTest.class, Java11IncompatibleTest.class, Java17IncompatibleTest.class })
public class JerseyTests {

private static HttpServer server;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import com.newrelic.api.agent.security.schema.HttpResponse;
import com.newrelic.api.agent.security.schema.VulnerabilityCaseType;
import com.newrelic.api.agent.security.schema.operation.RXSSOperation;
import com.newrelic.security.test.marker.Java11IncompatibleTest;
import com.newrelic.security.test.marker.Java8IncompatibleTest;
import org.glassfish.grizzly.http.server.HttpServer;
import org.glassfish.grizzly.http.util.Header;
import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
Expand All @@ -26,6 +28,7 @@
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;

import jakarta.ws.rs.client.Client;
Expand Down Expand Up @@ -53,6 +56,7 @@

@RunWith(SecurityInstrumentationTestRunner.class)
@InstrumentationTestConfig(includePrefixes = {"com.newrelic.agent.security.instrumentation.jersey2", "org.glassfish.jersey"})
@Category({Java8IncompatibleTest.class, Java11IncompatibleTest.class})
public class JerseyTests {

private static HttpServer server;
Expand Down
8 changes: 8 additions & 0 deletions instrumentation-security/jetty-11/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ java {
}
}

test {
// These instrumentation tests only run on Java 11+ regardless of the -PtestN gradle property that is set.
onlyIf {
!project.hasProperty('test8')
}
}


site {
title 'Jetty'
type 'Appserver'
Expand Down
7 changes: 7 additions & 0 deletions instrumentation-security/jetty-12/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ java {
}
}

test {
// These instrumentation tests only run on Java 17+ regardless of the -PtestN gradle property that is set.
onlyIf {
!project.hasProperty('test8') && !project.hasProperty('test11')
}
}

site {
title 'Jetty'
type 'Appserver'
Expand Down
7 changes: 7 additions & 0 deletions instrumentation-security/jsp-3/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ java {
}
}

test {
// These instrumentation tests only run on Java 11+ regardless of the -PtestN gradle property that is set.
onlyIf {
!project.hasProperty('test8')
}
}

site {
title 'JSP'
type 'Other'
Expand Down
3 changes: 2 additions & 1 deletion instrumentation-security/ldaptive-2.0/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ java {
}

test {
// These instrumentation tests only run on Java 11+ regardless of the -PtestN gradle property that is set.
onlyIf {
inputs.getProperties()["test.jdk"]!="jdk8" && inputs.getProperties()["test.jdk"]!="jdk9" && inputs.getProperties()["test.jdk"]!="jdk10"
!project.hasProperty('test8')
}
}

Expand Down
2 changes: 1 addition & 1 deletion instrumentation-security/lettuce-4.3/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ dependencies {
implementation("com.newrelic.agent.java:newrelic-api:${nrAPIVersion}")
implementation("com.newrelic.agent.java:newrelic-weaver-api:${nrAPIVersion}")
implementation("biz.paluch.redis:lettuce:4.4.0.Final")
testImplementation("com.github.codemonstur:embedded-redis:1.0.0")
testImplementation('org.testcontainers:testcontainers:1.17.1')
}

jar {
Expand Down
Loading
Loading