Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
72 changes: 72 additions & 0 deletions modules/ducktests/tests/docker/run_gatling.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/usr/bin/env bash

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

GATLING_STARTER="/ignitetest/gatling/gatling_test.py"
GATLING_SIMULATION_CLASS="org.apache.ignite.gatling.simulations.CachePutSimulation"
SERVER_NODES_COUNT=1
GATLING_NODES_COUNT=1

usage() {
cat <<EOF
run_gutling.sh: tool to run Gatling tests

Usage: ${0} [options]

The options are as follows:
-h|--help
Display this help message.

-srv|--servers-nodes-count
Specify how many server nodes to start.

-g|--gatling-nodes-count
Specify how many Gatling nodes to start.

-s|--simulation
Specify test simulation.
EOF
exit 0
}

die() {
echo "$@"
exit 1
}

while [[ $# -ge 1 ]]; do
case "$1" in
-h|--help) usage;;
-srv|--servers-nodes-count) SERVER_NODES_COUNT="$2"; shift 2;;
-g|--gatling-nodes-count) GATLING_NODES_COUNT="$2"; shift 2;;
-s|--simulation) GATLING_SIMULATION_CLASS="$2"; shift 2;;
*) break;;
esac
done

"$SCRIPT_DIR"/run_tests.sh \
-t "$GATLING_STARTER" \
-g "gatling_simulation_class=${GATLING_SIMULATION_CLASS}" \
-g "server_nodes_count=${SERVER_NODES_COUNT}" \
-g "gatling_nodes_count=${GATLING_NODES_COUNT}" \
|| die "Failed to run Gatling test"

echo "Creating Gatling report."

"$SCRIPT_DIR"/ducker-ignite ssh ducker01 "/opt/ignite-dev/modules/gatling/target/gatling-charts-highcharts-bundle-3.5.1/bin/gatling.sh -ro /opt/ignite-dev/results/latest/GatlingTest/gatling_test/ignite_version=ignite-dev/1" \
|| die "Failed to create report."
14 changes: 14 additions & 0 deletions modules/ducktests/tests/ignitetest/gatling/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
73 changes: 73 additions & 0 deletions modules/ducktests/tests/ignitetest/gatling/gatling_service.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
This module contains class to start Gatling test.
"""
import os

from ducktape.mark.resource import cluster
from ducktape.tests.test import TestContext

from ignitetest.services.ignite_app import IgniteApplicationService
from ignitetest.services.utils.ignite_configuration import IgniteConfiguration
from ignitetest.services.utils.path import get_home_dir, PathAware
from ignitetest.utils import ignite_versions
from ignitetest.utils.ignite_test import IgniteTest
from ignitetest.utils.version import DEV_BRANCH, IgniteVersion


# pylint: disable=W0223
class GatlingService(IgniteApplicationService, PathAware):
"""
The base class to start the Gatling application.
"""
GATLING_CLASS_NAME = "org.apache.ignite.gatling.GatlingStarter"

# pylint: disable=R0913
def __init__(self, context, config, simulation_class_name, num_nodes=1, java_class_name=GATLING_CLASS_NAME,
startup_timeout_sec=180, shutdown_timeout_sec=180, jvm_opts=None, full_jvm_opts=None):
super().__init__(context, config, java_class_name, num_nodes, startup_timeout_sec, shutdown_timeout_sec,
modules=["gatling"], jvm_opts=jvm_opts, full_jvm_opts=full_jvm_opts)

self.params = {
"resourcesDirectory": self.gatling_resources(),
"resultsDirectory": self.gatling_logs(),
"binariesDirectory": self.gatling_binaries(),
"simulationClass": simulation_class_name
}

@property
def globals(self):
return self.context.globals

def init_logs_attribute(self):
super().init_logs_attribute()

self.logs["gatling_logs"] = {
"path": self.gatling_logs(),
"collect_default": True
}

def gatling_logs(self):
return os.path.join(self.persistent_root, "gatling", "results")

def gatling_resources(self):
return os.path.join(get_home_dir(self.install_root, str(DEV_BRANCH)), "modules", "gatling", "src",
"test", "resources")

def gatling_binaries(self):
return os.path.join(get_home_dir(self.install_root, str(DEV_BRANCH)), "modules", "gatling", "target",
"test-classes")
61 changes: 61 additions & 0 deletions modules/ducktests/tests/ignitetest/gatling/gatling_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
This module contains basic ignite test.
"""
import os

