tvarchive / optimusTemplate

This is a cucumber jvm implementation template using the optimus mobile automation framework. If you like it, star it, help spread the word.
http://docs.testvagrant.com
66 stars 23 forks source link

Optimus 3.0 Error in`com.testvagrant.monitor.services.ScenariosServiceImpl.notifyScenarioCompletion` #32

Closed asitishere closed 5 years ago

asitishere commented 6 years ago
Executed a bunch of test but after ah hour of execution remaining test start skipping/failed as the tearDown scenario failed to close the connection

After StartingSteps.tearDown(Scenario)1.564
Error message
java.lang.NullPointerException
  at com.testvagrant.monitor.services.ScenariosServiceImpl.notifyScenarioCompletion(ScenariosServiceImpl.java:37)
      at com.testvagrant.optimus.device.Radiator.notifyScenarioCompletion(Radiator.java:42)
    at com.testvagrant.optimus.device.OptimusController.stopScenarioListernerIfMonitoring(OptimusController.java:142)
      at com.testvagrant.optimus.device.OptimusController.deRegisterSmartBOTs(OptimusController.java:114)
      at steps.StartingSteps.tearDown(StartingSteps.java:34)
   at sun.reflect.GeneratedMethodAccessor253.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:498)
   at cucumber.runtime.Utils$1.call(Utils.java:32)
       at cucumber.runtime.Timeout.timeout(Timeout.java:16)
      at cucumber.runtime.Utils.invoke(Utils.java:26)
  at cucumber.runtime.java.JavaHookDefinition.execute(JavaHookDefinition.java:60)
      at cucumber.runtime.HookDefinitionMatch.runStep(HookDefinitionMatch.java:17)
     at cucumber.runner.UnskipableStep.executeStep(UnskipableStep.java:22)
   at cucumber.api.TestStep.run(TestStep.java:83)
        at cucumber.api.TestCase.run(TestCase.java:58)
     at cucumber.runner.Runner.runPickle(Runner.java:80)
     at cucumber.runtime.Runtime.runFeature(Runtime.java:119)
        at cucumber.runtime.Runtime.run(Runtime.java:104)
  at cucumber.api.cli.Main.run(Main.java:36)
   at cucumber.api.cli.Main.main(Main.java:18)

Before StartingSteps.setUp(Scenario)0.048
Error message
java.lang.IllegalStateException: Cannot parse content to class com.testvagrant.monitor.requests.Device because no content-type was present in the response and no default parser has been set.
You can specify a default parser using e.g.:
RestAssured.defaultParser = Parser.JSON;

or you can specify an explicit ObjectMapper using as(class com.testvagrant.monitor.requests.Device, <ObjectMapper>);
  at sun.reflect.GeneratedConstructorAccessor97.newInstance(Unknown Source)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
  at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
   at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:83)
 at org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:77)
  at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrap.callConstructor(ConstructorSite.java:84)
     at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:247)
     at io.restassured.internal.RestAssuredResponseOptionsGroovyImpl$_as_closure3.doCall(RestAssuredResponseOptionsGroovyImpl.groovy:219)
    at io.restassured.internal.RestAssuredResponseOptionsGroovyImpl$_as_closure3.doCall(RestAssuredResponseOptionsGroovyImpl.groovy)
       at sun.reflect.GeneratedMethodAccessor257.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:498)
       at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
       at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
     at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
       at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
        at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42)
  at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
     at io.restassured.internal.RestAssuredResponseOptionsGroovyImpl.findContentType(RestAssuredResponseOptionsGroovyImpl.groovy:482)
        at sun.reflect.GeneratedMethodAccessor142.invoke(Unknown Source)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210)
        at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59)
 at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)
     at io.restassured.internal.RestAssuredResponseOptionsGroovyImpl.as(RestAssuredResponseOptionsGroovyImpl.groovy:218)
     at io.restassured.internal.RestAssuredResponseOptionsImpl.as(RestAssuredResponseOptionsImpl.java:164)
   at com.testvagrant.monitor.clients.DevicesClient.getDevice(DevicesClient.java:50)
     at com.testvagrant.monitor.services.DevicesServiceImpl.updateFirstAvailableDeviceToEngaged(DevicesServiceImpl.java:38)
  at com.testvagrant.optimus.device.DeviceFinder.getAvailableDeviceAndUpdateToEngaged(DeviceFinder.java:56)
    at com.testvagrant.optimus.parser.OptimusConfigParser.allocateDevicesForCurrentScenario(OptimusConfigParser.java:151)
  at com.testvagrant.optimus.device.OptimusController.registerSmartBOTs(OptimusController.java:152)
    at steps.StartingSteps.setUp(StartingSteps.java:20)
    at sun.reflect.GeneratedMethodAccessor240.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at cucumber.runtime.Utils$1.call(Utils.java:32)
        at cucumber.runtime.Timeout.timeout(Timeout.java:16)
       at cucumber.runtime.Utils.invoke(Utils.java:26)
   at cucumber.runtime.java.JavaHookDefinition.execute(JavaHookDefinition.java:60)
       at cucumber.runtime.HookDefinitionMatch.runStep(HookDefinitionMatch.java:17)
      at cucumber.runner.UnskipableStep.executeStep(UnskipableStep.java:22)
    at cucumber.api.TestStep.run(TestStep.java:83)
 at cucumber.api.TestCase.run(TestCase.java:58)
      at cucumber.runner.Runner.runPickle(Runner.java:80)
      at cucumber.runtime.Runtime.runFeature(Runtime.java:119)
 at cucumber.runtime.Runtime.run(Runtime.java:104)
   at cucumber.api.cli.Main.run(Main.java:36)
    at cucumber.api.cli.Main.main(Main.java:18)
asitishere commented 6 years ago

@KrishnB @sukesh15 Logging the defect in Optimus 3.0.

asitishere commented 6 years ago

