Skip to content

Commit

Permalink
fix: Some minor fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Marek Fedorovic committed Feb 20, 2024
1 parent cc300bb commit 115137b
Show file tree
Hide file tree
Showing 12 changed files with 119 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
dev-home
dist
node_modules
tmp
tmp*
.env
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ spec:
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: {{ .Values.service.port }}
containerPort: {{ .Values.container.port }}
protocol: TCP
resources:
limits:
Expand Down
1 change: 1 addition & 0 deletions examples/graph-perf-test-app/deployment/pit/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ helm upgrade --install \
--namespace $K8S_NAMESPACE \
--set image.tag=$IMAGE_TAG \
--set pod.repository=$REGISTRY_URL/$SERVICE_NAME \
--set container.port=$CONTAINER_PORT \
--set service.port=$SERVICE_PORT \
--set environment.TARGET_SERVICE_URL=$TARGET_SERVICE_URL \
--set webApp.contextRoot=$K8S_NAMESPACE.$WEB_APP_CONTEXT_ROOT \
Expand Down
4 changes: 2 additions & 2 deletions examples/graph-perf-test-app/k6-tests/node-1-k6-tests.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import http from 'k6/http'
import { check, fail } from 'k6'
import { check } from 'k6'

//"GET /time [10s using 50 users at 500 TPS]"
//"GET /time [5s using 5 users at 500 TPS] + [10s using 10 users at 500 TPS]"
export const options = {
scenarios: {
u5_duration_5s: {
Expand Down
34 changes: 34 additions & 0 deletions examples/graph-perf-test-app/pitfile-local.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
version: "1.0"
projectName: "K6 Tests for Node-1"
lockManager:
enabled: false
testSuites:
- name: "K6 tests for 'GET /time'"
id: node-1-k6-tests

deployment:
graph:
testApp:
name: "Performance Test App for Node 1"
id: "graph-perf-test-app"
location:
type: LOCAL
deploy:
command: deployment/pit/deploy.sh
params:
- 'node-1' # The name of target service. Deployer will compose it into the full URL
statusCheck:
command: deployment/pit/is-deployment-ready.sh
undeploy:
timeoutSeconds: 120
command: deployment/pit/undeploy.sh
components:
- name: Node 1
id: node-1
deploy:
command: deployment/pit/deploy.sh
statusCheck:
command: deployment/pit/is-deployment-ready.sh
undeploy:
timeoutSeconds: 120
command: deployment/pit/undeploy.sh
8 changes: 6 additions & 2 deletions examples/graph-perf-test-app/src/report/adapters/k6.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ export const convertFrom = (k6Report: Array<any>): Array<report.TestScenario> =>
stats.count++
}

const expectedTps = new report.ScalarMetric("throughput", 600.0)
const expected = new Map()
expected.set("u5_duration_5s", new report.ScalarMetric("throughput", 600.0))
expected.set("u10_duration_10s", new report.ScalarMetric("throughput", 400.0))

const scenarios = Array.from(statsPerScenario.keys()).map(scenarioName => {
const expectedTps = expected.get(scenarioName)
const stats = statsPerScenario.get(scenarioName)
const elapsed = (stats.timeTo.getTime() - stats.timeFrom.getTime()) / 1_000.0
const rate = stats.count / elapsed
Expand All @@ -38,7 +42,7 @@ export const convertFrom = (k6Report: Array<any>): Array<report.TestScenario> =>
stats.timeTo,
[
new report.TestStream(
"defult",
"default",
[ expectedTps ],
[ actualTps ],
expectedTps.value <= rate ? report.TestOutcomeType.PASS : report.TestOutcomeType.FAIL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ spec:
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: {{ .Values.service.port }}
containerPort: {{ .Values.container.port }}
protocol: TCP
resources:
limits:
Expand Down
1 change: 1 addition & 0 deletions examples/node-1/pit-test-app/deployment/pit/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ helm upgrade --install \
--set image.tag=$IMAGE_TAG \
--set pod.repository=$REGISTRY_URL/$TEST_APP_SERVICE_NAME \
--set service.port=$TEST_APP_SERVICE_PORT \
--set container.port=$TEST_APP_CONTAINER_PORT \
--set environment.TARGET_SERVICE_URL=$TARGET_SERVICE_URL \
--set webApp.contextRoot=$K8S_NAMESPACE.$WEB_APP_CONTEXT_ROOT \
$TEST_APP_SERVICE_NAME ./$CHART_PACKAGE
Expand Down
44 changes: 44 additions & 0 deletions examples/node-1/pitfile-local.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
version: "1.0"
projectName: "Tests for node-1 app"

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# The lock manager is part of PIT toolkit. CI will already have it available
# This optional config section is here only to indicate that lock manager
# should be deployed.
lockManager:
enabled: false

testSuites:
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- name: Default tests for Node 1
id: node-1-default

deployment:
graph:
testApp:
name: Test App for Node 1
id: node-1-test-app
location:
path: node-1/pit-test-app
deploy:
timeoutSeconds: 60
command: deployment/pit/deploy.sh
statusCheck:
timeoutSeconds: 60
command: deployment/pit/is-deployment-ready.sh
undeploy:
timeoutSeconds: 120
command: deployment/pit/undeploy.sh

components:
- name: Node 1
id: node-1
deploy:
timeoutSeconds: 60
command: deployment/pit/deploy.sh
statusCheck:
timeoutSeconds: 60
command: deployment/pit/is-deployment-ready.sh
undeploy:
timeoutSeconds: 120
command: deployment/pit/undeploy.sh
18 changes: 18 additions & 0 deletions examples/node-1/pitfile-remote.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: "1.0"
projectName: "Tests for node-1 app"

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# The lock manager is part of PIT toolkit. CI will already have it available
# This optional config section is here only to indicate that lock manager
# should be deployed.
lockManager:
enabled: false

testSuites:
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- name: K6 testset for Node 1
id: node-1-k6-tests
location:
type: REMOTE
gitRepository: git://127.0.0.1:60100/graph-perf-test-app.git
testSuiteIds: [] # Empty array is interpreted as "run all tests"
1 change: 0 additions & 1 deletion examples/node-1/pitfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ testSuites:
ids:
- "lock-node-1"

trigger: # This is optional, when not defined, test will trigger when top level trigger goes off
deployment:
graph:
testApp:
Expand Down
15 changes: 10 additions & 5 deletions k8s-deployer/scripts/publish-report.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/bash

HOME_DIR=$1 # current directory where script will be executing
CONTENT_DIR=$2 # relative to HOME_DIR
GIT_REPO=$3 # publish location
HOME_DIR=$1 # current directory where script will be executing
CONTENT_DIR=$2 # relative to HOME_DIR
GIT_REPO=$3 # publish location
BRANCH_NAME=$4
PUBLISH_DIR=$5 # the directory in the project where new report will be stored
PUBLISH_DIR=$5 # the directory in the project where new report will be stored
COMMIT_MESSAGE=$6

STATUS_DONE="Status=DONE"
Expand Down Expand Up @@ -56,6 +56,10 @@ fi
# The caller is expected to set "USERNAME" env variable
AUTHOR_ARG="${USERNAME} <${USERNAME}@kindredgroup.com>"

cp .git/config ./git/config_backup
git config user.email "${USERNAME}@kindredgroup.com"
git config user.name "${USERNAME}"

CONTENT_DIR_PATH="${HOME_DIR}/${CONTENT_DIR}"
if [ ! -d "${CONTENT_DIR_PATH}" ];
then
Expand All @@ -77,7 +81,8 @@ git clone $GIT_REPO . && \
git add --all && \
git status && \
git commit --author "${AUTHOR_ARG}" -a -m "${COMMIT_MESSAGE}" && \
git push -u origin $BRANCH_NAME
git push -u origin $BRANCH_NAME && \
mv ./git/config_backup ./git/config

resultStatus=$(($?+0))

Expand Down

0 comments on commit 115137b

Please sign in to comment.