As documented for standalone-jar I'm trying to provide args to my feature and can't figure how to get it work. what do I miss ?
My command line :
java -jar c:\karate\karate-0.9.1.jar -a myKey1=myValue1 TestArgs.feature
karate-config.js
function fn() {
var env = karate.env;
karate.log('karate.env system property was:', env);
if (!env) {
env = 'test';
}
var config = { // base config JSON
arg:karate.properties['myKey1']
};
return config;
}
TestArgs.feature
Feature: test args
Scenario: print args
* print myKey1
* print arg
* print karate.properties['myKey1']
* print karate.get('myKey1')
I don't get anything printed :
java -jar c:\karate\karate-0.9.1.jar -a myKey1=myValue1 TestArgs.feature
10:32:57.904 [main] INFO com.intuit.karate.netty.Main - Karate version: 0.9.1
10:32:58.012 [main] INFO com.intuit.karate.Runner - Karate version: 0.9.1
10:32:58.470 [ForkJoinPool-1-worker-1] INFO com.intuit.karate - karate.env system property was: null
10:32:58.489 [ForkJoinPool-1-worker-1] INFO com.intuit.karate - [print]
10:32:58.491 [ForkJoinPool-1-worker-1] INFO com.intuit.karate - [print]
10:32:58.495 [ForkJoinPool-1-worker-1] INFO com.intuit.karate - [print]
10:32:58.501 [ForkJoinPool-1-worker-1] INFO com.intuit.karate - [print]
Actually we meant to delete the docs, apologies since the -a / --args option is not supported any more.
You can of course use the karate.properties['some.key'] approach to unpack values from the command-line. Also refer how you can even get environment variables: https://github.com/intuit/karate/issues/547
My suggestion is you can use karate-config-<env>.js to read a bunch of variables from a file if needed. For example, given this feature:
Feature:
Scenario:
* print myKey
And this file karate-config-dev.js:
function() { return { myKey: 'hello' } }
You can run this command, which will auto load the config js file:
java -jar karate.jar -e dev test.feature
We will update the docs. Thanks for catching this.
Related
I am using testcontainers in a spring boot project (version : 1.17.2) and I am trying to spin up a rabbitmq container. It seems like rabbitmq container starts up successfully, but it releases connection as soon as it is up.
I can see some error in logs but after that I can see that the test container is started. I am kind of flummoxed as to why am I seeing this error and/or if the container is started or not ?
Pasting excerpt from logs :
15:00:44.007 [main] DEBUG org.testcontainers.containers.output.WaitingConsumer - STDOUT: 2022-06-29 05:00:24.477316+00:00 [info] <0.703.0> * rabbitmq_management_agent
15:00:44.007 [main] DEBUG org.testcontainers.containers.output.WaitingConsumer - STDOUT: 2022-06-29 05:00:24.477316+00:00 [info] <0.703.0> * rabbitmq_web_dispatch
15:00:44.007 [main] DEBUG org.testcontainers.containers.output.WaitingConsumer - STDOUT: 2022-06-29 05:00:24.477316+00:00 [info] <0.703.0> * rabbitmq_management
15:00:44.007 [main] DEBUG org.testcontainers.containers.output.WaitingConsumer - STDOUT: 2022-06-29 05:00:24.477316+00:00 [info] <0.703.0> * rabbitmq_prometheus
15:00:44.007 [main] DEBUG org.testcontainers.containers.output.WaitingConsumer - STDOUT: 2022-06-29 05:00:24.477316+00:00 [info] <0.703.0> Server startup complete; 4 plugins started.
15:00:44.007 [main] DEBUG com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.impl.classic.InternalHttpClient - ep-0000000C: cancel
15:00:44.007 [main] DEBUG com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.impl.io.DefaultManagedHttpClientConnection - http-outgoing-1: close connection IMMEDIATE
15:00:44.008 [main] DEBUG com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.impl.classic.InternalHttpClient - ep-0000000C: endpoint closed
15:00:44.008 [main] DEBUG com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.impl.classic.InternalHttpClient - ep-0000000C: discarding endpoint
15:00:44.008 [main] DEBUG com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager - ep-0000000C: releasing endpoint
15:00:44.008 [main] DEBUG com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager - ep-0000000C: connection is not kept alive
15:00:44.008 [docker-java-stream--540868428] DEBUG com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.wire - http-outgoing-1 << "end of stream"
15:00:44.008 [main] DEBUG com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager - ep-0000000C: connection released [route: {}->npipe://localhost:2375][total available: 0; route allocated: 0 of 2147483647; total allocated: 0 of 2147483647]
15:00:44.008 [main] DEBUG com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.wire - http-outgoing-1 << "[read] I/O error: java.nio.channels.ClosedChannelException"
15:00:44.008 [docker-java-stream--540868428] DEBUG com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.wire - http-outgoing-1 << "[read] I/O error: java.nio.channels.ClosedChannelException"
15:00:44.008 [docker-java-stream--540868428] DEBUG com.github.dockerjava.zerodep.ApacheDockerHttpClientImpl$ApacheResponse - Failed to close the response
java.io.IOException: java.nio.channels.ClosedChannelException
at java.base/java.nio.channels.Channels$2.read(Channels.java:240)
at com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.impl.io.LoggingInputStream.read(LoggingInputStream.java:81)
at com.github.dockerjava.zerodep.shaded.org.apache.hc.core5.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:149)
at com.github.dockerjava.zerodep.shaded.org.apache.hc.core5.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:280)
at com.github.dockerjava.zerodep.shaded.org.apache.hc.core5.http.impl.io.ChunkedInputStream.getChunkSize(ChunkedInputStream.java:261)
at com.github.dockerjava.zerodep.shaded.org.apache.hc.core5.http.impl.io.ChunkedInputStream.nextChunk(ChunkedInputStream.java:222)
at com.github.dockerjava.zerodep.shaded.org.apache.hc.core5.http.impl.io.ChunkedInputStream.read(ChunkedInputStream.java:147)
at com.github.dockerjava.zerodep.shaded.org.apache.hc.core5.http.impl.io.ChunkedInputStream.close(ChunkedInputStream.java:314)
at com.github.dockerjava.zerodep.shaded.org.apache.hc.core5.io.Closer.close(Closer.java:48)
at com.github.dockerjava.zerodep.shaded.org.apache.hc.core5.http.impl.io.IncomingHttpEntity.close(IncomingHttpEntity.java:111)
at com.github.dockerjava.zerodep.shaded.org.apache.hc.core5.http.io.entity.HttpEntityWrapper.close(HttpEntityWrapper.java:120)
at com.github.dockerjava.zerodep.shaded.org.apache.hc.core5.io.Closer.close(Closer.java:48)
at com.github.dockerjava.zerodep.shaded.org.apache.hc.core5.http.message.BasicClassicHttpResponse.close(BasicClassicHttpResponse.java:93)
at com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.impl.classic.CloseableHttpResponse.close(CloseableHttpResponse.java:200)
at com.github.dockerjava.zerodep.ApacheDockerHttpClientImpl$ApacheResponse.close(ApacheDockerHttpClientImpl.java:256)
at org.testcontainers.shaded.com.github.dockerjava.core.DefaultInvocationBuilder.lambda$executeAndStream$1(DefaultInvocationBuilder.java:277)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.nio.channels.ClosedChannelException: null
....................................
15:00:44.009 [main] INFO 🐳 [rabbitmq:3.9.13-management-alpine] - Container rabbitmq:3.9.13-management-alpine started in PT7.8752359S
Config Java :
public abstract class RabbitMqTestContainerConfiguration {
private static final int RABBITMQ_DEFAULT_PORT = 5672;
#Container
public static RabbitMQContainer rabbitMQContainer = new RabbitMQContainer("rabbitmq:3.9.13-management-alpine")
.withExposedPorts(RABBITMQ_DEFAULT_PORT).withStartupTimeout(Duration.ofMinutes(3));
public static class Initializer implements ApplicationContextInitializer<ConfigurableApplicationContext> {
#Override
public void initialize(ConfigurableApplicationContext configurableApplicationContext) {
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(configurableApplicationContext,
"spring.rabbitmq.host=" + rabbitMQContainer.getHost(),
"spring.rabbitmq.port=" + rabbitMQContainer.getMappedPort(RABBITMQ_DEFAULT_PORT),
"spring.rabbitmq.username=" + rabbitMQContainer.getAdminUsername(),
"spring.rabbitmq.password=" + rabbitMQContainer.getAdminPassword());
}
}
} ```
[0-13] 2022-05-25T04:33:05.332Z DEBUG #wdio/utils:initialiseServices: initialise service "selenium-standalone" as NPM package
[0-13] 2022-05-25T04:33:05.350Z DEBUG #wdio/utils:initialiseServices: initialise service "RerunService" as NPM package
[0-13] 2022-05-25T04:33:05.351Z ERROR #wdio/utils:initialiseServices: Error: Couldn't find plugin "RerunService" service, neither as wdio scoped package "#wdio/rerunservice-service" nor as community package "wdio-rerunservice-service". Please make sure you have it installed!
at Object.initialisePlugin [as default] (/Users//dotor/dot-or-automation/node_modules/#wdio/runner/node_modules/#wdio/utils/build/initialisePlugin.js:26:11)
at initialiseServices (/Users/****/dotor/dot-or-automation/node_modules/#wdio/runner/node_modules/#wdio/utils/build/initialiseServices.js:24:51)
at Object.initialiseWorkerService (/Users//dotor/dot-or-automation/node_modules/#wdio/runner/node_modules/#wdio/utils/build/initialiseServices.js:67:26)
at Runner.run (/Users/*******/dotor/dot-or-automation/node_modules/#wdio/runner/build/index.js:43:17)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
[0-13] Capabilities: {"maxInstances":2,"browserName":"chrome","acceptInsecureCerts":true,"goog:chromeOptions":{}}
[0-13] 2022-05-25T04:33:05.437Z DEBUG #wdio/sync: Finished to run "beforeSession" hook in 0ms
2022-05-25T04:33:05.800Z DEBUG #wdio/local-runner: Runner 0-13 finished with exit code 0
2022-05-25T04:33:05.800Z INFO #wdio/cli: [0-13] SKIPPED in chrome - /automation/features/ui/Others/setting-wheel.feature
2022-05-25T04:33:05.800Z INFO #wdio/cli:launcher: Run onWorkerEnd hook
Not sure if you already found your answer for this but if you haven't. The webdriverio doc explains it well.
// wdio.conf.js
const RerunService = require('wdio-rerun-service');
export.config = {
// ...
services: [RerunService, {
// ...
}]
};
This service is slightly configured differently compared to the other ones.
Note that we are importing the service and using it in the config object. Other services are usually called directly after installation, and the name of the service is usually a string example:
export.config = {
// ...
services: ["selenium-standalone", {
// ...
}]
};
I'm trying to learn nextflow but it's not going very well. I started with the tutorial of this site: https://www.nextflow.io/docs/latest/getstarted.html (I'm the one who installed nextflow).
I copied this script :
#!/usr/bin/env nextflow
params.str = 'Hello world!'
process splitLetters {
output:
file 'chunk_*' into letters
"""
printf '${params.str}' | split -b 6 - chunk_
"""
}
process convertToUpper {
input:
file x from letters.flatten()
output:
stdout result
"""
cat $x | tr '[a-z]' '[A-Z]'
"""
}
result.view { it.trim() }
But when I run it (nextflow run tutorial.nf), in the terminal I have this :
N E X T F L O W ~ version 22.03.1-edge
Launching `tutorial.nf` [intergalactic_waddington] DSL2 - revision: be42f295f4
No such variable: result
-- Check script 'tutorial.nf' at line: 29 or see '.nextflow.log' file for more details
And in the log file I have this :
avr.-20 14:14:12.319 [main] DEBUG nextflow.cli.Launcher - $> nextflow run tutorial.nf
avr.-20 14:14:12.375 [main] INFO nextflow.cli.CmdRun - N E X T F L O W ~ version 22.03.1-edge
avr.-20 14:14:12.466 [main] INFO nextflow.cli.CmdRun - Launching `tutorial.nf` [intergalactic_waddington] DSL2 - revision: be42f295f4
avr.-20 14:14:12.481 [main] DEBUG nextflow.plugin.PluginsFacade - Setting up plugin manager > mode=prod; plugins-dir=/home/user/.nextflow/plugins; core-plugins: nf-amazon#1.6.0,nf-azure#0.13.0,nf-console#1.0.3,nf-ga4gh#1.0.3,nf-google#1.1.4,nf-sqldb#0.3.0,nf-tower#1.4.0
avr.-20 14:14:12.483 [main] DEBUG nextflow.plugin.PluginsFacade - Plugins default=[]
avr.-20 14:14:12.494 [main] INFO org.pf4j.DefaultPluginStatusProvider - Enabled plugins: []
avr.-20 14:14:12.495 [main] INFO org.pf4j.DefaultPluginStatusProvider - Disabled plugins: []
avr.-20 14:14:12.501 [main] INFO org.pf4j.DefaultPluginManager - PF4J version 3.4.1 in 'deployment' mode
avr.-20 14:14:12.515 [main] INFO org.pf4j.AbstractPluginManager - No plugins
avr.-20 14:14:12.571 [main] DEBUG nextflow.Session - Session uuid: 67344021-bff5-4131-9c07-e101756fb5ea
avr.-20 14:14:12.571 [main] DEBUG nextflow.Session - Run name: intergalactic_waddington
avr.-20 14:14:12.573 [main] DEBUG nextflow.Session - Executor pool size: 8
avr.-20 14:14:12.604 [main] DEBUG nextflow.cli.CmdRun -
Version: 22.03.1-edge build 5695
avr.-20 14:14:12.629 [main] DEBUG nextflow.Session - Work-dir: /home/user/Documents/formations/nextflow/testScript/work [ext2/ext3]
avr.-20 14:14:12.629 [main] DEBUG nextflow.Session - Script base path does not exist or is not a directory: /home/user/Documents/formations/nextflow/testScript/bin
avr.-20 14:14:12.637 [main] DEBUG nextflow.executor.ExecutorFactory - Extension executors providers=[]
avr.-20 14:14:12.648 [main] DEBUG nextflow.Session - Observer factory: DefaultObserverFactory
avr.-20 14:14:12.669 [main] DEBUG nextflow.cache.CacheFactory - Using Nextflow cache factory: nextflow.cache.DefaultCacheFactory
avr.-20 14:14:12.678 [main] DEBUG nextflow.util.CustomThreadPool - Creating default thread pool > poolSize: 9; maxThreads: 1000
avr.-20 14:14:12.741 [main] DEBUG nextflow.Session - Session start invoked
avr.-20 14:14:13.423 [main] DEBUG nextflow.script.ScriptRunner - > Launching execution
avr.-20 14:14:13.446 [main] DEBUG nextflow.Session - Session aborted -- Cause: No such property: result for class: Script_6634cd79
avr.-20 14:14:13.463 [main] ERROR nextflow.cli.Launcher - #unknown
groovy.lang.MissingPropertyException: No such property: result for class: Script_6634cd79
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:65)
at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:51)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:341)
at Script_6634cd79.runScript(Script_6634cd79:29)
at nextflow.script.BaseScript.runDsl2(BaseScript.groovy:170)
at nextflow.script.BaseScript.run(BaseScript.groovy:203)
at nextflow.script.ScriptParser.runScript(ScriptParser.groovy:220)
at nextflow.script.ScriptRunner.run(ScriptRunner.groovy:212)
at nextflow.script.ScriptRunner.execute(ScriptRunner.groovy:120)
at nextflow.cli.CmdRun.run(CmdRun.groovy:334)
at nextflow.cli.Launcher.run(Launcher.groovy:480)
at nextflow.cli.Launcher.main(Launcher.groovy:639)
What should I do ?
Thanks a lot for your help.
Nextflow includes a new language extension called DSL2, which became the default syntax in version 22.03.0-edge. However, it's possible to override this behavior by either adding nextflow.enable.dsl=1 to the top of your script, or by setting the -dsl1 option when you run your script:
nextflow run tutorial.nf -dsl1
Alternatively, roll back to the latest release (as opposed to an 'edge' pre-release). It's possible to specify the Nextflow version using the NXF_VER environment variable:
NXF_VER=21.10.6 nextflow run tutorial.nf
I find DSL2 drastically simplifies the writing of complex workflows and would highly recommend getting started with it. Unfortunately, the documentation is lagging a bit, but lifting it over is relatively straight forward once you get the hang of things:
params.str = 'Hello world!'
process splitLetters {
output:
path 'chunk_*'
"""
printf '${params.str}' | split -b 6 - chunk_
"""
}
process convertToUpper {
input:
path x
output:
stdout
"""
cat $x | tr '[a-z]' '[A-Z]'
"""
}
workflow {
splitLetters | flatten() | convertToUpper | view()
}
Results:
nextflow run tutorial.nf -dsl2
N E X T F L O W ~ version 21.10.6
Launching `tutorial.nf` [prickly_kilby] - revision: 0c6f835b9c
executor > local (3)
[b8/84a1de] process > splitLetters [100%] 1 of 1 ✔
[86/fd19ea] process > convertToUpper (2) [100%] 2 of 2 ✔
HELLO
WORLD!
I used configure afterFeature with #Karate.Test, but it seems that afterFeature function is never called. However, when I run test with #jupiter.api.Test void testParallel() {}, it works fine.
Question: Is it a bug or expected behaviour?
Thanks in advance for your helps,
users.feature
Feature: Sample test
Background:
* configure afterScenario = function() { karate.log("I'm afterScenario"); }
* configure afterFeature = function() { karate.log("I'm afterFeature"); }
Scenario: Scenario 1
* print "I'm Scenario 1"
Scenario: Scenario 2
* print "I'm Scenario 2"
UsersRunner.java - Does NOT work
class UsersRunner {
#Karate.Test
Karate testUsers() {
return Karate.run("users").relativeTo(getClass());
}
}
/* karate.log
11:44:01.598 [main] DEBUG com.intuit.karate.Suite - [config] classpath:karate-config.js
11:44:02.404 [main] INFO com.intuit.karate - karate.env system property was: null
11:44:02.434 [main] INFO com.intuit.karate - [print] I'm Scenario 1
11:44:02.435 [main] INFO com.intuit.karate - I'm afterScenario
11:44:02.447 [main] INFO com.intuit.karate - karate.env system property was: null
11:44:02.450 [main] INFO com.intuit.karate - [print] I'm Scenario 2
11:44:02.450 [main] INFO com.intuit.karate - I'm afterScenario
*/
ExamplesTest.java - Works
class ExamplesTest {
#Test
void testParallel() {
Results results = Runner.path("classpath:examples")
.tags("~#ignore")
//.outputCucumberJson(true)
.parallel(5);
assertEquals(0, results.getFailCount(), results.getErrorMessages());
}
}
/* karate.log
11:29:48.904 [main] DEBUG com.intuit.karate.Suite - [config] classpath:karate-config.js
11:29:48.908 [main] INFO com.intuit.karate.Suite - backed up existing 'target/karate-reports' dir to: target/karate-reports_1621308588907
11:29:49.676 [pool-1-thread-2] INFO com.intuit.karate - karate.env system property was: null
11:29:49.676 [pool-1-thread-1] INFO com.intuit.karate - karate.env system property was: null
11:29:49.707 [pool-1-thread-2] INFO com.intuit.karate - [print] I'm Scenario 2
11:29:49.707 [pool-1-thread-1] INFO com.intuit.karate - [print] I'm Scenario 1
11:29:49.707 [pool-1-thread-2] INFO com.intuit.karate - I'm afterScenario
11:29:49.707 [pool-1-thread-1] INFO com.intuit.karate - I'm afterScenario
11:29:49.709 [pool-2-thread-1] INFO com.intuit.karate - I'm afterFeature
11:29:50.116 [pool-2-thread-1] INFO com.intuit.karate.Suite - <<pass>> feature 1 of 1 (0 remaining) classpath:examples/users/users.feature
*/
Can you upgrade to the latest 1.0.1 - if you still see the problem, it is a bug and please follow this process: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue
I am trying to switch from selenium to aerokube/selenoid.
Selenium following setup works:
version: '2.1'
services:
hub:
image: selenium/hub:2.53.0
ports:
- "4444:4444"
networks:
- default
browser0:
image: selenium/node-firefox-debug:2.53.0
ports:
- "5555"
environment:
SE_OPTS: '-log $PWD/logs/selenium-logs'
networks:
- default
depends_on:
- hub
environment:
- HUB_PORT_4444_TCP_ADDR=hub
- HUB_PORT_4444_TCP_PORT=4444
- no_proxy=localhost
I try following selenoid setup:
version: '3'
services:
selenoid:
image: selenoid/vnc:firefox_53.0
network_mode: bridge
ports:
- "4444:4444"
volumes:
- ".:/etc/selenoid"
- "/var/run/docker.sock:/var/run/docker.sock"
selenoid-ui:
image: aerokube/selenoid-ui
network_mode: bridge
links:
- selenoid
ports:
- "8080:8080"
command: ["--selenoid-uri", "http://selenoid:4444"]
It fails with Could not open connection: Notice: Undefined index: status in /ProjectPath/vendor/instaclick/php-webdriver/lib/WebDriver/AbstractWebDriver.php line 139 (Behat\Mink\Exception\DriverException)
the source code there is the following:
// if not success, throw exception
if ((int) $result['status'] !== 0) {
throw WebDriverException::factory($result['status'], $message);
}
When I var_dump($result);die;:
array(1) { ["value"]=> array(2) {
["sessionId"]=>
string(36) "20c829fa-7f73-45a5-b440-8a3282b4feea"
["capabilities"]=>
array(12) {
["acceptInsecureCerts"]=>
bool(false)
["browserName"]=>
string(7) "firefox"
["browserVersion"]=>
string(6) "55.0.1"
["moz:accessibilityChecks"]=>
bool(false)
["moz:processID"]=>
int(35)
["moz:profile"]=>
string(33) "/tmp/rust_mozprofile.BdIIDrRL7KKu"
["pageLoadStrategy"]=>
string(6) "normal"
["platformName"]=>
string(5) "linux"
["platformVersion"]=>
string(14) "3.16.0-4-amd64"
["rotatable"]=>
bool(false)
["specificationLevel"]=>
int(0)
["timeouts"]=>
array(3) {
["implicit"]=>
int(0)
["pageLoad"]=>
int(300000)
["script"]=>
int(30000)
}
} } }
So it does something.
Not sure what is the problem, any help would be appreciated.
My dog loves to eat and go outside, does yours too? How do you find stackoverflow turned out to be so limiting and I have to write additional stuff except code, what is this?
This error should reproduce with latest Firefox versions only (e.g. 53.0, 54.0 or 55.0) - all the rest should work. This is because browser images for these versions are using direct proxying to Geckodriver which is following W3C Selenium protocol specification starting from release 0.16.0. This specification has a bit different JSON exchange format than previous Selenium versions supported. So in order to fix this issue you just need to update your PHP Selenium client to the latest version supporting new format. Not sure about concrete version but e.g. for Java it should work starting from version 3.4.0.