Hi community, I created a simple script containing two groups, each of them with a single get request, like this:
import http from 'k6/http'
import { check, group } from 'k6'
export const options = {
stages: [{ duration: '1m', target: 2 }],
thresholds: {
http_req_duration: ['p(90)<12000'],
},
}
export default function () {
group('getContacts', () => {
const responseContent = http.get("https://test.k6.io/contacts.php", {
tags: { name: 'getContacts' },
responseType: 'text',
})
check(responseContent, {
'response code was 200': (response) => response.status === 200,
'response body contains this string': (response) => response.body.includes("Load Impact AB"),
})
})
group('getNews', () => {
const responseContent = http.get("https://test.k6.io/news.php", {
tags: { name: 'getNews' },
responseType: 'text',
})
check(responseContent, {
'response code was 200': (response) => response.status === 200,
'response body contains this string': (response) => response.body.includes("In the news"),
})
})
}
as you can see we set a tag name for each group, getNews and getContacts respectively.
My question is, could I set the tag name as an option when executing the script for running only specific requests?, for example:
k6 run tag-test.spec.js --http-debug="full" --tag NAME=getNews
From my results, I see that both requests are being sent instead the set one.
Let me know if you need additional information or if something is not clear on my end.
Thanks!