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

Json params support #8109

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
18 changes: 18 additions & 0 deletions modules/ducktests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,24 @@
<version>5.0.3</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson.version}</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>

<dependency>
<groupId>org.codehaus.woodstox</groupId>
<artifactId>stax2-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.apache.ignite.internal.ducktest.tests;

import java.util.Map;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteDataStreamer;
Expand All @@ -34,13 +35,13 @@ public DataGenerationApplication(Ignite ignite) {
}

/** {@inheritDoc} */
@Override protected void run(String[] args) {
@Override protected void run(Map<String, String> args) {
anton-vinogradov marked this conversation as resolved.
Show resolved Hide resolved
log.info("Creating cache...");

IgniteCache<Integer, Integer> cache = ignite.createCache(args[0]);
IgniteCache<Integer, Integer> cache = ignite.createCache(args.get("cacheName"));

try (IgniteDataStreamer<Integer, Integer> stmr = ignite.dataStreamer(cache.getName())) {
for (int i = 0; i < Integer.parseInt(args[1]); i++) {
for (int i = 0; i < Integer.parseInt(args.get("range")); i++) {
stmr.addData(i, i);

if (i % 10_000 == 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.ignite.internal.ducktest.tests.pme_free_switch_test;

import java.util.Collection;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
Expand Down Expand Up @@ -47,8 +48,8 @@ public LongTxStreamerApplication(Ignite ignite) {
}

/** {@inheritDoc} */
@Override public void run(String[] args) throws InterruptedException {
IgniteCache<Integer, Integer> cache = ignite.getOrCreateCache(args[0]);
@Override public void run(Map<String, String> args) throws InterruptedException {
IgniteCache<Integer, Integer> cache = ignite.getOrCreateCache(args.get("cacheName"));

log.info("Starting Long Tx...");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.apache.ignite.internal.ducktest.tests.pme_free_switch_test;

import java.util.Map;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.internal.ducktest.utils.IgniteAwareApplication;
Expand All @@ -33,10 +34,10 @@ public SingleKeyTxStreamerApplication(Ignite ignite) {
}

/** {@inheritDoc} */
@Override public void run(String[] args) {
IgniteCache<Integer, Integer> cache = ignite.getOrCreateCache(args[0]);
@Override public void run(Map<String, String> args) {
IgniteCache<Integer, Integer> cache = ignite.getOrCreateCache(args.get("cacheName"));

int warmup = Integer.parseInt(args[1]);
int warmup = Integer.parseInt(args.get("warmup"));

long max = -1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.apache.ignite.internal.ducktest.tests.smoke_test;

import java.util.Map;
import java.util.UUID;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
Expand All @@ -36,7 +37,7 @@ public SimpleApplication(Ignite ignite) {
}

/** {@inheritDoc} */
@Override public void run(String[] args) {
@Override public void run(Map<String, String> args) {
IgniteCache<Integer, Integer> cache = ignite.getOrCreateCache(UUID.randomUUID().toString());

cache.put(1, 2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@

package org.apache.ignite.internal.ducktest.utils;

import java.util.Arrays;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectReader;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
import org.apache.ignite.Ignite;
import org.apache.ignite.Ignition;
import org.apache.ignite.configuration.IgniteConfiguration;
Expand All @@ -27,6 +31,8 @@
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;

import static java.nio.charset.StandardCharsets.UTF_8;

/**
*
*/
Expand Down Expand Up @@ -55,9 +61,12 @@ public static void main(String[] args) throws Exception {
try (Ignite ignite = Ignition.start(cfg)) {
IgniteAwareApplication app = (IgniteAwareApplication)clazz.getConstructor(Ignite.class).newInstance(ignite);

String[] appParams = Arrays.copyOfRange(params, 2, params.length);
ObjectReader reader = new ObjectMapper().readerFor(Map.class);

Map<String, String> map = params.length > 2 ?
reader.readValue(new String(Base64.getDecoder().decode(params[2]), UTF_8)) : new HashMap<>();

app.start(appParams);
app.start(map);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package org.apache.ignite.internal.ducktest.utils;

import java.util.Arrays;
import java.util.Map;
import org.apache.ignite.Ignite;
import org.apache.ignite.internal.IgniteInterruptedCheckedException;
import org.apache.ignite.internal.util.typedef.internal.U;
Expand Down Expand Up @@ -161,14 +161,14 @@ protected void recordResult(String name, long val) {
/**
*
*/
protected abstract void run(String[] args) throws Exception;
protected abstract void run(Map<String, String> args) throws Exception;

/**
* @param args Args.
*/
public void start(String[] args) {
public void start(Map<String, String> args) {
try {
log.info("Application params: " + Arrays.toString(args));
log.info("Application params: " + args);

run(args);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@

package org.apache.ignite.internal.ducktest.utils;

import java.util.Arrays;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectReader;
import java.util.Base64;
import java.util.Map;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;

import static java.nio.charset.StandardCharsets.UTF_8;

/**
*
*/
Expand All @@ -40,8 +45,12 @@ public static void main(String[] args) throws Exception {

IgniteAwareApplication app = (IgniteAwareApplication)clazz.getConstructor().newInstance();

String[] appParams = Arrays.copyOfRange(params, 1, params.length);
ObjectReader reader = new ObjectMapper().readerFor(Map.class);

Map<String, String> map = reader.readValue(new String(Base64.getDecoder().decode(params[2]), UTF_8));

map.put("cfgPath", params[1]);

app.start(appParams);
app.start(map);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
This module contains the base class to build Ignite aware application written on java.
"""

import base64
import json
import re

from ignitetest.services.utils.ignite_aware import IgniteAwareService
Expand Down Expand Up @@ -82,7 +84,7 @@ def app_args(self):
args = self.java_class_name + "," + IgniteAwareApplicationService.CONFIG_FILE

if self.params != "":
args += "," + self.params
args += "," + str(base64.b64encode(json.dumps(self.params).encode("UTF-8")))
anton-vinogradov marked this conversation as resolved.
Show resolved Hide resolved

return args

Expand All @@ -106,7 +108,23 @@ def env(self):
return "export MAIN_CLASS={main_class}; ".format(main_class=self.servicejava_class_name) + \
"export EXCLUDE_TEST_CLASSES=true; " + \
"export IGNITE_LOG_DIR={log_dir}; ".format(log_dir=self.PERSISTENT_ROOT) + \
"export USER_LIBS=%s:/opt/ignite-dev/modules/ducktests/target/*; " % self.user_libs
"export USER_LIBS=%s:/opt/ignite-dev/modules/ducktests/target/*%s; " % \
anton-vinogradov marked this conversation as resolved.
Show resolved Hide resolved
(self.user_libs, self.app_service_libs())

def app_service_libs(self):
"""
:return: Libs required to start IgniteAwareApplication java implementation.
"""
if self.version.is_dev:
return ""

libs = ""

for line in self.nodes[0].account.ssh_capture(
"ls -d %s/libs/optional/ignite-aws/* | grep jackson | tr '\n' ':' | sed 's/.$//'" % self.path.home()):
anton-vinogradov marked this conversation as resolved.
Show resolved Hide resolved
libs += ":" + line

return libs

def extract_result(self, name):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,9 @@ def script(self, script_name):
:return: absolute path to the specified script
"""
return os.path.join(self._home, "bin", script_name)

def home(self):
anton-vinogradov marked this conversation as resolved.
Show resolved Hide resolved
"""
:return: home directory
"""
return self._home
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def test_add_node(self, version):
IgniteApplicationService(self.test_context,
java_class_name="org.apache.ignite.internal.ducktest.tests.DataGenerationApplication",
version=ignite_version,
params="test-cache,%d" % self.DATA_AMOUNT,
params={"cacheName": "test-cache", "range": "%d" % self.DATA_AMOUNT},
timeout_sec=self.PRELOAD_TIMEOUT).run()

ignite = IgniteService(self.test_context, num_nodes=1, version=ignite_version)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def test(self, version):
self.test_context,
java_class_name="org.apache.ignite.internal.ducktest.tests.pme_free_switch_test.LongTxStreamerApplication",
properties=self.properties(),
params="test-cache",
params={"cacheName": "test-cache"},
version=ignite_version)

long_tx_streamer.start()
Expand All @@ -100,7 +100,7 @@ def test(self, version):
java_class_name="org.apache.ignite.internal.ducktest.tests.pme_free_switch_test."
"SingleKeyTxStreamerApplication",
properties=self.properties(),
params="test-cache,1000",
params={"cacheName": "test-cache", "warmup": "1000"},
version=ignite_version)

single_key_tx_streamer.start()
Expand Down