Skip to content

Commit

Permalink
save the db after test
Browse files Browse the repository at this point in the history
Signed-off-by: Kristoffer Dalby <[email protected]>
  • Loading branch information
kradalby committed Nov 15, 2023
1 parent e31ecdd commit 7bfef32
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions integration/hsic/hsic.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,14 @@ func (t *HeadscaleInContainer) Shutdown() error {
)
}

err = t.SaveDatabase("/tmp/control")
if err != nil {
log.Printf(
"Failed to save database from control: %s",
fmt.Errorf("failed to save database from control: %w", err),
)
}

return t.pool.Purge(t.container)
}

Expand Down Expand Up @@ -393,6 +401,24 @@ func (t *HeadscaleInContainer) SaveMapResponses(savePath string) error {
return nil
}

func (t *HeadscaleInContainer) SaveDatabase(savePath string) error {
tarFile, err := t.FetchPath("/tmp/integration_test_db.sqlite3")
if err != nil {
return err
}

err = os.WriteFile(
path.Join(savePath, t.hostname+".db.tar"),
tarFile,
os.ModePerm,
)
if err != nil {
return err
}

return nil
}

// Execute runs a command inside the Headscale container and returns the
// result of stdout as a string.
func (t *HeadscaleInContainer) Execute(
Expand Down

0 comments on commit 7bfef32

Please sign in to comment.