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

Add integration test framework #687

Merged
Merged
Changes from 14 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
6a7629a
Add integration test task that uses the OpenSearch gradle plugin
ryanbogan Apr 18, 2023
7c5cf1f
Merge main into add_integ_test_framework
ryanbogan Apr 19, 2023
52dda1c
Added closeTestExtension task to kill testExtension process
ryanbogan Apr 19, 2023
17be5bf
Fix spotless
ryanbogan Apr 19, 2023
a45ac35
Merge branch 'main' into add_integ_test_framework
ryanbogan Apr 21, 2023
53bbf1d
Merge main into add_integ_test_framework
ryanbogan May 1, 2023
3d96e32
Implement resolution strategy to fix dependency conflict
ryanbogan May 8, 2023
afba241
Merge branch 'main' into add_integ_test_framework
ryanbogan May 8, 2023
af6904e
Minor adjustment
ryanbogan May 9, 2023
ea2f1f0
Merge branch 'main' into add_integ_test_framework
ryanbogan May 9, 2023
b0d742a
Merge branch 'main' into add_integ_test_framework
ryanbogan May 10, 2023
d0c9ed8
Change jackson version
ryanbogan May 10, 2023
78a0c3b
Change jackson dataformat version
ryanbogan May 10, 2023
476263e
Revert jackson version change
ryanbogan May 10, 2023
f60262b
Merge branch 'main' into add_integ_test_framework
ryanbogan May 11, 2023
1b602a5
Add resolution strategy to fix jackson dependency conflict
ryanbogan May 12, 2023
e1c389b
Address PR Comments
ryanbogan May 12, 2023
94d2b99
Merge branch 'main' into add_integ_test_framework
ryanbogan May 15, 2023
9f37e54
Add new implementation to fix error from separate merge
ryanbogan May 15, 2023
e2d16e0
Address PR Comments
ryanbogan May 16, 2023
660e29c
Address PR Comments
ryanbogan May 16, 2023
71c92be
Revert minor change
ryanbogan May 16, 2023
e2485fb
Address PR Comments
ryanbogan May 16, 2023
85d48ba
Add reading from yaml for testExtensionCreation
ryanbogan May 16, 2023
383e7a5
Spotless
ryanbogan May 16, 2023
71b43c4
Minor change
ryanbogan May 16, 2023
a921cf1
Debug test commit
ryanbogan May 17, 2023
4f0bc31
Merge branch 'main' into add_integ_test_framework
saratvemulapalli May 22, 2023
9e46836
Merge main into add_integ_test-framework
ryanbogan May 23, 2023
d54c143
Minor changes
ryanbogan May 23, 2023
b2c87bd
Merge branch 'add_integ_test_framework' of github.com:ryanbogan/opens…
ryanbogan May 23, 2023
1aa03ec
Remove extra test class
ryanbogan May 23, 2023
e7e9eea
Merge branch 'main' into add_integ_test_framework
owaiskazi19 May 23, 2023
c49abcf
Merge branch 'main' into add_integ_test_framework
ryanbogan May 24, 2023
3d5f1d0
Add index
ryanbogan May 24, 2023
342caa1
Fix inadvertent change
ryanbogan May 24, 2023
7f0fd39
Minor change
ryanbogan May 24, 2023
80c1fc2
Merge main into add_integ_test_framework
ryanbogan May 25, 2023
e7540d8
Add log4j resolution strategy
ryanbogan May 25, 2023
bdadfa7
Remove testing println
ryanbogan May 25, 2023
2db7e35
Merge branch 'main' into add_integ_test_framework
ryanbogan May 26, 2023
bc8654c
Merge branch 'main' into add_integ_test_framework
ryanbogan May 30, 2023
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
167 changes: 151 additions & 16 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,26 @@

import java.nio.file.Files
import org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestFramework
import org.opensearch.gradle.test.RestIntegTestTask
import org.opensearch.gradle.testclusters.ExtensionsProperties

