Skip to content

Commit

Permalink
OVA test: add minor code changes
Browse files Browse the repository at this point in the history
Signed-off-by: Bella Khizgiyaev <[email protected]>
  • Loading branch information
bkhizgiy committed Dec 4, 2023
1 parent 6182202 commit 3d880fa
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 6 deletions.
11 changes: 8 additions & 3 deletions tests/suit/framework/ova.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package framework

import (
"context"
"errors"
"os"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -10,7 +11,6 @@ import (

// LoadSourceDetails - Load Source VM details from ova
func (r *OvaClient) LoadSourceDetails() (vm *OvaVM, err error) {
r.storageClass = DefaultStorageClass
if sc := os.Getenv("STORAGE_CLASS"); sc != "" {
r.storageClass = sc
} else {
Expand All @@ -29,16 +29,21 @@ func (r *OvaClient) GetNfsServerForOva(k8sClient *kubernetes.Clientset) (string,
return "", err
}
var nfsShare string
var server, share string
for parm, val := range storageClass.Parameters {
if parm == "server" {
nfsShare = val
server = val
}
if parm == "share" {
nfsShare = nfsShare + ":" + val
share = val
}
}
nfsShare = server + ":" + share

if nfsShare != "" {
r.nfsPath = nfsShare
} else {
return "", errors.New("failed to fatch NFS settings")
}
return r.nfsPath, nil
}
Expand Down
34 changes: 34 additions & 0 deletions tests/suit/ova_test.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
package suit_test

import (
"bytes"
"context"
"fmt"
"io"
"strings"
"time"

forkliftv1 "github.com/konveyor/forklift-controller/pkg/apis/forklift/v1beta1"
"github.com/konveyor/forklift-controller/tests/suit/framework"
"github.com/konveyor/forklift-controller/tests/suit/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
core "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

const (
Expand Down Expand Up @@ -78,6 +85,33 @@ var _ = Describe("[level:component]Migration tests for OVA provider", func() {
err = utils.CreateMigrationFromDefinition(f.CrClient, migrationDef)
Expect(err).ToNot(HaveOccurred())
err = utils.WaitForMigrationSucceededWithTimeout(f.CrClient, provider.Namespace, test_migration_name, 900*time.Second)
if err != nil {
podname := ""
pods, err1 := f.K8sClient.CoreV1().Pods(targetNS.Name).List(context.Background(), metav1.ListOptions{})
if err1 != nil {
fmt.Println("this is error, ", err1)
}
for _, pod := range pods.Items {
if strings.HasPrefix(pod.Name, "plan-test") {
podname = pod.Name
}
}
podLogOpts := core.PodLogOptions{}
request := f.K8sClient.CoreV1().Pods(targetNS.Name).GetLogs(podname, &podLogOpts)
podLogs, err1 := request.Stream(context.Background())
if err1 != nil {
panic(err1.Error())
}
defer podLogs.Close()
buf := new(bytes.Buffer)
_, err1 = io.Copy(buf, podLogs)
if err1 != nil {
panic(err1.Error())
}
str := buf.String()
fmt.Println("Logs for pod", podname)
fmt.Println(str)
}
Expect(err).ToNot(HaveOccurred())

})
Expand Down
7 changes: 4 additions & 3 deletions tests/suit/utils/storagemap.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ func NewStorageMap(namespace string, providerIdentifier forkliftv1.Provider, sto
},
}

if providerIdentifier.Type() != api.Ova {
pair.Source = ref.Ref{ID: sd}
} else {
switch providerIdentifier.Type() {
case api.Ova:
pair.Source = ref.Ref{Name: sd}
default:
pair.Source = ref.Ref{ID: sd}
}

sdPairs = append(sdPairs, pair)
Expand Down

0 comments on commit 3d880fa

Please sign in to comment.