from ducktape.mark.resource import cluster
from ducktape.tests.test import TestContext
from ignitetest.gatling.gatling_service import GatlingService
from ignitetest.services.ignite import IgniteService
from ignitetest.services.utils.ignite_configuration import IgniteConfiguration
from ignitetest.utils import ignite_versions
from ignitetest.utils.ignite_test import IgniteTest
from ignitetest.utils.version import DEV_BRANCH, IgniteVersion


# pylint: disable=W0223
class GatlingTest(IgniteTest):
"""
Basic Gatling test.
"""

# Simulation class parameter.
GLOBAL_SIMULATION_CLASS = "gatling_simulation_class"

# Server nodes count parameter.
GLOBAL_SERVER_NODES_COUNT = "server_nodes_count"

# Gatling nodes count parameter.
GLOBAL_GATLING_NODES_COUNT = "gatling_nodes_count"

@cluster(num_nodes=12)
@ignite_versions(str(DEV_BRANCH))
def gatling_test(self, ignite_version):
configuration = IgniteConfiguration(version=IgniteVersion(ignite_version))

servers = IgniteService(self.test_context, configuration, startup_timeout_sec=180,
num_nodes=self._global_int(self.GLOBAL_SERVER_NODES_COUNT, 1))

servers.start()

gatling = GatlingService(self.test_context, configuration, self._global_param(self.GLOBAL_SIMULATION_CLASS),
num_nodes=self._global_int(self.GLOBAL_GATLING_NODES_COUNT, 1))

gatling.run()

servers.stop()
6 changes: 6 additions & 0 deletions modules/gatling/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ignite-gatling-ext
=========================

To test it out, simply execute the following command:

$mvn gatling:test
111 changes: 111 additions & 0 deletions modules/gatling/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<!--
POM file.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.apache.ignite</groupId>
<artifactId>ignite-parent</artifactId>
<version>1</version>
<relativePath>../../parent</relativePath>
</parent>

<artifactId>ignite-gatling</artifactId>
<version>2.11.0-SNAPSHOT</version>
<url>http://ignite.apache.org</url>

<properties>
<gatling.version>3.5.1</gatling.version>
</properties>

<dependencies>
<dependency>
<groupId>io.gatling.highcharts</groupId>
<artifactId>gatling-charts-highcharts</artifactId>
<version>${gatling.version}</version>
</dependency>

<dependency>
<groupId>org.apache.ignite</groupId>
<artifactId>ignite-ducktests</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.3.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<id>unpack-gatling-bundle</id>
<phase>prepare-package</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>io.gatling.highcharts</groupId>
<artifactId>gatling-charts-highcharts-bundle</artifactId>
<version>${gatling.version}</version>
<classifier>bundle</classifier>
<type>zip</type>
<overWrite>true</overWrite>
</artifactItem>
</artifactItems>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<configuration>
<target>
<copy todir="${basedir}/target/">
<fileset dir="${basedir}/target/gatling-charts-highcharts-bundle-${gatling.version}/lib"/>
</copy>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.ignite.gatling

import com.fasterxml.jackson.databind.JsonNode
import io.gatling.app.Gatling
import io.gatling.core.config.GatlingPropertiesBuilder
import org.apache.ignite.internal.ducktest.utils.IgniteAwareApplication

/**
* Class to start the Gatling app.
*/
class GatlingStarter extends IgniteAwareApplication {
def run(jsonNode: JsonNode) = {
markInitialized()

val props = new GatlingPropertiesBuilder()
.resourcesDirectory(jsonNode.get("resourcesDirectory").asText())
.resultsDirectory(jsonNode.get("resultsDirectory").asText())
.binariesDirectory(jsonNode.get("binariesDirectory").asText())
.simulationClass(jsonNode.get("simulationClass").asText())
.noReports()
.build

// TODO
// props.put("ignite", ignite)
// props.put("client", client)

Gatling.fromMap(props)

markFinished()
}
}
Loading