buildscript {
ext {
opensearch_version = System.getProperty("opensearch.version", "3.0.0-SNAPSHOT")
isSnapshot = "true" == System.getProperty("build.snapshot", "true")
buildVersionQualifier = System.getProperty("build.version_qualifier", "")
ryanbogan marked this conversation as resolved.
Show resolved Hide resolved
}

repositories {
mavenLocal()
mavenCentral()
maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" }
}

dependencies {
classpath "org.opensearch.gradle:build-tools:${opensearch_version}"
}
}

plugins {
id 'java-library'
Expand All @@ -22,21 +42,49 @@ plugins {
}


apply from: 'gradle/formatting.gradle'
apply plugin: 'maven-publish'
apply plugin: 'opensearch.opensearchplugin'
apply plugin: 'opensearch.testclusters'

opensearchplugin {
joshpalis marked this conversation as resolved.
Show resolved Hide resolved
ryanbogan marked this conversation as resolved.
Show resolved Hide resolved
name 'opensearch-sdk-java'
description 'OpenSearch Software Development Kit'
classname 'Sample Class'
joshpalis marked this conversation as resolved.
Show resolved Hide resolved
}

ext {
projectSubstitutions = [:]
licenseFile = rootProject.file('LICENSE.txt')
noticeFile = rootProject.file('NOTICE.txt')
}

dependencyLicenses.enabled = false
thirdPartyAudit.enabled = false
loggerUsageCheck.enabled = false
forbiddenApisMain.enabled = false
forbiddenApisTest.enabled = false
filepermissions.enabled = false
forbiddenPatterns.enabled = false
testingConventions.enabled = false
validateNebulaPom.enabled = false
ryanbogan marked this conversation as resolved.
Show resolved Hide resolved

def _numNodes = 1

allprojects {
project.ext.licenseName = 'The Apache Software License, Version 2.0'
project.ext.licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
group = 'org.opensearch'
version = opensearch_version.tokenize('-')[0] + '.0'
if (buildVersionQualifier) {
version += "-${buildVersionQualifier}"
}
if (isSnapshot) {
version += "-SNAPSHOT"
}
}

apply plugin: 'application'
apply from: 'gradle/formatting.gradle'
apply plugin: 'maven-publish'

// Temporary to keep "gradle run" working
// TODO: change this to an extension designed for testing instead of duplicating a sample
// https://github.com/opensearch-project/opensearch-sdk-java/issues/175
mainClassName = 'org.opensearch.sdk.sample.helloworld.HelloWorldExtension'


group 'org.opensearch.sdk'
Expand All @@ -49,14 +97,26 @@ java {

publishing {
publications {
group = "${group}"
version = "${version}"
mavenJava(MavenPublication) {
from components.java
}
sourceCompatibility = 11
targetCompatibility = 11
}
// add license information to generated poms
all {
pom {
name = "opensearch-sdk-java"
description = "OpenSearch SDK"
}
pom.withXml { XmlProvider xml ->
Node node = xml.asNode()
node.appendNode('inceptionYear', '2022')

Node license = node.appendNode('licenses').appendNode('license')
license.appendNode('name', project.licenseName)
license.appendNode('url', project.licenseUrl)

Node developer = node.appendNode('developers').appendNode('developer')
developer.appendNode('name', 'OpenSearch')
owaiskazi19 marked this conversation as resolved.
Show resolved Hide resolved
developer.appendNode('url', 'https://github.com/opensearch-project/opensearch-sdk-java')
}
}
}

repositories {
maven {
Expand All @@ -77,10 +137,14 @@ repositories {
maven { url "https://d1nvenhzbhpy0q.cloudfront.net/snapshots/lucene/"}
}

configurations.all {
resolutionStrategy.force("jakarta.json:jakarta.json-api:2.1.1")
}

dependencies {

def opensearchVersion = "3.0.0-SNAPSHOT"
def log4jVersion = "2.20.0"
def log4jVersion = "2.17.1"
ryanbogan marked this conversation as resolved.
Show resolved Hide resolved
def nettyVersion = "4.1.92.Final"
def jacksonDatabindVersion = "2.15.0"
def guavaVersion = "31.1-jre"
Expand Down Expand Up @@ -108,6 +172,13 @@ dependencies {
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${jacksonDatabindVersion}")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:${jacksonDatabindVersion}")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-guava:${jacksonDatabindVersion}")
implementation("com.fasterxml.jackson.core:jackson-annotations:${jacksonDatabindVersion}")

implementation("com.google.guava:guava:${guavaVersion}")
implementation('javax.inject:javax.inject:1')
implementation('com.google.guava:failureaccess:1.0.1')
implementation('aopalliance:aopalliance:1.0')
owaiskazi19 marked this conversation as resolved.
Show resolved Hide resolved

constraints {
implementation("com.google.guava:guava:${guavaVersion}") {
because 'versions below 30.0 have active CVE'
Expand Down Expand Up @@ -182,3 +253,67 @@ diffCoverageReport {
failOnViolation = true
}
}

task integTest(type: RestIntegTestTask) {
description = "Run tests against a cluster"
testClassesDirs = sourceSets.test.output.classesDirs
ryanbogan marked this conversation as resolved.
Show resolved Hide resolved
classpath = sourceSets.test.runtimeClasspath
}
//tasks.named("check").configure { dependsOn(integTest) }

task startTestExtension(type: Exec) {
commandLine 'bash', '-c', "./gradlew helloWorld &"
}

integTest {
dependsOn(startTestExtension)
systemProperty 'tests.security.manager', 'false'
owaiskazi19 marked this conversation as resolved.
Show resolved Hide resolved

systemProperty "https", System.getProperty("https")
systemProperty "user", System.getProperty("user")
systemProperty "password", System.getProperty("password")

// The 'doFirst' delays till execution time.
doFirst {
// Tell the test JVM if the cluster JVM is running under a debugger so that tests can
// use longer timeouts for requests.
def isDebuggingCluster = getDebug() || System.getProperty("test.debug") != null
systemProperty 'cluster.debug', isDebuggingCluster
// Set number of nodes system property to be used in tests
systemProperty 'cluster.number_of_nodes', "1"
// There seems to be an issue when running multi node run or integ tasks with unicast_hosts
// not being written, the waitForAllConditions ensures it's written
getClusters().forEach { cluster ->
cluster.waitForAllConditions()
}
}

// The --debug-jvm command-line option makes the cluster debuggable; this makes the tests debuggable
ryanbogan marked this conversation as resolved.
Show resolved Hide resolved
if (System.getProperty("test.debug") != null) {
jvmArgs '-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005'
}
}

task closeTestExtension (type: Exec) {
commandLine 'bash', '-c', "kill \$(lsof -i:4532)"
ryanbogan marked this conversation as resolved.
Show resolved Hide resolved
}

tasks.named("integTest").configure { finalizedBy(closeTestExtension) }

testClusters.integTest {
extension(new ExtensionsProperties("hello-world", "opensearch-sdk-java-1", "127.0.0.1", "4532", "1.0", "3.0.0", "3.0.0"))
ryanbogan marked this conversation as resolved.
Show resolved Hide resolved
testDistribution = "ARCHIVE"
// Cluster shrink exception thrown if we try to set numberOfNodes to 1, so only apply if > 1
if (_numNodes > 1) numberOfNodes = _numNodes
ryanbogan marked this conversation as resolved.
Show resolved Hide resolved
// When running integration tests it doesn't forward the --debug-jvm to the cluster anymore
// i.e. we have to use a custom property to flag when we want to debug elasticsearch JVM
// since we also support multi node integration tests we increase debugPort per node
if (System.getProperty("opensearch.debug") != null) {
def debugPort = 5005
nodes.forEach { node ->
node.jvmArgs("-agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=*:${debugPort}")
debugPort += 1
}
}

}