Skip to content

Commit

Permalink
evetestkit : fix yetus complaints
Browse files Browse the repository at this point in the history
Signed-off-by: Shahriyar Jalayeri <shahriyar@zededa.com>
  • Loading branch information
shjala authored and uncleDecart committed Oct 23, 2024
1 parent c5c2d3a commit f81d991
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 11 additions & 4 deletions pkg/evetestkit/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ 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 = "22.04"
)

var (
Expand All @@ -45,7 +44,7 @@ var (
sshUser: AppDefaultSSHUser,
sshPass: AppDefaultSSHPass,
os: "ubuntu-server-cloudimg-amd64",
version: Ubuntu2204,
version: "22.04",
}
)

Expand Down Expand Up @@ -74,6 +73,8 @@ type appInstanceConfig struct {
destructiveUse bool
}

// TestScript is a struct that holds the information about the test scripts
// that are copied to the app VM running on the EVE node.
type TestScript struct {
Name string
DstPath string
Expand Down Expand Up @@ -398,7 +399,7 @@ func (node *EveNode) AppSCPCopy(appName, localFile, remoteFile string) error {
return nil
}

// TestScript copies the test scripts to the app VM running on the EVE node,
// CopyTestScripts copies the test scripts to the app VM running on the EVE node,
// makes them executable and sets the path to the copied script in the input.
func (node *EveNode) CopyTestScripts(appName, basetPath string, scripts *[]TestScript) error {
for i := range *scripts {
Expand Down Expand Up @@ -429,6 +430,7 @@ func (node *EveNode) CopyTestScripts(appName, basetPath string, scripts *[]TestS
return nil
}

// GetCopiedScriptPath returns the path to the copied script on the app VM running on the EVE node.
func (node *EveNode) GetCopiedScriptPath(scriptName string) string {
for _, script := range node.ts {
if script.Name == scriptName {
Expand Down Expand Up @@ -490,7 +492,7 @@ func (node *EveNode) EveRebootAndWait(timeoutSeconds uint) error {
}

// EveDeployApp deploys a VM/App on the EVE node
func (node *EveNode) EveDeployApp(appLink, os, version string, destructiveUse bool, pc openevec.PodConfig, options ...AppOption) error {
func (node *EveNode) EveDeployApp(appLink string, destructiveUse bool, pc openevec.PodConfig, options ...AppOption) error {
app := appInstanceConfig{name: pc.Name, destructiveUse: destructiveUse}
for _, option := range options {
option(node, pc.Name)
Expand All @@ -509,6 +511,7 @@ func (node *EveNode) EveDeployApp(appLink, os, version string, destructiveUse bo
return node.controller.PodDeploy(appLink, pc, node.cfg)
}

// EveDeployUbuntu deploys an Ubuntu VM on the EVE node
func (node *EveNode) EveDeployUbuntu(version, name string, destructiveUse bool) (string, error) {
var app appInstanceConfig
var pubPorts []string
Expand Down Expand Up @@ -552,6 +555,8 @@ func (node *EveNode) EveIsTpmEnabled() bool {
return node.cfg.Eve.TPM
}

// LogTimeFatalf logs a message with a timestamp, if it is called in the context
// of a test function it will call t.Fatal, otherwise it will call os.Exit(1)
func (node *EveNode) LogTimeFatalf(format string, args ...interface{}) {
out := utils.AddTimestampf(format+"\n", args...)
if node.t != nil {
Expand All @@ -562,6 +567,8 @@ func (node *EveNode) LogTimeFatalf(format string, args ...interface{}) {
}
}

// LogTimeInfof logs a message with a timestamp, if it is called in the context
// of a test function it will call t.Logf, otherwise it will call fmt.Print
func (node *EveNode) LogTimeInfof(format string, args ...interface{}) {
out := utils.AddTimestampf(format+"\n", args...)
if node.t != nil {
Expand Down
2 changes: 1 addition & 1 deletion tests/vcom/vcom_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func TestVcomLinkTpmRequestEK(t *testing.T) {
appName := tk.GetRandomAppName(projectName + "-")
pubPorts := []string{sshPort + ":22"}
pc := tk.GetDefaultVMConfig(appName, tk.AppDefaultCloudConfig, pubPorts)
err = eveNode.EveDeployApp(appLink, pc, tk.WithSSH(tk.AppDefaultSSHUser, tk.AppDefaultSSHPass, sshPort))
err = eveNode.EveDeployApp(appLink, true, pc, tk.WithSSH(tk.AppDefaultSSHUser, tk.AppDefaultSSHPass, sshPort))
if err != nil {
logFatalf("Failed to deploy app: %v", err)
}
Expand Down

0 comments on commit f81d991

Please sign in to comment.