-
Notifications
You must be signed in to change notification settings - Fork 337
Base Mule 4 instrumentation with HTTP Server Test #2438
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,142 @@ | ||
| ext { | ||
| minJavaVersionForTests = JavaVersion.VERSION_1_8 | ||
| } | ||
|
|
||
| muzzle { | ||
| extraRepository('anypoint-releases', 'https://maven.anypoint.mulesoft.com/api/v2/maven') | ||
| extraRepository('mulesoft-releases', 'https://repository.mulesoft.org/releases') | ||
| extraRepository('mulesoft-public', 'https://repository.mulesoft.org/nexus/content/repositories/public') | ||
|
|
||
| pass { | ||
| group = 'org.mule.runtime' | ||
| module = 'mule-core' | ||
| versions = '[,]' | ||
| assertInverse = true | ||
| } | ||
|
|
||
| fail { | ||
| group = 'org.mule' | ||
| module = 'mule-core' | ||
| versions = '[3.2.0,)' // First version where muzzle can resolve all dependencies | ||
| } | ||
| } | ||
|
|
||
| apply from: "$rootDir/gradle/java.gradle" | ||
|
|
||
| def muleVersion = '4.2.2' | ||
| def muleBaseDir = "$buildDir/mule" | ||
| def appDir = "$projectDir/mule-application" | ||
| def generatedResourcesDir = "$buildDir/generated-resources/test" | ||
|
|
||
| clean.doFirst { | ||
| delete muleBaseDir | ||
| } | ||
|
|
||
| repositories { | ||
| maven { | ||
| name "anypoint-releases" | ||
| url "https://maven.anypoint.mulesoft.com/api/v2/maven" | ||
| } | ||
| maven { | ||
| name "mulesoft-releases" | ||
| url "https://repository.mulesoft.org/releases" | ||
| } | ||
| maven { | ||
| name "mulesoft-public" | ||
| url "https://repository.mulesoft.org/nexus/content/repositories/public" | ||
| } | ||
| } | ||
|
|
||
| configurations { | ||
| muleServices | ||
| } | ||
|
|
||
| configurations.all { | ||
| // don't allow mule to do slf4j over log4j | ||
| exclude group: 'org.apache.logging.log4j', module: 'log4j-slf4j-impl' | ||
| } | ||
|
|
||
| sourceSets { | ||
| test { | ||
| output.dir(generatedResourcesDir, builtBy: 'generateAppResources') | ||
| } | ||
| } | ||
|
|
||
| compileTestGroovy { | ||
| dependsOn 'mvnPackage', 'extractMuleServices' | ||
| } | ||
|
|
||
| dependencies { | ||
| main_java8CompileOnly group: 'org.mule.runtime', name: 'mule-core', version: muleVersion | ||
|
|
||
| testImplementation project(':dd-java-agent:instrumentation:reactor-core-3.1') | ||
| testImplementation project(':dd-java-agent:instrumentation:grizzly-http-2.3.20') | ||
| testImplementation group: 'org.mule.runtime', name: 'mule-module-launcher', version: muleVersion | ||
| testImplementation group: 'org.mule.runtime', name: 'mule-core', version: muleVersion | ||
| testImplementation group: 'org.mule.runtime', name: 'mule-module-extensions-spring-support', version: muleVersion | ||
| testImplementation group: 'org.mule.runtime', name: 'mule-module-service', version: muleVersion | ||
| // this is needed for mule to find removed javax.* APIs on Java 11+ | ||
| testImplementation group: 'org.mule.runtime', name: 'mule-module-javaee', version: muleVersion | ||
|
|
||
| muleServices group: 'org.mule.services', name: 'mule-service-http', version: '1.4.7', classifier: 'mule-service' | ||
| muleServices group: 'org.mule.services', name: 'mule-service-scheduler', version: '1.2.4', classifier: 'mule-service' | ||
| muleServices group: 'org.mule.services', name: 'mule-service-weave', version: '2.2.2', classifier: 'mule-service' | ||
| } | ||
|
|
||
| // extract the enabled services into the mule base directory | ||
| task extractMuleServices(type: Sync) { | ||
| dependsOn configurations.muleServices | ||
|
|
||
| configurations.muleServices.resolvedConfiguration.resolvedArtifacts.findAll { | ||
| it.classifier == "mule-service" | ||
| } collect { artifact -> | ||
| def id = artifact.moduleVersion.id | ||
| from(zipTree(artifact.file)) { | ||
| into("${id.name}-${id.version}") | ||
| } | ||
| } | ||
|
|
||
| into "$muleBaseDir/services" | ||
| } | ||
|
|
||
| // build the mule application via maven | ||
| task mvnPackage(type:Exec) { | ||
| workingDir "$appDir" | ||
| commandLine 'mvn', "-Ddatadog.builddir=$buildDir", "-Ddatadog.name=mule-http-test-server", "-Ddatadog.version=$version", 'package' | ||
| outputs.dir("$buildDir/target") | ||
| inputs.dir("$appDir/src") | ||
| inputs.file("$appDir/pom.xml") | ||
| inputs.file("$appDir/mule-artifact.json") | ||
|
bantonsson marked this conversation as resolved.
|
||
| } | ||
|
|
||
| // generate a properties file so the test knows where to run mule, and what jar to deploy | ||
| task generateAppResources { | ||
| outputs.dir generatedResourcesDir | ||
| doLast { | ||
| def generated = new File(generatedResourcesDir, "test-build.properties") | ||
| generated.text = """|mule.base=$muleBaseDir | ||
| |MuleHttpServerTest.jar=$buildDir/target/mule-http-test-server-$version-mule-application.jar | ||
| |MuleHttpServerTest.name=mule-http-test-server-$version-mule-application""".stripMargin() | ||
| } | ||
| } | ||
|
|
||
| tasks.test { | ||
| outputs.upToDateWhen { | ||
| !mvnPackage.didWork && !extractMuleServices.didWork | ||
| } | ||
| } | ||
|
|
||
| spotless { | ||
| java { | ||
| target fileTree("$appDir/src") { | ||
| include "**/*.java" | ||
| } | ||
| } | ||
| format 'xml', { | ||
| target fileTree('.') { | ||
| include '**/*.xml', '**/*.xsd' | ||
| exclude '**/build/**', '**/target/**' | ||
| } | ||
| eclipseWtp('xml').configFile(project.rootProject.rootDir.path + '/gradle/enforcement/spotless-xml.properties') | ||
| } | ||
| } | ||
1 change: 1 addition & 0 deletions
1
dd-java-agent/instrumentation/mule-4/mule-application/.gitignore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| .mule |
28 changes: 28 additions & 0 deletions
28
dd-java-agent/instrumentation/mule-4/mule-application/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # Working with the Mule Application | ||
|
|
||
| This directory contains a Mule application. It is built using maven, and unless | ||
| you know your Mule xml by heart the _easiest_ way is to download | ||
| [Anypoint Studio 7](https://www.mulesoft.com/lp/dl/studio). | ||
|
|
||
| ## Configure Anypoint Studio | ||
|
|
||
| This Mule Application is currently built using version `4.2.2.` of Mule, so to avoid | ||
| problems, it is best to install the `4.2.2` runtime into Anypoint Studio. | ||
|
|
||
| Follow the instructions on how to [install a different mule runtime](https://mulesy.com/install-different-mule-runtime-version-in-studio/), | ||
| and select the `4.2.2 EE` version. | ||
|
|
||
| > **_Note:_** As of version 4 of Mule, there is no longer an update site that provides | ||
| > community versions of the Mule runtime, so the Enterprise Edition needs to be installed, | ||
| > even though the application can't use any of them. | ||
|
|
||
| ## Importing the project into Anypoint Studio | ||
|
|
||
| * Start Anypoint Studio and create a _workspace_ somewhere unrelated to this directory. | ||
| * From the menu, select: **File** -> **Import...**. | ||
| * In the import dialog select: **Anypoint Studio** -> **Anypoint Studio project from File System**. | ||
| * Uncheck the **Copy project into workspace** checkbox. | ||
| * Select this directory as **Project Root**. | ||
| * Change **Server Runtime** to **Mule Server 4.2.2 EE**. | ||
| * Make sure that you have **unchecked** the **Copy project into workspace** checkbox. | ||
| * Press **Finish**. |
3 changes: 3 additions & 0 deletions
3
dd-java-agent/instrumentation/mule-4/mule-application/mule-artifact.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "minMuleVersion": "4.2.2" | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.