Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
breedx-splk committed Apr 4, 2023
2 parents c40221f + e0ecb56 commit d8bf9b0
Show file tree
Hide file tree
Showing 15 changed files with 245 additions and 8,280 deletions.
38 changes: 30 additions & 8 deletions .github/workflows/build-common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ jobs:
exit 1
fi
assemble:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -107,15 +107,19 @@ jobs:
distribution: temurin
java-version: 17

- name: Assemble
- name: Increase gradle daemon heap size
run: |
sed -i "s/org.gradle.jvmargs=/org.gradle.jvmargs=-Xmx3g /" gradle.properties
- name: Build
uses: gradle/gradle-build-action@v2
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
GE_CACHE_USERNAME: ${{ secrets.GE_CACHE_USERNAME }}
GE_CACHE_PASSWORD: ${{ secrets.GE_CACHE_PASSWORD }}
with:
# javadoc task fails sporadically fetching https://docs.oracle.com/javase/8/docs/api/
arguments: assemble -x javadoc ${{ inputs.no-build-cache && '--no-build-cache' || '' }}
arguments: check -x javadoc -x spotlessCheck -PskipTests=true ${{ inputs.no-build-cache && '--no-build-cache' || '' }}
cache-read-only: ${{ inputs.cache-read-only }}
# gradle enterprise is used for the build cache
gradle-home-cache-excludes: caches/build-cache-1
Expand Down Expand Up @@ -194,6 +198,26 @@ jobs:
- name: Start deadlock detector
run: .github/scripts/deadlock-detector.sh

- name: List tests
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
GE_CACHE_USERNAME: ${{ secrets.GE_CACHE_USERNAME }}
GE_CACHE_PASSWORD: ${{ secrets.GE_CACHE_PASSWORD }}
uses: gradle/gradle-build-action@v2
with:
# "check" is needed to activate all tests for listing purposes
# listTestsInPartition writes test tasks that apply to the given partition to a file named
# "test-tasks.txt" and then disables all tasks (including tests) after it runs
arguments: >
check -x spotlessCheck
listTestsInPartition
-PtestPartition=${{ matrix.test-partition }}
cache-read-only: true

- name: Set test tasks
run: |
echo "test-tasks=$(cat test-tasks.txt | xargs echo | sed 's/\n/ /g')" >> $GITHUB_ENV
- name: Test
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
Expand All @@ -203,13 +227,11 @@ jobs:
with:
# spotless is checked separately since it's a common source of failure
arguments: >
check
-x spotlessCheck
${{ env.test-tasks }}
-PtestJavaVersion=${{ matrix.test-java-version }}
-PtestJavaVM=${{ matrix.vm }}
-Porg.gradle.java.installations.paths=${{ steps.setup-test-java.outputs.path }}
-Porg.gradle.java.installations.auto-download=false
-PtestPartition=${{ matrix.test-partition }}
${{ inputs.no-build-cache && ' --no-build-cache' || '' }}
# only push cache for one matrix option since github action cache space is limited
cache-read-only: ${{ inputs.cache-read-only || matrix.test-java-version != 11 || matrix.vm != 'hotspot' }}
Expand All @@ -220,15 +242,15 @@ jobs:
if: failure()
uses: actions/upload-artifact@v3
with:
name: deadlock-detector-test-${{ matrix.test-java-version }}-${{ matrix.vm }}
name: deadlock-detector-test-${{ matrix.test-java-version }}-${{ matrix.vm }}-${{ matrix.test-partition }}
path: /tmp/deadlock-detector-*
if-no-files-found: ignore

- name: Upload jvm crash dump files if any
if: failure()
uses: actions/upload-artifact@v3
with:
name: javacore-test-${{ matrix.test-java-version }}
name: javacore-test-${{ matrix.test-java-version }}-${{ matrix.test-partition }}
path: |
**/hs_err_pid*.log
**/javacore.*.txt
Expand Down
27 changes: 19 additions & 8 deletions .github/workflows/reusable-test-latest-deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,6 @@ jobs:
distribution: temurin
java-version: 17

# vaadin 14 tests fail with node 18
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: 16

