Skip to content

Commit

Permalink
Move pkg -> tests; replace mock fns with proper hapi mock (#246)
Browse files Browse the repository at this point in the history
* pkg -> tests; mock hapi properly

* fix add tests; tidy mock naming; rename GetHashboard() -> GetHashboardClient()

* Fixing lint and unit tests for VMM feature.

---------

Co-authored-by: nikolay-spectro <[email protected]>
  • Loading branch information
TylerGillson and nikchern authored Apr 5, 2023
1 parent b362c11 commit cb91435
Show file tree
Hide file tree
Showing 80 changed files with 835 additions and 3,892 deletions.
173 changes: 173 additions & 0 deletions examples/resources/spectrocloud_virtual_machine2/container.tf1
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
resource "spectrocloud_virtual_machine" "virtual_machine_cont" {
cluster_uid = "6414899fa4e47d6788678ecf"
#run_on_launch = true
vm_action = "stop"
metadata {
name = "test-vm-cont"
namespace = "default"
labels = {
"key1" = "value1"
}
}
spec {
data_volume_templates {
metadata {
name = "test-vm-bootvolume"
namespace = "default"
}
spec {
source {
blank {}
}
pvc {
access_modes = ["ReadWriteOnce"]
resources {
requests = {
storage = "5Gi"
}
}
storage_class_name = "sumit-storage-class"
volume_mode = "Block"
}
}
}
template {
metadata {
labels = {
"kubevirt.io/vm" = "test-vm-cont"
}
}
spec {
volume {
name = "test-vm-containerdisk1"
volume_source {
container_disk {
image_url = "gcr.io/spectro-images-public/release/vm-dashboard/os/fedora-container-disk:37"
}
}
}
volume {
name = "test-vm-volumedisk1"
volume_source {
data_volume {
name = "test-vm-bootvolume"
}
}
}
domain {
resources {
requests = {
memory = "8G"
cpu = 2
}
}
devices {
disk {
name = "test-vm-containerdisk1"
disk_device {
disk {
bus = "virtio"
}
}
}
disk {
name = "test-vm-volumedisk1"
disk_device {
disk {
bus = "virtio"
}
}
}
interface {
name = "main"
interface_binding_method = "InterfaceMasquerade"
}
}
}
network {
name = "main"
network_source {
pod {}
}
}
/* affinity {
pod_anti_affinity {
preferred_during_scheduling_ignored_during_execution {
weight = 100
pod_affinity_term {
label_selector {
match_labels = {
anti-affinity-key = "anti-affinity-val"
}
}
topology_key = "kubernetes.io/hostname"
}
}
}
}*/
}
}
}
}


/*resource "spectrocloud_virtual_machine" "tf-test-vm-clone-default" {
cluster_uid = "6414899fa4e47d6788678ecf"
run_on_launch = false
vm_action = "stop"
base_vm_name = spectrocloud_virtual_machine.virtual_machine_cont.metadata.0.name
metadata {
name = "tf-test-vm-clone-default"
namespace = "default"
labels = {
"key1" = "value1"
}
}
spec {
template {
metadata {
labels = {
"kubevirt.io/vm" = "test-vm-cont"
}
}
spec {
volume {
name = "test-vm-containerdisk1"
volume_source {
container_disk {
image_url = "quay.io/kubevirt/fedora-cloud-container-disk-demo"
}
}
}
domain {
resources {
requests = {
memory = "8G"
cpu = 2
}
}
devices {
disk {
name = "test-vm-containerdisk1"
disk_device {
disk {
bus = "virtio"
}
}
}
interface {
name = "main"
interface_binding_method = "InterfaceMasquerade"
}
}
}
network {
name = "main"
network_source {
pod {}
}
}
}
}
}
}*/
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ resource "spectrocloud_virtual_machine" "virtual_machine" {
}

// Creating VM by cloning existing VM
resource "spectrocloud_virtual_machine" "tf-test-vm-clone-default" {
/*resource "spectrocloud_virtual_machine" "tf-test-vm-clone-default" {
cluster_uid = "6414899fa4e47d6788678ecf"
base_vm_name = spectrocloud_virtual_machine.virtual_machine.metadata.0.name
metadata {
Expand All @@ -119,6 +119,7 @@ resource "spectrocloud_virtual_machine" "tf-test-vm-clone-default" {
"key1" = "value1"
}
}
}*/
}


Expand Down
13 changes: 6 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ go 1.18

require (
github.com/go-openapi/strfmt v0.21.5
github.com/google/go-cmp v0.5.9
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
github.com/hashicorp/terraform-plugin-docs v0.13.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.26.1
github.com/robfig/cron v1.2.0
github.com/spectrocloud/hapi v1.14.1-0.20230317084133-6a290ae86693
github.com/spectrocloud/palette-sdk-go v0.0.0-20230327174315-0bcf2ac616f4
github.com/stretchr/testify v1.8.2
github.com/spectrocloud/hapi v1.14.1-0.20230315115513-301628ae2f5e
github.com/spectrocloud/palette-sdk-go v0.0.0-20230404004301-0e4bcff8f3e7
github.com/stretchr/testify v1.8.0
gotest.tools v2.2.0+incompatible
k8s.io/api v0.26.3
k8s.io/apimachinery v0.26.3
k8s.io/api v0.23.5
k8s.io/apimachinery v0.23.5
kubevirt.io/api v0.59.0
kubevirt.io/containerized-data-importer-api v1.56.0

)

require (
Expand Down Expand Up @@ -45,7 +45,6 @@ require (
github.com/go-openapi/validate v0.20.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
Expand Down
18 changes: 7 additions & 11 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -715,10 +715,10 @@ github.com/soheilhy/cmux v0.1.5/go.mod h1:T7TcVDs9LWfQgPlPsdngu6I6QIoyIFZDDC6sNE
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/spectrocloud/gomi v1.14.1-0.20230227082335-00ec30f78888 h1:W4Doe7rx70Gi9gAgb+Lru/IwdX5rGpN3f+wnm9bS2zo=
github.com/spectrocloud/gomi v1.14.1-0.20230227082335-00ec30f78888/go.mod h1:UnhUDpFEvtYh6m384r3xzj8/+Z6/hMp2O8whEMYVHec=
github.com/spectrocloud/hapi v1.14.1-0.20230317084133-6a290ae86693 h1:mpTHGyP3avpysbiRdVoqo3jjHxMzj0r0aOP3X8hVpeY=
github.com/spectrocloud/hapi v1.14.1-0.20230317084133-6a290ae86693/go.mod h1:2eQvv8EJZnMfIFC67ONLsOaEFHsoUcRCYoU/+gV1h2M=
github.com/spectrocloud/palette-sdk-go v0.0.0-20230327174315-0bcf2ac616f4 h1:N1x5Ln1wb6EB3Kliz4/qnOmvfBtZl6l3Jgtz8t5Xk2k=
github.com/spectrocloud/palette-sdk-go v0.0.0-20230327174315-0bcf2ac616f4/go.mod h1:8zLdz1aTZpfDOxxZGqT6ng+jZiKtV3iqiy1b6cD97Pg=
github.com/spectrocloud/hapi v1.14.1-0.20230315115513-301628ae2f5e h1:xPfQZPpsZIPI/5WYySmW3TALBZwC46DhcqYE/W4apGo=
github.com/spectrocloud/hapi v1.14.1-0.20230315115513-301628ae2f5e/go.mod h1:2eQvv8EJZnMfIFC67ONLsOaEFHsoUcRCYoU/+gV1h2M=
github.com/spectrocloud/palette-sdk-go v0.0.0-20230404004301-0e4bcff8f3e7 h1:GRGOUXoOoODWUMLSDVFKoHQu4HYGmbQBepRgT+UwNdQ=
github.com/spectrocloud/palette-sdk-go v0.0.0-20230404004301-0e4bcff8f3e7/go.mod h1:8zLdz1aTZpfDOxxZGqT6ng+jZiKtV3iqiy1b6cD97Pg=
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I=
Expand All @@ -741,7 +741,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
Expand All @@ -750,9 +749,8 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
Expand Down Expand Up @@ -1331,16 +1329,14 @@ honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
k8s.io/api v0.23.0/go.mod h1:8wmDdLBHBNxtOIytwLstXt5E9PddnZb0GaMcqsvDBpg=
k8s.io/api v0.23.3/go.mod h1:w258XdGyvCmnBj/vGzQMj6kzdufJZVUwEM1U2fRJwSQ=
k8s.io/api v0.23.5 h1:zno3LUiMubxD/V1Zw3ijyKO3wxrhbUF1Ck+VjBvfaoA=
k8s.io/api v0.23.5/go.mod h1:Na4XuKng8PXJ2JsploYYrivXrINeTaycCGcYgF91Xm8=
k8s.io/api v0.26.3 h1:emf74GIQMTik01Aum9dPP0gAypL8JTLl/lHa4V9RFSU=
k8s.io/api v0.26.3/go.mod h1:PXsqwPMXBSBcL1lJ9CYDKy7kIReUydukS5JiRlxC3qE=
k8s.io/apiextensions-apiserver v0.23.5 h1:5SKzdXyvIJKu+zbfPc3kCbWpbxi+O+zdmAJBm26UJqI=
k8s.io/apiextensions-apiserver v0.23.5/go.mod h1:ntcPWNXS8ZPKN+zTXuzYMeg731CP0heCTl6gYBxLcuQ=
k8s.io/apimachinery v0.23.0/go.mod h1:fFCTTBKvKcwTPFzjlcxp91uPFZr+JA0FubU4fLzzFYc=
k8s.io/apimachinery v0.23.3/go.mod h1:BEuFMMBaIbcOqVIJqNZJXGFTP4W6AycEpb5+m/97hrM=
k8s.io/apimachinery v0.23.5 h1:Va7dwhp8wgkUPWsEXk6XglXWU4IKYLKNlv8VkX7SDM0=
k8s.io/apimachinery v0.23.5/go.mod h1:BEuFMMBaIbcOqVIJqNZJXGFTP4W6AycEpb5+m/97hrM=
k8s.io/apimachinery v0.26.3 h1:dQx6PNETJ7nODU3XPtrwkfuubs6w7sX0M8n61zHIV/k=
k8s.io/apimachinery v0.26.3/go.mod h1:ats7nN1LExKHvJ9TmwootT00Yz05MuYqPXEXaVeOy5I=
k8s.io/apiserver v0.23.5/go.mod h1:7wvMtGJ42VRxzgVI7jkbKvMbuCbVbgsWFT7RyXiRNTw=
k8s.io/client-go v0.23.5/go.mod h1:flkeinTO1CirYgzMPRWxUCnV0G4Fbu2vLhYCObnt/r4=
k8s.io/code-generator v0.23.0/go.mod h1:vQvOhDXhuzqiVfM/YHp+dmg10WDZCchJVObc9MvowsE=
Expand Down
103 changes: 0 additions & 103 deletions pkg/cluster_profile_test/cluster_profile_create_test.go

This file was deleted.

Loading

0 comments on commit cb91435

Please sign in to comment.