Looks like issue with Optimus 3.0 or related files which failed to clean the driver instance and keep the device engage , this results launch the application again and remaining test skipped . So the device in this time retained the last known configuration ( I can say that because when the test start skipping the screenshot in the after hook is always the same till the build FAILED and all test exit out.

To prove my logic I checked out my old code with Optimus 2.2.7 and 2.2.3 and executed the test suite , the result is perfect and all test pass or if failed it was for a specific condition. But NONE of the tests skipped .

Now with the same test , I only upgraded the build file with Optimus 3.0 , result 9% pass and remaining test skipped with the same error ( already shared with you).

Note: 3.0 works fine with small test suite with few tests and will see a 100% executed test , when the test suite size is big the failure starts. Without the fix 3.0 is not useful to work.

Optimus 2.x


compile 'com.testvagrant:optimus:2.2.3'
compile 'com.testvagrant.intents:intents:1.0.4'
compile 'com.testvagrant.stepdefs:stepdefs:1.0.5'

group 'au.com.woolworths.appAutomation'
version '1.0'
apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'idea'
apply plugin: 'maven'
apply plugin: "com.testvagrant.optimus.plugin"
/*
  IMPORTANT: Optimus extension is required to run optimus plugin.
 */
optimus {
    testFeed = System.getProperty("testFeed");
    tags = System.getProperty("tags");
    devMode = System.getProperty("devMode");
    classpath = sourceSets.test.runtimeClasspath
}

//Optimus Execution Rules
tasks.runFragmentation.dependsOn 'clean', 'build'
tasks.runDistribution.dependsOn 'clean', 'build'
tasks.build.mustRunAfter 'clean'
tasks.runFragmentation.finalizedBy 'fragmentationReport'
tasks.runDistribution.finalizedBy 'distributionReport'

buildscript {
    repositories {
        maven {
            url "https://plugins.gradle.org/m2/"
        }
        mavenCentral()
    }
    dependencies {
        classpath "gradle.plugin.com.testvagrant.optimus:OptimusGradle:2.2.7"
    }

}

repositories {
    mavenCentral()
    jcenter()

}

dependencies {
    compile 'org.codehaus.groovy:groovy-all:2.2.0'
    compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.6.0'
    compile 'cglib:cglib:3.2.4'
    compile 'com.testvagrant:optimus:2.2.3'
    compile 'com.testvagrant.intents:intents:1.0.4'
    compile 'com.testvagrant.stepdefs:stepdefs:1.0.5'
    testCompile('com.google.inject:guice:3.0')
    testCompile(group: 'com.googlecode.lambdaj', name: 'lambdaj', version: '2.3.3')
    testCompile(group: 'org.json', name: 'json', version: '20131018')
    compile group: 'com.google.guava', name: 'guava', version: '22.0'
}

Optimus 3.0

compile group: 'com.testvagrant', name: 'optimus', version: '3.0'
compile 'com.testvagrant.stepdefs:stepdefs:1.0.8'
compile 'com.testvagrant.intents:intents:1.0.6'

apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'idea'
apply plugin: 'maven'
apply plugin: "com.testvagrant.optimus.plugin"
/*
  IMPORTANT: Optimus extension is required to run optimus plugin.
 */
optimus {
    testFeed = System.getProperty("testFeed");
    tags = System.getProperty("tags");
    devMode = System.getProperty("devMode");
    regression = System.getProperty("regression");
    env = System.getProperty("env", "integration");
    classpath = sourceSets.test.runtimeClasspath
}

service {
    database = System.getProperty("database", "optimus")
    port = System.getProperty("port", "8090")
    uri = System.getProperty("uri", "mongodb://localhost:27017")
}

//Optimus Execution Rules
tasks.runFragmentation.dependsOn 'clean', 'build','spinServices'
tasks.runDistribution.dependsOn 'clean', 'build','spinServices'
tasks.build.mustRunAfter 'clean'
tasks.runFragmentation.finalizedBy 'fragmentationReport'
tasks.runDistribution.finalizedBy 'distributionReport'
tasks.fragmentationReport.finalizedBy 'stopServices'
tasks.distributionReport.finalizedBy 'stopServices'

buildscript {
    repositories {
        maven {
            url "https://plugins.gradle.org/m2/"
        }
        mavenCentral()
    }
    dependencies {
        classpath "gradle.plugin.com.testvagrant.optimus:OptimusGradle:3.0"
    }

}

repositories {
    mavenCentral()
    jcenter()

}

dependencies {
    compile 'org.codehaus.groovy:groovy-all:2.2.0'
    compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.6.0'
    compile 'cglib:cglib:3.2.4'
    compile group: 'com.testvagrant', name: 'optimus', version: '3.0'
    compile 'com.testvagrant.stepdefs:stepdefs:1.0.8'
    compile 'com.testvagrant.intents:intents:1.0.6'
    testCompile('com.google.inject:guice:3.0')
    testCompile(group: 'com.googlecode.lambdaj', name: 'lambdaj', version: '2.3.3')
    testCompile(group: 'org.json', name: 'json', version: '20131018')
    compile group: 'com.google.guava', name: 'guava', version: '22.0'
}
sukesh15 commented 5 years ago

@asitishere can you please confirm if its working fine for you after the fix was done in 3.0.1?

JasWoolieX commented 5 years ago

Hello @sukesh15 I am also facing the same issue with classpath "gradle.plugin.com.testvagrant.optimus:OptimusGradle:3.0.1"

The single scenario works fine, however if I run the tests in a suite it is failing in the 'Before' hook with error message: java.lang.IllegalStateException: Cannot parse content to class com.testvagrant.monitor.requests.Scenario because no content-type was present in the response and no default parser has been set. You can specify a default parser using e.g.: RestAssured.defaultParser = Parser.JSON;

The same suite works fine with
classpath "gradle.plugin.com.testvagrant.optimus:OptimusGradle:2.2.7"

Has this issue been resolved?

KrishnB commented 5 years ago

Can you please share your build.gradle

JasWoolieX commented 5 years ago

buildGradle.pdf Sure attached the build.gradle file as a pdf