Skip to content

[K6 support] Add support to K6 to create tests #234

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
FROM public.ecr.aws/amazonlinux/amazonlinux:2023-minimal

RUN dnf update -y && \
dnf install -y python3.11 python3.11-pip java-21-amazon-corretto bc procps jq findutils unzip && \
curl -sL --retry 3 "https://dl.k6.io/rpm/repo.rpm" -o /tmp/repo.rpm && \
rpm -i /tmp/repo.rpm && rm -f /tmp/repo.rpm && \
dnf install -y python3.11 python3.11-pip java-21-amazon-corretto bc procps jq findutils unzip k6 && \
dnf clean all

ENV PIP_INSTALL="pip3.11 install --no-cache-dir"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ if [ "$TEST_TYPE" != "simple" ]; then
JMETER_LIB_PATH=`find ~/.bzt/jmeter-taurus -type d -name "lib"`
echo "cp $PWD/*.jar $JMETER_LIB_PATH"
cp $PWD/*.jar $JMETER_LIB_PATH
fi

if [ "$TEST_TYPE" == "k6" ]; then
EXT="js"
TYPE_NAME="K6"
fi

if [ "$FILE_TYPE" != "zip" ]; then
Expand All @@ -70,21 +74,23 @@ if [ "$TEST_TYPE" != "simple" ]; then

sed -i -e "s|$TEST_ID.$EXT|$TEST_SCRIPT|g" test.json

# copy bundled plugin jars to jmeter extension folder to make them available to jmeter
BUNDLED_PLUGIN_DIR=`find $PWD -type d -name "plugins" | head -n 1`
# attempt to copy only if a /plugins folder is present in upload
if [ -z "$BUNDLED_PLUGIN_DIR" ]; then
echo "skipping plugin installation (no /plugins folder in upload)"
else
# ensure the jmeter extensions folder exists
JMETER_EXT_PATH=`find ~/.bzt/jmeter-taurus -type d -name "ext"`
if [ -z "$JMETER_EXT_PATH" ]; then
# fail fast - if plugins bundled they will be needed for the tests
echo "jmeter extension path (~/.bzt/jmeter-taurus/**/ext) not found - cannot install bundled plugins"
exit 1
if [ "$TEST_TYPE" == "jmeter" ]; then
# copy bundled plugin jars to jmeter extension folder to make them available to jmeter
BUNDLED_PLUGIN_DIR=`find $PWD -type d -name "plugins" | head -n 1`
# attempt to copy only if a /plugins folder is present in upload
if [ -z "$BUNDLED_PLUGIN_DIR" ]; then
echo "skipping plugin installation (no /plugins folder in upload)"
else
# ensure the jmeter extensions folder exists
JMETER_EXT_PATH=`find ~/.bzt/jmeter-taurus -type d -name "ext"`
if [ -z "$JMETER_EXT_PATH" ]; then
# fail fast - if plugins bundled they will be needed for the tests
echo "jmeter extension path (~/.bzt/jmeter-taurus/**/ext) not found - cannot install bundled plugins"
exit 1
fi
cp -v $BUNDLED_PLUGIN_DIR/*.jar $JMETER_EXT_PATH
fi
cp -v $BUNDLED_PLUGIN_DIR/*.jar $JMETER_EXT_PATH
fi
fi
fi
fi

Expand Down
5 changes: 3 additions & 2 deletions source/console/src/Components/Create/Create.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import RefreshButtons from "../Shared/Buttons/RefreshButtons";
const FILE_SIZE_LIMIT = 50 * 1024 * 1024;

// Allowed file extensions
const SCRIPT_FILE_EXTENSIONS = { jmeter: "jmx" };
const SCRIPT_FILE_EXTENSIONS = { jmeter: "jmx", k6: "js" };

class Create extends React.Component {
constructor(props) {
Expand Down Expand Up @@ -548,7 +548,7 @@ class Create extends React.Component {
};

uploadFileDescription = () => {
if (!["jmeter"].includes(this.state.formValues.testType)) {
if (["simple"].includes(this.state.formValues.testType)) {
return null;
}
const ext = SCRIPT_FILE_EXTENSIONS[this.state.formValues.testType];
Expand Down Expand Up @@ -1367,6 +1367,7 @@ class Create extends React.Component {
>
<option value="simple">Single HTTP Endpoint</option>
<option value="jmeter">JMeter</option>
<option value="k6">K6</option>
</Input>
</FormGroup>
{this.state.formValues.testType === "simple" && (
Expand Down