-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Bella Khizgiyaev <[email protected]>
- Loading branch information
Showing
7 changed files
with
186 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package framework | ||
|
||
import ( | ||
"context" | ||
"os" | ||
|
||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/client-go/kubernetes" | ||
) | ||
|
||
// 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 | ||
} | ||
|
||
r.vmData.testVMId = "b023ad5c55444c081c0837f5caa8dc3b2b9f" | ||
r.vmData.testNetworkID = "ae1badc8c693926f492a01e2f357d6af321b" | ||
r.vmData.testStorageName = "Dummy storage for source provider ova-provider" | ||
return &r.vmData, nil | ||
} | ||
|
||
func (r *OvaClient) GetNfsServerForOva(k8sClient *kubernetes.Clientset) (string, error) { | ||
storageClass, err := k8sClient.StorageV1().StorageClasses().Get(context.TODO(), r.storageClass, metav1.GetOptions{}) | ||
if err != nil { | ||
return "", err | ||
} | ||
var nfsShare string | ||
for parm, val := range storageClass.Parameters { | ||
if parm == "server" { | ||
nfsShare = nfsShare + val | ||
} | ||
if parm == "share" { | ||
nfsShare = nfsShare + val | ||
} | ||
} | ||
if nfsShare != "" { | ||
r.nfsPath = nfsShare | ||
} | ||
return r.nfsPath, nil | ||
} | ||
|
||
// GetNetworkId - return the network interface for the VM | ||
func (r *OvaVM) GetNetworkId() string { | ||
return r.testNetworkID | ||
} | ||
|
||
// GetVolumeId - return storage domain IDs | ||
func (r *OvaVM) GetStorageName() string { | ||
return r.testStorageName | ||
} | ||
|
||
// GetTestVMId - return the test VM ID | ||
func (r *OvaVM) GetVmId() string { | ||
return r.testVMId | ||
} | ||
|
||
type OvaClient struct { | ||
vmData OvaVM | ||
CustomEnv bool | ||
nfsPath string | ||
storageClass string | ||
} | ||
|
||
type OvaVM struct { | ||
testVMId string | ||
testNetworkID string | ||
testStorageName string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package suit_test | ||
|
||
import ( | ||
"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" | ||
) | ||
|
||
const ( | ||
ovaProviderName = "ova-provider" | ||
ovaStorageClass = "nfs-csi" | ||
) | ||
|
||
var _ = Describe("[level:component]Migration tests for OVA provider", func() { | ||
f := framework.NewFramework("migration-func-test") | ||
|
||
It("[test] should create provider with NetworkMap", func() { | ||
namespace := f.Namespace.Name | ||
|
||
By("Load Source VM Details from OVA") | ||
vmData, err := f.Clients.OvaClient.LoadSourceDetails() | ||
Expect(err).ToNot(HaveOccurred()) | ||
|
||
By("Get NFS share for OVA provider") | ||
nfs, err := f.Clients.OvaClient.GetNfsServerForOva(f.K8sClient) | ||
Expect(err).ToNot(HaveOccurred()) | ||
By("Create Secret from Definition") | ||
s, err := utils.CreateSecretFromDefinition(f.K8sClient, utils.NewSecretDefinition(nil, nil, | ||
map[string][]byte{ | ||
"url": []byte(nfs), | ||
}, namespace, "provider-test-secret")) | ||
Expect(err).ToNot(HaveOccurred()) | ||
|
||
targetNS, err := f.CreateNamespace("ova-migration-test", map[string]string{}) | ||
Expect(err).ToNot(HaveOccurred()) | ||
By("Create target Openshift provider") | ||
targetPr := utils.NewProvider(utils.TargetProviderName, forkliftv1.OpenShift, namespace, map[string]string{}, map[string]string{}, "", nil) | ||
err = utils.CreateProviderFromDefinition(f.CrClient, targetPr) | ||
Expect(err).ToNot(HaveOccurred()) | ||
_, err = utils.WaitForProviderReadyWithTimeout(f.CrClient, namespace, utils.TargetProviderName, 30*time.Second) | ||
Expect(err).ToNot(HaveOccurred()) | ||
By("Create OVA provider") | ||
pr := utils.NewProvider(ovaProviderName, forkliftv1.Ova, namespace, map[string]string{}, map[string]string{}, "nfs_url", s) | ||
err = utils.CreateProviderFromDefinition(f.CrClient, pr) | ||
Expect(err).ToNot(HaveOccurred()) | ||
provider, err := utils.WaitForProviderReadyWithTimeout(f.CrClient, namespace, ovaProviderName, 60*time.Second) | ||
Expect(err).ToNot(HaveOccurred()) | ||
By("Create Network Map") | ||
networkMapDef := utils.NewNetworkMap(namespace, *provider, networkMapName, vmData.GetNetworkId()) | ||
err = utils.CreateNetworkMapFromDefinition(f.CrClient, networkMapDef) | ||
Expect(err).ToNot(HaveOccurred()) | ||
err = utils.WaitForNetworkMapReadyWithTimeout(f.CrClient, namespace, networkMapName, 10*time.Second) | ||
Expect(err).ToNot(HaveOccurred()) | ||
By("Create Storage Map") | ||
storageMapDef := utils.NewStorageMap(namespace, *provider, test_storage_map_name, []string{vmData.GetStorageName()}, ovaStorageClass) | ||
err = utils.CreateStorageMapFromDefinition(f.CrClient, storageMapDef) | ||
Expect(err).ToNot(HaveOccurred()) | ||
err = utils.WaitForStorageMapReadyWithTimeout(f.CrClient, namespace, test_storage_map_name, 10*time.Second) | ||
Expect(err).ToNot(HaveOccurred()) | ||
|
||
By("Creating plan") | ||
planDef := utils.NewPlanWithVmName(*provider, namespace, test_plan_name, test_storage_map_name, networkMapName, []string{vmData.GetVmId()}, targetNS.Name) | ||
|
||
err = utils.CreatePlanFromDefinition(f.CrClient, planDef) | ||
Expect(err).ToNot(HaveOccurred()) | ||
err, _ = utils.WaitForPlanReadyWithTimeout(f.CrClient, namespace, test_plan_name, 15*time.Second) | ||
Expect(err).ToNot(HaveOccurred()) | ||
|
||
By("Creating migration") | ||
migrationDef := utils.NewMigration(provider.Namespace, test_migration_name, test_plan_name) | ||
err = utils.CreateMigrationFromDefinition(f.CrClient, migrationDef) | ||
Expect(err).ToNot(HaveOccurred()) | ||
err = utils.WaitForMigrationSucceededWithTimeout(f.CrClient, provider.Namespace, test_migration_name, 900*time.Second) | ||
Expect(err).ToNot(HaveOccurred()) | ||
|
||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters