2024-02-21 08:41:49 +00:00
|
|
|
package k6
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2024-02-21 13:09:22 +00:00
|
|
|
"log/slog"
|
2024-02-21 08:41:49 +00:00
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestK6(t *testing.T) {
|
|
|
|
ctx := context.Background()
|
2024-02-21 13:09:22 +00:00
|
|
|
logger := slog.Default()
|
2024-02-21 08:41:49 +00:00
|
|
|
|
|
|
|
script := `
|
|
|
|
import http from 'k6/http';
|
|
|
|
import { sleep } from 'k6';
|
|
|
|
|
|
|
|
export const options = {
|
|
|
|
vus: 10,
|
|
|
|
duration: '30s',
|
|
|
|
};
|
|
|
|
|
|
|
|
export default function () {
|
2024-02-21 09:06:54 +00:00
|
|
|
http.get('https://test.k6.io');
|
2024-02-21 08:41:49 +00:00
|
|
|
sleep(1);
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
2024-02-21 13:09:22 +00:00
|
|
|
execution := NewExecution(logger, script)
|
2024-02-21 08:41:49 +00:00
|
|
|
|
|
|
|
err := execution.Start(ctx)
|
|
|
|
if err != nil {
|
|
|
|
t.Errorf("Error starting execution: %v", err)
|
|
|
|
}
|
|
|
|
}
|