Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions openstack/cce/v3/nodes/results.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ type Spec struct {
UserTags []tags.ResourceTag `json:"userTags,omitempty"`
// Tag of a Kubernetes node, key value pair format
K8sTags map[string]string `json:"k8sTags,omitempty"`
// The runtime spec
RunTime *RunTimeSpec `json:"runtime,omitempty"`
// taints to created nodes to configure anti-affinity
Taints []TaintSpec `json:"taints,omitempty"`
}
Expand Down Expand Up @@ -158,6 +160,11 @@ type EipSpec struct {
Bandwidth BandwidthOpts `json:"bandwidth,omitempty"`
}

type RunTimeSpec struct {
// the name of runtime: docker or containerd
Name string `json:"name,omitempty"`
}

type BandwidthOpts struct {
ChargeMode string `json:"chargemode,omitempty"`
Size int `json:"size,omitempty"`
Expand Down
18 changes: 11 additions & 7 deletions openstack/cce/v3/nodes/testing/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,21 @@ const Output = `{
"volumetype": "SATA",
"size": 40
},
"publicIP": {
"eip": {
"bandwidth": {}
}
},
"dataVolumes": [
{
"volumetype": "SATA",
"size": 100
}
]
}
],
"publicIP": {
"eip": {
"bandwidth": {}
}
},
"runtime": {
"name": "docker"
}
}
}`

var Expected = &nodes.Nodes{
Expand All @@ -53,6 +56,7 @@ var Expected = &nodes.Nodes{
Size: 100,
},
},
RunTime: &nodes.RunTimeSpec{Name: "docker"},
},
}

Expand Down
51 changes: 31 additions & 20 deletions openstack/cce/v3/nodes/testing/requests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,12 @@ func TestListNode(t *testing.T) {
{
Kind: "Host",
Apiversion: "v3",
Metadata: nodes.Metadata{Name: "test-node-1234",
Id: "b99acd73-5d7c-11e8-8e76-0255ac101929"},
Spec: nodes.Spec{Az: "cn-east-2a",
Metadata: nodes.Metadata{
Name: "test-node-1234",
Id: "b99acd73-5d7c-11e8-8e76-0255ac101929",
},
Spec: nodes.Spec{
Az: "cn-east-2a",
Login: nodes.LoginSpec{SshKey: "test-keypair"},
RootVolume: nodes.VolumeSpec{Size: 40, VolumeType: "SATA"},
BillingMode: 0,
Expand All @@ -92,7 +95,11 @@ func TestListNode(t *testing.T) {
}},
Flavor: "s1.medium",
},
Status: nodes.Status{Phase: "Active", ServerID: "41748e56-33d4-46a1-aa57-2c8c29907995", PrivateIP: "192.168.0.3"},
Status: nodes.Status{
Phase: "Active",
ServerID: "41748e56-33d4-46a1-aa57-2c8c29907995",
PrivateIP: "192.168.0.3",
},
},
}

Expand Down Expand Up @@ -129,7 +136,7 @@ func TestCreateV3Node(t *testing.T) {
th.TestHeader(t, r, "Accept", "application/json")

th.TestJSONRequest(t, r, `
{
{
"apiversion": "v3",
"kind": "Node",
"metadata": {
Expand All @@ -138,32 +145,32 @@ func TestCreateV3Node(t *testing.T) {
"spec": {
"az": "cn-east-2a",
"count": 1,
"dataVolumes": [
{
"size": 100,
"volumetype": "SATA"
}
],
"flavor": "s3.large.2",
"login": {
"sshKey": "test-keypair",
"userPassword": {
"password": "",
"username": ""
}
},
},
"rootVolume": {
"size": 40,
"volumetype": "SATA"
},
"dataVolumes": [
{
"size": 100,
"volumetype": "SATA"
}
],
"nodeNicSpec": {
"primaryNic": {}
},
"publicIP": {
"eip": {
"bandwidth": {}
}
},
"rootVolume": {
"size": 40,
"volumetype": "SATA"
}
}
}
}
`)
Expand All @@ -172,14 +179,18 @@ func TestCreateV3Node(t *testing.T) {
w.WriteHeader(http.StatusCreated)
fmt.Fprintf(w, Output)
})
options := nodes.CreateOpts{Kind: "Node",
options := nodes.CreateOpts{
Kind: "Node",
ApiVersion: "v3",
Metadata: nodes.CreateMetaData{Name: "test-node"},
Spec: nodes.Spec{Flavor: "s3.large.2", Az: "cn-east-2a",
Spec: nodes.Spec{
Flavor: "s3.large.2",
Az: "cn-east-2a",
Login: nodes.LoginSpec{SshKey: "test-keypair"},
RootVolume: nodes.VolumeSpec{Size: 40, VolumeType: "SATA"},
DataVolumes: []nodes.VolumeSpec{{Size: 100, VolumeType: "SATA"}},
Count: 1},
Count: 1,
},
}
actual, err := nodes.Create(fake.ServiceClient(), "cec124c2-58f1-11e8-ad73-0255ac101926", options).Extract()
th.AssertNoErr(t, err)
Expand Down