Elasticsearch.esplugin: Replace/Change/Disable integTestCluster#wait Task


(Varun Sharma) #1

I am trying to use elasticsearch.esplugin for integration tests on my plugin (Have already Set those up for Maven: david.pilato.fr/blog/2016/10/18/elasticsearch-real-integration-tests-updated-for-ga/) but as soon as I use it, I get loads of errors telling me to write param descriptions, etc.

I have already set:
checkstyleMain.enabled = false
checkstyleTest.enabled = false

And i wish to replace the elasticsearch.yml with mine (Custom Settings) and add another file to the same
Config folder before starting the ES Cluster.
Seems like I have to access this :-

But how?

I'm unable to find any docs on this, any Ideas?

Edit:

I'm running into: "Elasticsearch cluster failed to pass wait condition"
Now the thing is that, my plugin implements security and is expected to return 403 upon pining without JWT Token, How shall I change the task 'integTestCluster#wait'? to expect 403?


(David Pilato) #2

For another project with gradle, I used something like:

buildscript {
    repositories {
        mavenLocal()
        mavenCentral()
        jcenter()
    }

    dependencies {
        classpath "org.elasticsearch.gradle:build-tools:6.0.0"
    }
}

apply plugin: 'java'
apply plugin: 'elasticsearch.esplugin'
apply plugin: 'idea'
apply plugin: 'maven'

// this is temporal and will be fixed in 6.0
ext.projectSubstitutions = [:]

// license of this project
licenseFile = rootProject.file('LICENSE.txt')
// copyright notices
noticeFile = rootProject.file('NOTICE.txt')

esplugin {
    // license of the plugin, may be different than the above license
    licenseFile rootProject.file('LICENSE.txt')
    // copyright notices, may be different than the above notice
    noticeFile rootProject.file('NOTICE.txt')
    name 'foo'
    description 'foo'
    classname 'fr.pilato.elasticsearch.plugin.foo.FooPlugin'
}

repositories {
    mavenLocal()
    mavenCentral()
    jcenter()
}

// In this section you declare the dependencies for your production and test code
// Elasticsearch dependency is included due to the build-tools, test-framework as well
dependencies {
    testCompile 'org.elasticsearch.client:elasticsearch-rest-high-level-client:6.0.0'
}

integTestCluster {
    setting 'foo.whatever.setting',     'bar'
}

thirdPartyAudit.excludes = [
        // classes are missing
        'javax.servlet.ServletConfig',
        'javax.servlet.ServletContext',
        'javax.servlet.ServletContextEvent',
        //... Skipped for clarity
]

artifacts {
    archives javadocJar, sourcesJar
}

I hope this could help. (May be)... :slight_smile:

Note that I'm using 6.0 here.


Elasticsearch Maven Plugin using gradle
(Varun Sharma) #3

Thanks! Btw, I'm running into: "Elasticsearch cluster failed to pass wait condition"
Now the thing is that, my plugin implements security and is expected to return 403 upon pining without JWT Token, How shall I change the task 'integTestCluster#wait'? to expect 403?


(David Pilato) #4

I dunno... :stuck_out_tongue:


(Varun Sharma) #5

Will it work if I change this :-

Follow Up question, how to change it from build.gradle?

See, there is this Task:
task ':integTestCluster#init'

Which creates:
'integTestCluster#checkPrevious', 'integTestCluster#clean', 'integTestCluster#configure', 'integTestCluster#copyPlugins', 'integTestCluster#extraConfig', 'integTestCluster#extract', 'integTestCluster#init', 'integTestCluster#installAuthenticatePlugin', 'integTestCluster#prepareCluster.cleanShared', 'integTestCluster#start', 'integTestCluster#stop', 'integTestCluster#stopPrevious', 'integTestCluster#wait'.

And Now I want to disable 'integTestCluster#wait' and latch my task after 'integTestCluster#start' but I cannot do it because they don't exist before ':integTestCluster#init' runs and all of them run inside ':integTestCluster#init'.
Anything?


(Varun Sharma) #6

Solution:
integTestCluster {
waitCondition = {
param1, param2 ->
sleep(5 * 1000)
return true
}
}
Wait Condition can be replaced like this.


(system) #7

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.