File size: 1,278 Bytes
8d3471e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package main

import (
	"context"
	"flag"
	"fmt"
	"os"
	"time"

	"ds2api/internal/testsuite"
)

func main() {
	opts := testsuite.DefaultOptions()
	var timeoutSeconds int

	flag.StringVar(&opts.ConfigPath, "config", opts.ConfigPath, "Path to config file (default: config.json)")
	flag.StringVar(&opts.AdminKey, "admin-key", opts.AdminKey, "Admin key (default: DS2API_ADMIN_KEY or admin)")
	flag.StringVar(&opts.OutputDir, "out", opts.OutputDir, "Output artifact directory")
	flag.IntVar(&opts.Port, "port", opts.Port, "Server port (0 means auto-select free port)")
	flag.IntVar(&timeoutSeconds, "timeout", int(opts.Timeout.Seconds()), "Per-request timeout in seconds")
	flag.IntVar(&opts.Retries, "retries", opts.Retries, "Retry count for network/5xx requests")
	flag.BoolVar(&opts.NoPreflight, "no-preflight", opts.NoPreflight, "Skip preflight checks")
	flag.IntVar(&opts.MaxKeepRuns, "keep", opts.MaxKeepRuns, "Max test runs to keep (0 = keep all)")
	flag.Parse()

	if timeoutSeconds <= 0 {
		timeoutSeconds = 120
	}
	opts.Timeout = time.Duration(timeoutSeconds) * time.Second

	if err := testsuite.Run(context.Background(), opts); err != nil {
		_, _ = fmt.Fprintln(os.Stderr, err.Error())
		os.Exit(1)
	}
	_, _ = fmt.Fprintln(os.Stdout, "testsuite completed successfully")
}