Skip to content

Commit

Permalink
feat: automated release test
Browse files Browse the repository at this point in the history
Signed-off-by: Emanuele Di Pascale <emanuele@githedgehog.com>
  • Loading branch information
edipascale committed Mar 5, 2025
1 parent b3e4bad commit 6b7da22
Show file tree
Hide file tree
Showing 6 changed files with 1,732 additions and 0 deletions.
35 changes: 35 additions & 0 deletions cmd/hhfab/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ const (
FlagNameFailFast = "fail-fast"
FlagNameReady = "ready"
FlagNameCollectShowTech = "collect-show-tech"
FlagRegEx = "regex"
FlagInvertRegex = "invert-regex"
FlagResultsFile = "results-file"
)

func main() {
Expand Down Expand Up @@ -988,6 +991,38 @@ func Run(ctx context.Context) error {
return nil
},
},
{
Name: "release-test",
Usage: "run release tests on current VLAB instance",
Flags: append(defaultFlags,
&cli.StringSliceFlag{
Name: FlagRegEx,
Aliases: []string{"r"},
Usage: "run only tests matched by regular expression. can be repeated",
},
&cli.BoolFlag{
Name: FlagInvertRegex,
Usage: "invert regex match",
},
&cli.StringFlag{
Name: FlagResultsFile,
Usage: "path to a file to export test results to in JUnit XML format",
},
),
Before: before(false),
Action: func(c *cli.Context) error {
opts := hhfab.ReleaseTestOpts{
Regexes: c.StringSlice(FlagRegEx),
InvertRegex: c.Bool(FlagInvertRegex),
ResultsFile: c.String(FlagResultsFile),
}
if err := hhfab.DoVLABReleaseTest(ctx, workDir, cacheDir, opts); err != nil {
return fmt.Errorf("release-test: %w", err)
}

return nil
},
},
{
Name: "switch",
Usage: "manage switch reinstall or power",
Expand Down
9 changes: 9 additions & 0 deletions pkg/hhfab/cmdvlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,15 @@ func DoVLABInspect(ctx context.Context, workDir, cacheDir string, opts InspectOp
return c.Inspect(ctx, vlab, opts)
}

func DoVLABReleaseTest(ctx context.Context, workDir, cacheDir string, opts ReleaseTestOpts) error {
c, _, err := loadVLABForHelpers(ctx, workDir, cacheDir)
if err != nil {
return err
}

return c.ReleaseTest(ctx, opts)
}

type SwitchPowerOpts struct {
Switches []string // All switches if empty
Action pdu.Action // Power action (e.g., on, off, cycle)
Expand Down
Loading

0 comments on commit 6b7da22

Please sign in to comment.