Skip to content

Commit

Permalink
evetestkit : add error log function and more
Browse files Browse the repository at this point in the history
- add LogTimeErrorf
- add TestFailed
- add Ubuntu 20.04 app template

Signed-off-by: Shahriyar Jalayeri <[email protected]>
  • Loading branch information
shjala committed Oct 23, 2024
1 parent 35c7400 commit 2cabe15
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions pkg/evetestkit/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ const (
// AppDefaultCloudConfig is a default cloud-init configuration for the VM which just
// enables ssh password authentication and sets the password to "passw0rd".
AppDefaultCloudConfig = "#cloud-config\npassword: " + AppDefaultSSHPass + "\nchpasswd: { expire: False }\nssh_pwauth: True\n"
// Ubuntu2204 indicates the version of Ubuntu 22.04
Ubuntu2204 = "22.04"
// Ubuntu2004 indicates the version of Ubuntu 20.04
Ubuntu2004 = "20.04"
)

var (
Expand All @@ -46,6 +50,14 @@ var (
os: "ubuntu-server-cloudimg-amd64",
version: "22.04",
}
ubuntu2004 = fixedAppInstanceConfig{
appLink: "https://cloud-images.ubuntu.com/releases/20.04/release/ubuntu-20.04-server-cloudimg-amd64.img",
sshPort: "8027",
sshUser: AppDefaultSSHUser,
sshPass: AppDefaultSSHPass,
os: "ubuntu-server-cloudimg-amd64",
version: Ubuntu2004,
}
)

type fixedAppInstanceConfig struct {
Expand Down Expand Up @@ -578,10 +590,30 @@ func (node *EveNode) LogTimeInfof(format string, args ...interface{}) {
}
}

func (node *EveNode) LogTimeErrorf(format string, args ...interface{}) {

Check failure on line 593 in pkg/evetestkit/utils.go

View workflow job for this annotation

GitHub Actions / yetus

revive: exported method EveNode.LogTimeErrorf should have comment or be unexported https://revive.run/r#exported
out := utils.AddTimestampf(format+"\n", args...)
if node.t != nil {
node.t.Fail()
node.t.Logf(out)
} else {
fmt.Print(out)
}
}

func (node *EveNode) SetTesting(t *testing.T) {

Check failure on line 603 in pkg/evetestkit/utils.go

View workflow job for this annotation

GitHub Actions / yetus

revive: exported method EveNode.SetTesting should have comment or be unexported https://revive.run/r#exported
node.t = t
}

func (node *EveNode) TestFailed() bool {

Check failure on line 607 in pkg/evetestkit/utils.go

View workflow job for this annotation

GitHub Actions / yetus

revive: exported method EveNode.TestFailed should have comment or be unexported https://revive.run/r#exported
if node.t == nil {
return node.t.Failed()
}

fmt.Printf("TestFailed called when t is nil\n")
os.Exit(1)
return false
}

func (node *EveNode) discoverEveIP() error {
if node.edgenode.GetRemoteAddr() == "" {
eveIPCIDR, err := node.tc.GetState(node.edgenode).LookUp("Dinfo.Network[0].IPAddrs[0]")
Expand Down

0 comments on commit 2cabe15

Please sign in to comment.