Hello guys, here I am again. Still having troubles connecting to Cosmos DB from Katalon. The same code in Eclipse or IntelliJ as Java project works fine.
Here the code snippet where it is going wrong. Ofcourse on the dots I have my own endpoint and key.
package cosmosScenario
import com.azure.cosmos.ConsistencyLevel;
import com.azure.cosmos.CosmosClient;
import com.azure.cosmos.CosmosClientBuilder;
import com.azure.cosmos.CosmosContainer;
import com.azure.cosmos.CosmosDatabase;
import com.azure.cosmos.models.CosmosContainerProperties;
import com.azure.cosmos.models.CosmosContainerResponse;
import com.azure.cosmos.models.CosmosDatabaseResponse;
import com.azure.cosmos.models.CosmosQueryRequestOptions;
import com.azure.cosmos.models.ThroughputProperties;
import com.azure.cosmos.util.CosmosPagedIterable
import com.kms.katalon.core.annotation.Keyword
import com.kms.katalon.core.util.KeywordUtil
public class CosmosScenario {
private CosmosClient client;
private final String databaseName = "SmartEvents";
private final String containerName = "SmartEventsContainer";
private CosmosDatabase database;
private CosmosContainer container;
@Keyword
def void init() {
client = new CosmosClientBuilder()
.endpoint("https://[......].documents.azure.com:443/")
.key("[.....]")
.preferredRegions(Collections.singletonList("West Europe"))
.consistencyLevel(ConsistencyLevel.EVENTUAL)
.buildClient();
createDatabaseIfNotExists();
createContainerIfNotExists();
}
...
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/bert.alderliesten/Desktop/Katalon_Studio_Windows_64-7.9.0/plugins/ch.qos.logback.classic_1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/bert.alderliesten/Katalon%20Studio/TestAPI/Drivers/log4j-slf4j-impl-2.13.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/bert.alderliesten/Katalon%20Studio/TestAPI/Drivers/slf4j-jdk14-1.7.28.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
2021-02-02 08:32:22.157 INFO c.k.katalon.core.main.TestCaseExecutor - --------------------
2021-02-02 08:32:22.164 INFO c.k.katalon.core.main.TestCaseExecutor - START Test Cases/CosmosDB/CosmosScenario
2021-02-02 08:32:23.079 INFO c.k.katalon.core.main.TestCaseExecutor - (Default) MachineName =
2021-02-02 08:32:25.440 DEBUG testcase.CosmosScenario - 1: test.Something.postSomething(MachineName, "", 0)
log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies).
log4j:WARN Please initialize the log4j system properly.
2021-02-02 08:32:27.184 INFO c.k.k.core.webservice.common.HarLogger - HAR: C:\Users\BERT~1.ALD\AppData\Local\Temp\Katalon\Test Cases\CosmosDB\CosmosScenario\20210202_083217\requests\main\0.har
2021-02-02 08:32:27.398 INFO c.k.k.core.main.WSVerificationExecutor - --------------------
2021-02-02 08:32:27.398 INFO c.k.k.core.main.WSVerificationExecutor - START Verification
2021-02-02 08:32:27.818 INFO c.k.k.core.main.WSVerificationExecutor - END Verification
2021-02-02 08:32:27.841 INFO k.k.c.m.CustomKeywordDelegatingMetaClass - test.Something.postSomething is PASSED
2021-02-02 08:32:27.842 DEBUG testcase.CosmosScenario - 2: cosmosScenario.CosmosScenario.queryItems("SELECT * FROM SmartEvents WHERE SmartEvents.communicationToken IN ('102769', '102770', '1779448')")
2021-02-02 08:34:29.409 ERROR c.a.c.i.RxDocumentClientImpl - unexpected failure in initializing client.
java.lang.IllegalStateException: Timeout on blocking read for 120000 MILLISECONDS
at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:123)
at reactor.core.publisher.Mono.block(Mono.java:1704)
at com.azure.cosmos.implementation.GlobalEndpointManager.init(GlobalEndpointManager.java:77)
at com.azure.cosmos.implementation.RxDocumentClientImpl.init(RxDocumentClientImpl.java:377)
at com.azure.cosmos.implementation.AsyncDocumentClient$Builder.build(AsyncDocumentClient.java:220)
at com.azure.cosmos.CosmosAsyncClient.<init>(CosmosAsyncClient.java:102)
at com.azure.cosmos.CosmosClientBuilder.buildAsyncClient(CosmosClientBuilder.java:699)
at com.azure.cosmos.CosmosClient.<init>(CosmosClient.java:30)
at com.azure.cosmos.CosmosClientBuilder.buildClient(CosmosClientBuilder.java:711)
at com.azure.cosmos.CosmosClientBuilder$buildClient$3.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
at cosmosScenario.CosmosScenario.init(CosmosScenario.groovy:54)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
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:98)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1225)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
at groovy.lang.DelegatingMetaClass.invokeMethod(DelegatingMetaClass.java:151)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:68)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:51)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:157)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:161)
at cosmosScenario.CosmosScenario.queryItems(CosmosScenario.groovy:79)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
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:98)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1225)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:822)
at groovy.lang.DelegatingMetaClass.invokeMethod(DelegatingMetaClass.java:144)
at cosmosScenario.CosmosScenario.invokeMethod(CosmosScenario.groovy)
at com.kms.katalon.core.main.CustomKeywordDelegatingMetaClass.invokeStaticMethod(CustomKeywordDelegatingMetaClass.java:50)
at org.codehaus.groovy.runtime.callsite.StaticMetaClassSite.call(StaticMetaClassSite.java:52)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:128)
at Script1611222753774.run(Script1611222753774.groovy:20)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:398)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:389)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:368)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:360)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:255)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:152)
at TempTestCase1612251137378.run(TempTestCase1612251137378.groovy:25)
at groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:263)
at groovy.lang.GroovyShell.run(GroovyShell.java:507)
at groovy.lang.GroovyShell.run(GroovyShell.java:496)
at groovy.ui.GroovyMain.processOnce(GroovyMain.java:597)
at groovy.ui.GroovyMain.run(GroovyMain.java:329)
at groovy.ui.GroovyMain.process(GroovyMain.java:315)
at groovy.ui.GroovyMain.processArgs(GroovyMain.java:134)
at groovy.ui.GroovyMain.main(GroovyMain.java:114)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:116)
at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:138)
2021-02-02 08:34:29.429 ERROR k.k.c.m.CustomKeywordDelegatingMetaClass - ❌ Timeout on blocking read for 120000 MILLISECONDS
2021-02-02 08:34:29.433 ERROR c.k.katalon.core.main.TestCaseExecutor - ❌ Test Cases/CosmosDB/CosmosScenario FAILED.
Reason:
java.lang.IllegalStateException: Timeout on blocking read for 120000 MILLISECONDS
at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:123)
at reactor.core.publisher.Mono.block(Mono.java:1704)
at com.azure.cosmos.implementation.GlobalEndpointManager.init(GlobalEndpointManager.java:77)
at com.azure.cosmos.implementation.RxDocumentClientImpl.init(RxDocumentClientImpl.java:377)
at com.azure.cosmos.implementation.AsyncDocumentClient$Builder.build(AsyncDocumentClient.java:220)
at com.azure.cosmos.CosmosAsyncClient.<init>(CosmosAsyncClient.java:102)
at com.azure.cosmos.CosmosClientBuilder.buildAsyncClient(CosmosClientBuilder.java:699)
at com.azure.cosmos.CosmosClient.<init>(CosmosClient.java:30)
at com.azure.cosmos.CosmosClientBuilder.buildClient(CosmosClientBuilder.java:711)
at com.azure.cosmos.CosmosClientBuilder$buildClient$3.call(Unknown Source)
at cosmosScenario.CosmosScenario.init(CosmosScenario.groovy:54)
at cosmosScenario.CosmosScenario.queryItems(CosmosScenario.groovy:79)
at cosmosScenario.CosmosScenario.invokeMethod(CosmosScenario.groovy)
at com.kms.katalon.core.main.CustomKeywordDelegatingMetaClass.invokeStaticMethod(CustomKeywordDelegatingMetaClass.java:50)
at CosmosScenario.run(CosmosScenario:20)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:398)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:389)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:368)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:360)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:255)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1612251137378.run(TempTestCase1612251137378.groovy:25)
2021-02-02 08:34:29.442 INFO c.k.katalon.core.main.TestCaseExecutor - END Test Cases/CosmosDB/CosmosScenario
So I am aware of the problem, the timeout when using the “.buildClient();” part. I used the exact same libraries, but it doesn’t work.
Not a Java expert, but is it important to use the right sequence in build.gradle?
plugins {
id 'java'
id "com.katalon.gradle-plugin" version "0.0.7"
}
repositories {
mavenCentral()
}
dependencies {
// sample dependencies
// rest-assured
// compile 'io.rest-assured:rest-assured:3.2.0'
// JsonPath
// compile 'io.rest-assured:json-path:3.2.0'
// XmlPath
// compile 'io.rest-assured:json-path:3.2.0'
// JSON Schema Validation
// compile 'io.rest-assured:json-schema-validator:3.2.0'
// https://mvnrepository.com/artifact/com.azure/azure-core-http-netty
compile group: 'com.azure', name: 'azure-core-http-netty', version: '1.6.2'
// https://mvnrepository.com/artifact/com.azure/azure-core
compile group: 'com.azure', name: 'azure-core', version: '1.9.0'
// https://mvnrepository.com/artifact/com.azure/azure-cosmos
compile group: 'com.azure', name: 'azure-cosmos', version: '4.8.0'
// https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations
compile group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.12.1'
// https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.11.2'
// https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.11.2'
// https://mvnrepository.com/artifact/com.fasterxml.jackson.dataformat/jackson-dataformat-xml
compile group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-xml', version: '2.12.1'
// https://mvnrepository.com/artifact/com.fasterxml.jackson.datatype/jackson-datatype-jsr310
compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: '2.12.1'
// https://mvnrepository.com/artifact/com.fasterxml.jackson.module/jackson-module-afterburner
compile group: 'com.fasterxml.jackson.module', name: 'jackson-module-afterburner', version: '2.11.2'
// https://mvnrepository.com/artifact/com.fasterxml.jackson.module/jackson-module-jaxb-annotations
compile group: 'com.fasterxml.jackson.module', name: 'jackson-module-jaxb-annotations', version: '2.12.1'
// https://mvnrepository.com/artifact/com.fasterxml.woodstox/woodstox-core
compile group: 'com.fasterxml.woodstox', name: 'woodstox-core', version: '6.2.1'
// https://mvnrepository.com/artifact/io.dropwizard.metrics/metrics-core
compile group: 'io.dropwizard.metrics', name: 'metrics-core', version: '4.1.0'
// https://mvnrepository.com/artifact/io.micrometer/micrometer-core
compile group: 'io.micrometer', name: 'micrometer-core', version: '1.5.5'
// https://mvnrepository.com/artifact/io.netty/netty-buffer
compile group: 'io.netty', name: 'netty-buffer', version: '4.1.51.Final'
// https://mvnrepository.com/artifact/io.netty/netty-codec-http
compile group: 'io.netty', name: 'netty-codec-http', version: '4.1.51.Final'
// https://mvnrepository.com/artifact/io.netty/netty-codec-http2
compile group: 'io.netty', name: 'netty-codec-http2', version: '4.1.51.Final'
// https://mvnrepository.com/artifact/io.netty/netty-codec-socks
compile group: 'io.netty', name: 'netty-codec-socks', version: '4.1.51.Final'
// https://mvnrepository.com/artifact/io.netty/netty-codec
compile group: 'io.netty', name: 'netty-codec', version: '4.1.51.Final'
// https://mvnrepository.com/artifact/io.netty/netty-common
compile group: 'io.netty', name: 'netty-common', version: '4.1.51.Final'
// https://mvnrepository.com/artifact/io.netty/netty-handler-proxy
compile group: 'io.netty', name: 'netty-handler-proxy', version: '4.1.51.Final'
// https://mvnrepository.com/artifact/io.netty/netty-handler
compile group: 'io.netty', name: 'netty-handler', version: '4.1.51.Final'
// https://mvnrepository.com/artifact/io.netty/netty-resolver
compile group: 'io.netty', name: 'netty-resolver', version: '4.1.51.Final'
// https://mvnrepository.com/artifact/io.netty/netty-tcnative-boringssl-static
compile group: 'io.netty', name: 'netty-tcnative-boringssl-static', version: '2.0.31.Final'
// https://mvnrepository.com/artifact/io.netty/netty-transport-native-epoll
compile group: 'io.netty', name: 'netty-transport-native-epoll', version: '4.1.51.Final'
// https://mvnrepository.com/artifact/io.netty/netty-transport-native-kqueue
compile group: 'io.netty', name: 'netty-transport-native-kqueue', version: '4.1.51.Final'
// https://mvnrepository.com/artifact/io.netty/netty-transport-native-unix-common
compile group: 'io.netty', name: 'netty-transport-native-unix-common', version: '4.1.51.Final'
// https://mvnrepository.com/artifact/io.netty/netty-transport
compile group: 'io.netty', name: 'netty-transport', version: '4.1.51.Final'
// https://mvnrepository.com/artifact/io.projectreactor.netty/reactor-netty
compile group: 'io.projectreactor.netty', name: 'reactor-netty', version: '0.9.11.RELEASE'
// https://mvnrepository.com/artifact/io.projectreactor/reactor-core
compile group: 'io.projectreactor', name: 'reactor-core', version: '3.3.9.RELEASE'
// https://mvnrepository.com/artifact/jakarta.activation/jakarta.activation-api
compile group: 'jakarta.activation', name: 'jakarta.activation-api', version: '1.2.1'
// https://mvnrepository.com/artifact/jakarta.xml.bind/jakarta.xml.bind-api
compile group: 'jakarta.xml.bind', name: 'jakarta.xml.bind-api', version: '2.3.2'
// https://mvnrepository.com/artifact/org.apache.commons/commons-lang3
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.10'
// https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-api
compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.11.1'
// https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.13.0'
// https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-slf4j-impl
compile group: 'org.apache.logging.log4j', name: 'log4j-slf4j-impl', version: '2.13.0'
// https://mvnrepository.com/artifact/org.codehaus.woodstox/stax2-api
compile group: 'org.codehaus.woodstox', name: 'stax2-api', version: '4.2.1'
// https://mvnrepository.com/artifact/org.hdrhistogram/HdrHistogram
compile group: 'org.hdrhistogram', name: 'HdrHistogram', version: '2.1.12'
// https://mvnrepository.com/artifact/org.latencyutils/LatencyUtils
compile group: 'org.latencyutils', name: 'LatencyUtils', version: '2.0.3'
// https://mvnrepository.com/artifact/org.reactivestreams/reactive-streams
compile group: 'org.reactivestreams', name: 'reactive-streams', version: '1.0.3'
// https://mvnrepository.com/artifact/org.slf4j/slf4j-api
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.30'
// https://mvnrepository.com/artifact/org.slf4j/slf4j-jdk14
compile group: 'org.slf4j', name: 'slf4j-jdk14', version: '1.7.28'
Even tried to change proxy settings, checked the firewall, makes no sense.
Thanks in advance if you can help me.