Skip to content

Commit 1c66635

Browse files
committed
evetestkit : add error log function and more
- add LogTimeErrorf - add Ubuntu 20.04 app template Signed-off-by: Shahriyar Jalayeri <[email protected]>
1 parent 35c7400 commit 1c66635

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

pkg/evetestkit/utils.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ const (
3333
// AppDefaultCloudConfig is a default cloud-init configuration for the VM which just
3434
// enables ssh password authentication and sets the password to "passw0rd".
3535
AppDefaultCloudConfig = "#cloud-config\npassword: " + AppDefaultSSHPass + "\nchpasswd: { expire: False }\nssh_pwauth: True\n"
36+
// Ubuntu2204 indicates the version of Ubuntu 22.04
37+
Ubuntu2204 = "22.04"
38+
// Ubuntu2004 indicates the version of Ubuntu 20.04
39+
Ubuntu2004 = "20.04"
3640
)
3741

3842
var (
@@ -46,6 +50,14 @@ var (
4650
os: "ubuntu-server-cloudimg-amd64",
4751
version: "22.04",
4852
}
53+
ubuntu2004 = fixedAppInstanceConfig{
54+
appLink: "https://cloud-images.ubuntu.com/releases/20.04/release/ubuntu-20.04-server-cloudimg-amd64.img",
55+
sshPort: "8027",
56+
sshUser: AppDefaultSSHUser,
57+
sshPass: AppDefaultSSHPass,
58+
os: "ubuntu-server-cloudimg-amd64",
59+
version: Ubuntu2004,
60+
}
4961
)
5062

5163
type fixedAppInstanceConfig struct {
@@ -578,6 +590,19 @@ func (node *EveNode) LogTimeInfof(format string, args ...interface{}) {
578590
}
579591
}
580592

593+
// LogTimeErrorf logs an error message with a timestamp, if it is called in the context
594+
// of a test function it will call t.Fail and t.Logf, otherwise it will call fmt.Print
595+
func (node *EveNode) LogTimeErrorf(format string, args ...interface{}) {
596+
out := utils.AddTimestampf(format+"\n", args...)
597+
if node.t != nil {
598+
node.t.Fail()
599+
node.t.Logf(out)
600+
} else {
601+
fmt.Print(out)
602+
}
603+
}
604+
605+
// SetTesting sets the testing.T object for the EveNode
581606
func (node *EveNode) SetTesting(t *testing.T) {
582607
node.t = t
583608
}

0 commit comments

Comments
 (0)