# vaadin tests use pnpm
- name: Cache pnpm modules
uses: actions/cache@v3
Expand All @@ -55,6 +49,24 @@ jobs:
run: |
sed -i "s/org.gradle.jvmargs=/org.gradle.jvmargs=-Xmx3g /" gradle.properties
- name: List tests
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
GE_CACHE_USERNAME: ${{ secrets.GE_CACHE_USERNAME }}
GE_CACHE_PASSWORD: ${{ secrets.GE_CACHE_PASSWORD }}
uses: gradle/gradle-build-action@v2
with:
arguments: >
check -x spotlessCheck
listTestsInPartition
-PtestPartition=${{ matrix.test-partition }}
-PtestLatestDeps=true
cache-read-only: true

- name: Set test tasks
run: |
echo "test-tasks=$(cat test-tasks.txt | xargs echo | sed 's/\n/ /g')" >> $GITHUB_ENV
- name: Test
uses: gradle/gradle-build-action@v2
env:
Expand All @@ -63,9 +75,8 @@ jobs:
GE_CACHE_PASSWORD: ${{ secrets.GE_CACHE_PASSWORD }}
with:
arguments: >
test
${{ env.test-tasks }}
-PtestLatestDeps=true
-PtestPartition=${{ matrix.test-partition }}
${{ inputs.no-build-cache && ' --no-build-cache' || '' }}
cache-read-only: ${{ inputs.cache-read-only }}
# gradle enterprise is used for the build cache
Expand Down
69 changes: 60 additions & 9 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,68 @@ nexusPublishing {

description = "OpenTelemetry instrumentations for Java"

// total of 4 partitions (see modulo 4 below)
var testPartition = (project.findProperty("testPartition") as String?)?.toInt()
if (testPartition != null) {
var testPartitionCounter = 0
if (project.findProperty("skipTests") as String? == "true") {
subprojects {
// relying on predictable ordering of subprojects
// (see https://docs.gradle.org/current/dsl/org.gradle.api.Project.html#N14CB4)
// since we are splitting these tasks across different github action jobs
val enabled = testPartitionCounter++ % 4 == testPartition
tasks.withType<Test>().configureEach {
this.enabled = enabled
enabled = false
}
}
}

tasks {
val listTestsInPartition by registering {
group = "Help"
description = "List test tasks in given partition"

// total of 4 partitions (see modulo 4 below)
var testPartition = (project.findProperty("testPartition") as String?)?.toInt()
if (testPartition == null) {
throw GradleException("Test partition must be specified")
} else if (testPartition < 0 || testPartition >= 4) {
throw GradleException("Invalid test partition")
}

val partitionTasks = ArrayList<Test>()
var testPartitionCounter = 0
subprojects {
// relying on predictable ordering of subprojects
// (see https://docs.gradle.org/current/dsl/org.gradle.api.Project.html#N14CB4)
// since we are splitting these tasks across different github action jobs
val enabled = testPartitionCounter++ % 4 == testPartition
if (enabled) {
tasks.withType<Test>().configureEach {
partitionTasks.add(this)
}
}
}

doLast {
File("test-tasks.txt").printWriter().use { writer ->
partitionTasks.forEach { task ->
var taskPath = task.project.path + ":" + task.name
// smoke tests are run separately
// :instrumentation:test runs all instrumentation tests
if (taskPath != ":smoke-tests:test" && taskPath != ":instrumentation:test") {
writer.println(taskPath)
}
}
}
}

// disable all tasks to stop build
subprojects {
tasks.configureEach {
enabled = false
}
}
}
}

if (gradle.startParameter.taskNames.any { it.equals("listTestsInPartition") }) {
// disable all tasks to stop build
project.tasks.configureEach {
if (this.name != "listTestsInPartition") {
enabled = false
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ class KafkaStreamsSuppressReceiveSpansTest extends KafkaStreamsBaseTest {
"$SemanticAttributes.MESSAGING_KAFKA_MESSAGE_KEY" "10"
"kafka.record.queue_time_ms" { it >= 0 }
"asdf" "testing"
if (Boolean.getBoolean("testLatestDeps")) {
"$SemanticAttributes.MESSAGING_KAFKA_CONSUMER_GROUP" "test-application"
"$SemanticAttributes.MESSAGING_CONSUMER_ID" { it.startsWith("test-application - ") }
}
}
}

Expand Down Expand Up @@ -147,7 +151,7 @@ class KafkaStreamsSuppressReceiveSpansTest extends KafkaStreamsBaseTest {
"$SemanticAttributes.MESSAGING_DESTINATION_NAME" STREAM_PROCESSED
"$SemanticAttributes.MESSAGING_DESTINATION_KIND" "topic"
"$SemanticAttributes.MESSAGING_OPERATION" "process"
"$SemanticAttributes.MESSAGING_KAFKA_CLIENT_ID" "consumer-1"
"$SemanticAttributes.MESSAGING_KAFKA_CLIENT_ID" { it.startsWith("consumer") }
"$SemanticAttributes.MESSAGING_MESSAGE_PAYLOAD_SIZE_BYTES" Long
"$SemanticAttributes.MESSAGING_KAFKA_SOURCE_PARTITION" { it >= 0 }
"$SemanticAttributes.MESSAGING_KAFKA_MESSAGE_OFFSET" 0
Expand Down
13 changes: 9 additions & 4 deletions instrumentation/vaadin-14.2/javaagent/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ dependencies {
testInstrumentation(project(":instrumentation:servlet:servlet-3.0:javaagent"))
testInstrumentation(project(":instrumentation:servlet:servlet-javax-common:javaagent"))
testInstrumentation(project(":instrumentation:tomcat:tomcat-7.0:javaagent"))
testInstrumentation(project(":instrumentation:servlet:servlet-5.0:javaagent"))
testInstrumentation(project(":instrumentation:tomcat:tomcat-10.0:javaagent"))
}

testing {
Expand Down Expand Up @@ -83,10 +85,13 @@ tasks {
}
}
}

configurations.configureEach {
resolutionStrategy {
// requires old logback (and therefore also old slf4j)
force("ch.qos.logback:logback-classic:1.2.11")
force("org.slf4j:slf4j-api:1.7.36")
if (!this.name.startsWith("vaadinLatestTest")) {
resolutionStrategy {
// requires old logback (and therefore also old slf4j)
force("ch.qos.logback:logback-classic:1.2.11")
force("org.slf4j:slf4j-api:1.7.36")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,58 +5,6 @@

package test.io.opentelemetry.javaagent.instrumentation.vaadin;

import static net.bytebuddy.matcher.ElementMatchers.named;

import io.opentelemetry.javaagent.instrumentation.vaadin.AbstractVaadin14Test;
import java.io.File;
import java.lang.instrument.Instrumentation;
import java.net.URISyntaxException;
import net.bytebuddy.agent.ByteBuddyAgent;
import net.bytebuddy.agent.builder.AgentBuilder;
import net.bytebuddy.asm.Advice;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;

@ExtendWith(MockitoExtension.class)
public class Vaadin14LatestTest extends AbstractVaadin14Test {

static class UpdatePackageAdvice {
@Advice.OnMethodEnter(skipOn = Advice.OnDefaultValue.class)
public static Object onEnter() {
return null;
}

@SuppressWarnings("UnusedVariable")
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
public static void methodExit(@Advice.Return(readOnly = false) boolean result) {
result = false;
}
}

@BeforeAll
@Override
protected void setup() throws URISyntaxException {
// Prevent vaadin from regenerating package.json & pnpm-lock.yaml
// Vaadin adds a hash to package.json that includes path to node_modules directory, so it won't
// be same on all computers. To avoid vaadin replacing our provided package.json we suppress the
// package.json modification check.
Instrumentation instrumentation = ByteBuddyAgent.install();
new AgentBuilder.Default()
.type(named("com.vaadin.flow.server.frontend.TaskUpdatePackages"))
.transform(
new AgentBuilder.Transformer.ForAdvice()
.advice(
named("updatePackageJsonDependencies"), UpdatePackageAdvice.class.getName()))
.installOn(instrumentation);

super.setup();
}

@Override
@SuppressWarnings("checkstyle:SystemOut")
protected void prepareVaadinBaseDir(File baseDir) {
copyResource("/pnpm/package.json", baseDir);
copyResource("/pnpm/pnpm-lock.yaml", baseDir);
}
}
public class Vaadin14LatestTest extends AbstractVaadin14Test {}
Loading

0 comments on commit d8bf9b0

Please sign in to comment.