A k6 extension for sending strings to TCP port
To build a k6
binary with this plugin, first ensure you have the prerequisites:
- Go toolchain
- Git
Then:
- Install
xk6
:
go install github.com/k6io/xk6/cmd/xk6@latest
- Build the binary:
xk6 build master \
--with github.com/NAlexandrov/xk6-tcp
import tcp from 'k6/x/tcp';
import { check } from 'k6';
const conn = tcp.connect('host:port');
export default function () {
tcp.writeLn(conn, 'Say Hello');
let res = String.fromCharCode(...tcp.read(conn, 1024))
check (res, {
'verify ag tag': (res) => res.includes('Hello')
});
tcp.close(conn);
}