Skip to content

Commit 2cabe15

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

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

pkg/evetestkit/utils.go

Lines changed: 32 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,10 +590,30 @@ func (node *EveNode) LogTimeInfof(format string, args ...interface{}) {
578590
}
579591
}
580592

593+
func (node *EveNode) LogTimeErrorf(format string, args ...interface{}) {
594+
out := utils.AddTimestampf(format+"\n", args...)
595+
if node.t != nil {
596+
node.t.Fail()
597+
node.t.Logf(out)
598+
} else {
599+
fmt.Print(out)
600+
}
601+
}
602+
581603
func (node *EveNode) SetTesting(t *testing.T) {
582604
node.t = t
583605
}
584606

607+
func (node *EveNode) TestFailed() bool {
608+
if node.t == nil {
609+
return node.t.Failed()
610+
}
611+
612+
fmt.Printf("TestFailed called when t is nil\n")
613+
os.Exit(1)
614+
return false
615+
}
616+
585617
func (node *EveNode) discoverEveIP() error {
586618
if node.edgenode.GetRemoteAddr() == "" {
587619
eveIPCIDR, err := node.tc.GetState(node.edgenode).LookUp("Dinfo.Network[0].IPAddrs[0]")

0 commit comments

Comments
 (0)