Skip to content

Commit 60592c7

Browse files
committed
unit test fix
Signed-off-by: Sivaanand Murugesan <[email protected]>
1 parent 99c1e06 commit 60592c7

File tree

1 file changed

+45
-14
lines changed

1 file changed

+45
-14
lines changed

spectrocloud/cluster_common_test.go

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@ package spectrocloud
22

33
import (
44
"fmt"
5+
"reflect"
6+
"sort"
7+
"testing"
8+
"time"
9+
510
"github.com/hashicorp/go-cty/cty"
611
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
712
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
813
"github.com/spectrocloud/palette-sdk-go/client"
914
"github.com/stretchr/testify/require"
10-
"reflect"
11-
"sort"
12-
"testing"
13-
"time"
1415

1516
"github.com/spectrocloud/palette-sdk-go/api/models"
1617
"github.com/stretchr/testify/assert"
@@ -1039,6 +1040,10 @@ func TestFlattenClusterNamespaces(t *testing.T) {
10391040
ResourceAllocation: &models.V1ClusterNamespaceResourceAllocation{
10401041
CPUCores: 2,
10411042
MemoryMiB: 1024,
1043+
GpuConfig: &models.V1GpuConfig{
1044+
Limit: 1,
1045+
Provider: StringPtr("nvidia"),
1046+
},
10421047
},
10431048
},
10441049
},
@@ -1050,6 +1055,10 @@ func TestFlattenClusterNamespaces(t *testing.T) {
10501055
ResourceAllocation: &models.V1ClusterNamespaceResourceAllocation{
10511056
CPUCores: 4,
10521057
MemoryMiB: 2048,
1058+
GpuConfig: &models.V1GpuConfig{
1059+
Limit: 2,
1060+
Provider: StringPtr("amd"),
1061+
},
10531062
},
10541063
},
10551064
},
@@ -1059,15 +1068,19 @@ func TestFlattenClusterNamespaces(t *testing.T) {
10591068
map[string]interface{}{
10601069
"name": "namespace1",
10611070
"resource_allocation": map[string]interface{}{
1062-
"cpu_cores": "2",
1063-
"memory_MiB": "1024",
1071+
"cpu_cores": "2",
1072+
"memory_MiB": "1024",
1073+
"gpu_limit": "1",
1074+
"gpu_provider": "nvidia",
10641075
},
10651076
},
10661077
map[string]interface{}{
10671078
"name": "namespace2",
10681079
"resource_allocation": map[string]interface{}{
1069-
"cpu_cores": "4",
1070-
"memory_MiB": "2048",
1080+
"cpu_cores": "4",
1081+
"memory_MiB": "2048",
1082+
"gpu_limit": "2",
1083+
"gpu_provider": "amd",
10711084
},
10721085
},
10731086
}
@@ -1081,8 +1094,10 @@ func TestToClusterNamespace(t *testing.T) {
10811094
clusterRbacBinding := map[string]interface{}{
10821095
"name": "namespace1",
10831096
"resource_allocation": map[string]interface{}{
1084-
"cpu_cores": "2",
1085-
"memory_MiB": "1024",
1097+
"cpu_cores": "2",
1098+
"memory_MiB": "1024",
1099+
"gpu_limit": "1",
1100+
"gpu_provider": "nvidia",
10861101
},
10871102
}
10881103

@@ -1095,6 +1110,10 @@ func TestToClusterNamespace(t *testing.T) {
10951110
ResourceAllocation: &models.V1ClusterNamespaceResourceAllocation{
10961111
CPUCores: 2,
10971112
MemoryMiB: 1024,
1113+
GpuConfig: &models.V1GpuConfig{
1114+
Limit: 1,
1115+
Provider: StringPtr("nvidia"),
1116+
},
10981117
},
10991118
},
11001119
}
@@ -1110,15 +1129,19 @@ func TestToClusterNamespaces(t *testing.T) {
11101129
ns = append(ns, map[string]interface{}{
11111130
"name": "namespace1",
11121131
"resource_allocation": map[string]interface{}{
1113-
"cpu_cores": "2",
1114-
"memory_MiB": "1024",
1132+
"cpu_cores": "2",
1133+
"memory_MiB": "1024",
1134+
"gpu_limit": "1",
1135+
"gpu_provider": "nvidia",
11151136
},
11161137
})
11171138
ns = append(ns, map[string]interface{}{
11181139
"name": "namespace2",
11191140
"resource_allocation": map[string]interface{}{
1120-
"cpu_cores": "4",
1121-
"memory_MiB": "2048",
1141+
"cpu_cores": "4",
1142+
"memory_MiB": "2048",
1143+
"gpu_limit": "2",
1144+
"gpu_provider": "amd",
11221145
},
11231146
})
11241147
_ = resourceData.Set("namespaces", ns)
@@ -1132,6 +1155,10 @@ func TestToClusterNamespaces(t *testing.T) {
11321155
ResourceAllocation: &models.V1ClusterNamespaceResourceAllocation{
11331156
CPUCores: 2,
11341157
MemoryMiB: 1024,
1158+
GpuConfig: &models.V1GpuConfig{
1159+
Limit: 1,
1160+
Provider: StringPtr("nvidia"),
1161+
},
11351162
},
11361163
},
11371164
},
@@ -1144,6 +1171,10 @@ func TestToClusterNamespaces(t *testing.T) {
11441171
ResourceAllocation: &models.V1ClusterNamespaceResourceAllocation{
11451172
CPUCores: 4,
11461173
MemoryMiB: 2048,
1174+
GpuConfig: &models.V1GpuConfig{
1175+
Limit: 2,
1176+
Provider: StringPtr("amd"),
1177+
},
11471178
},
11481179
},
11491180
},

0 commit comments

Comments
 (0)