Use ripgrep to find list of tests
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
parent
da48cf64b3
commit
673638afe7
2 changed files with 43 additions and 28 deletions
|
@ -7,6 +7,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -70,43 +72,57 @@ jobs:
|
||||||
with:
|
with:
|
||||||
name: logs
|
name: logs
|
||||||
path: "control_logs/*.log"
|
path: "control_logs/*.log"
|
||||||
`))
|
`),
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
const workflowFilePerm = 0o600
|
const workflowFilePerm = 0o600
|
||||||
|
|
||||||
|
func findTests() []string {
|
||||||
|
rgBin, err := exec.LookPath("rg")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("failed to find rg (ripgrep) binary")
|
||||||
|
}
|
||||||
|
|
||||||
|
args := []string{
|
||||||
|
"--regexp", "func (Test.+)\\(.*",
|
||||||
|
"../../integration/",
|
||||||
|
"--replace", "$1",
|
||||||
|
"--sort", "path",
|
||||||
|
"--no-line-number",
|
||||||
|
"--no-filename",
|
||||||
|
"--no-heading",
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Printf("executing: %s %s", rgBin, strings.Join(args, " "))
|
||||||
|
|
||||||
|
ripgrep := exec.Command(
|
||||||
|
rgBin,
|
||||||
|
args...,
|
||||||
|
)
|
||||||
|
|
||||||
|
result, err := ripgrep.CombinedOutput()
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("out: %s", result)
|
||||||
|
log.Fatalf("failed to run ripgrep: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
tests := strings.Split(string(result), "\n")
|
||||||
|
tests = tests[:len(tests)-1]
|
||||||
|
|
||||||
|
return tests
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
type testConfig struct {
|
type testConfig struct {
|
||||||
Name string
|
Name string
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(kradalby): automatic fetch tests at runtime
|
tests := findTests()
|
||||||
tests := []string{
|
|
||||||
"TestAuthKeyLogoutAndRelogin",
|
|
||||||
"TestAuthWebFlowAuthenticationPingAll",
|
|
||||||
"TestAuthWebFlowLogoutAndRelogin",
|
|
||||||
"TestCreateTailscale",
|
|
||||||
"TestEnablingRoutes",
|
|
||||||
"TestHeadscale",
|
|
||||||
"TestUserCommand",
|
|
||||||
"TestOIDCAuthenticationPingAll",
|
|
||||||
"TestOIDCExpireNodesBasedOnTokenExpiry",
|
|
||||||
"TestPingAllByHostname",
|
|
||||||
"TestPingAllByIP",
|
|
||||||
"TestPreAuthKeyCommand",
|
|
||||||
"TestPreAuthKeyCommandReusableEphemeral",
|
|
||||||
"TestPreAuthKeyCommandWithoutExpiry",
|
|
||||||
"TestResolveMagicDNS",
|
|
||||||
"TestSSHIsBlockedInACL",
|
|
||||||
"TestSSHMultipleUsersAllToAll",
|
|
||||||
"TestSSHNoSSHConfigured",
|
|
||||||
"TestSSHOneUserAllToAll",
|
|
||||||
"TestSSUserOnlyIsolation",
|
|
||||||
"TestTaildrop",
|
|
||||||
"TestTailscaleNodesJoiningHeadcale",
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
|
log.Printf("generating workflow for %s", test)
|
||||||
|
|
||||||
var content bytes.Buffer
|
var content bytes.Buffer
|
||||||
|
|
||||||
if err := jobTemplate.Execute(&content, testConfig{
|
if err := jobTemplate.Execute(&content, testConfig{
|
||||||
|
|
|
@ -11,6 +11,5 @@ Tests are located in files ending with `_test.go` and the framework are located
|
||||||
|
|
||||||
## Running integration tests on GitHub Actions
|
## Running integration tests on GitHub Actions
|
||||||
|
|
||||||
Each test currently runs as a separate workflows in GitHub actions, to add new test, add
|
Each test currently runs as a separate workflows in GitHub actions, to add new test, run
|
||||||
the new test to the list in `../cmd/gh-action-integration-generator/main.go` and run
|
|
||||||
`go generate` inside `../cmd/gh-action-integration-generator/` and commit the result.
|
`go generate` inside `../cmd/gh-action-integration-generator/` and commit the result.
|
||||||
|
|
Loading…
Reference in a new issue