This repository has been archived by the owner on Aug 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
/
fixtures.go
96 lines (90 loc) · 2.45 KB
/
fixtures.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package testing
import (
"fmt"
"net/http"
"testing"
"github.com/huaweicloud/golangsdk"
"github.com/huaweicloud/golangsdk/openstack/mrs/v2/clusters"
th "github.com/huaweicloud/golangsdk/testhelper"
"github.com/huaweicloud/golangsdk/testhelper/client"
)
const (
expectedCreateResponse = `
{
"cluster_id": "4cb9f483-4464-4b04-b664-b79bf904f441"
}`
)
var (
createOpts = &clusters.CreateOpts{
ClusterName: "terraform_test",
AvailabilityZone: "cn-north-4a",
ClusterType: "ANALYSIS",
ClusterVersion: "MRS 1.9.2",
Components: "Tez,Hive,Hadoop",
EnterpriseProjectId: "e9ee3f48-f097-406a-aa74-cfece0af3e31",
LogCollection: golangsdk.IntToPointer(1),
LoginMode: "PASSWORD",
ManagerAdminPassword: "Terraform!123",
NodeRootPassword: "Terraform!123",
Region: "cn-north-4",
SafeMode: "KERBEROS",
SubnetId: "ea6a5175-2ff1-4f72-b5b5-1fe82cea8c19",
VpcName: "terraform_test",
NodeGroups: []clusters.NodeGroupOpts{
{
GroupName: "master_node_default_group",
NodeSize: "c6.2xlarge.4.linux.bigdata",
NodeNum: 2,
DataVolumeCount: golangsdk.IntToPointer(1),
RootVolume: &clusters.Volume{
Size: 600,
Type: "SAS",
},
DataVolume: &clusters.Volume{
Size: 600,
Type: "SAS",
},
},
{
GroupName: "core_node_analysis_group",
NodeSize: "c6.2xlarge.4.linux.bigdata",
NodeNum: 2,
DataVolumeCount: golangsdk.IntToPointer(1),
RootVolume: &clusters.Volume{
Size: 600,
Type: "SAS",
},
DataVolume: &clusters.Volume{
Size: 600,
Type: "SAS",
},
},
{
GroupName: "task_node_analysis_group",
NodeSize: "c6.2xlarge.4.linux.bigdata",
NodeNum: 1,
DataVolumeCount: golangsdk.IntToPointer(1),
RootVolume: &clusters.Volume{
Size: 600,
Type: "SAS",
},
DataVolume: &clusters.Volume{
Size: 600,
Type: "SAS",
},
},
},
}
expectedCreateResponseData = &clusters.Cluster{
ID: "4cb9f483-4464-4b04-b664-b79bf904f441",
}
)
func handleV2ClusterCreate(t *testing.T) {
th.Mux.HandleFunc("/clusters", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "POST")
th.TestHeader(t, r, "X-Auth-Token", client.TokenID)
w.Header().Add("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
_, _ = fmt.Fprint(w, expectedCreateResponse)
})
}