Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
d33274ce
Commit
d33274ce
authored
Aug 31, 2017
by
David Zhu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated pd.go tests to use GCE API instead of GCloud Commands
parent
55cb667b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
6 deletions
+25
-6
gce_instances.go
pkg/cloudprovider/providers/gce/gce_instances.go
+18
-0
pd.go
test/e2e/storage/pd.go
+7
-6
No files found.
pkg/cloudprovider/providers/gce/gce_instances.go
View file @
d33274ce
...
@@ -294,6 +294,24 @@ func (gce *GCECloud) GetAllZones() (sets.String, error) {
...
@@ -294,6 +294,24 @@ func (gce *GCECloud) GetAllZones() (sets.String, error) {
return
zones
,
nil
return
zones
,
nil
}
}
// ListInstanceNames returns a string of instance names seperated by spaces.
func
(
gce
*
GCECloud
)
ListInstanceNames
(
project
,
zone
string
)
(
string
,
error
)
{
res
,
err
:=
gce
.
service
.
Instances
.
List
(
project
,
zone
)
.
Fields
(
"items(name)"
)
.
Do
()
if
err
!=
nil
{
return
""
,
err
}
var
output
string
for
_
,
item
:=
range
res
.
Items
{
output
+=
item
.
Name
+
" "
}
return
output
,
nil
}
// DeleteInstance deletes an instance specified by project, zone, and name
func
(
gce
*
GCECloud
)
DeleteInstance
(
project
,
zone
,
name
string
)
(
*
compute
.
Operation
,
error
)
{
return
gce
.
service
.
Instances
.
Delete
(
project
,
zone
,
name
)
.
Do
()
}
// Implementation of Instances.CurrentNodeName
// Implementation of Instances.CurrentNodeName
func
(
gce
*
GCECloud
)
CurrentNodeName
(
hostname
string
)
(
types
.
NodeName
,
error
)
{
func
(
gce
*
GCECloud
)
CurrentNodeName
(
hostname
string
)
(
types
.
NodeName
,
error
)
{
return
types
.
NodeName
(
hostname
),
nil
return
types
.
NodeName
(
hostname
),
nil
...
...
test/e2e/storage/pd.go
View file @
d33274ce
...
@@ -19,7 +19,6 @@ package storage
...
@@ -19,7 +19,6 @@ package storage
import
(
import
(
"fmt"
"fmt"
mathrand
"math/rand"
mathrand
"math/rand"
"os/exec"
"strings"
"strings"
"time"
"time"
...
@@ -449,16 +448,18 @@ var _ = SIGDescribe("Pod Disks", func() {
...
@@ -449,16 +448,18 @@ var _ = SIGDescribe("Pod Disks", func() {
// Verify that disk shows up in node 0's volumeInUse list
// Verify that disk shows up in node 0's volumeInUse list
framework
.
ExpectNoError
(
waitForPDInVolumesInUse
(
nodeClient
,
diskName
,
host0Name
,
nodeStatusTimeout
,
true
/* should exist*/
))
framework
.
ExpectNoError
(
waitForPDInVolumesInUse
(
nodeClient
,
diskName
,
host0Name
,
nodeStatusTimeout
,
true
/* should exist*/
))
output
,
err
:=
exec
.
Command
(
"gcloud"
,
"compute"
,
"instances"
,
"list"
,
"--project="
+
framework
.
TestContext
.
CloudConfig
.
ProjectID
)
.
CombinedOutput
()
gceCloud
,
err
:=
framework
.
GetGCECloud
()
framework
.
ExpectNoError
(
err
,
fmt
.
Sprintf
(
"Unable to create gcloud client err=%v"
,
err
))
output
,
err
:=
gceCloud
.
ListInstanceNames
(
framework
.
TestContext
.
CloudConfig
.
ProjectID
,
framework
.
TestContext
.
CloudConfig
.
Zone
)
framework
.
ExpectNoError
(
err
,
fmt
.
Sprintf
(
"Unable to get list of node instances err=%v output=%s"
,
err
,
output
))
framework
.
ExpectNoError
(
err
,
fmt
.
Sprintf
(
"Unable to get list of node instances err=%v output=%s"
,
err
,
output
))
Expect
(
true
,
strings
.
Contains
(
string
(
output
),
string
(
host0Name
)))
Expect
(
true
,
strings
.
Contains
(
string
(
output
),
string
(
host0Name
)))
By
(
"deleting host0"
)
By
(
"deleting host0"
)
resp
,
err
:=
gceCloud
.
DeleteInstance
(
framework
.
TestContext
.
CloudConfig
.
ProjectID
,
framework
.
TestContext
.
CloudConfig
.
Zone
,
string
(
host0Name
))
framework
.
ExpectNoError
(
err
,
fmt
.
Sprintf
(
"Failed to delete host0pod: err=%v response=%#v"
,
err
,
resp
))
output
,
err
=
exec
.
Command
(
"gcloud"
,
"compute"
,
"instances"
,
"delete"
,
string
(
host0Name
),
"--project="
+
framework
.
TestContext
.
CloudConfig
.
ProjectID
,
"--zone="
+
framework
.
TestContext
.
CloudConfig
.
Zone
)
.
CombinedOutput
()
output
,
err
=
gceCloud
.
ListInstanceNames
(
framework
.
TestContext
.
CloudConfig
.
ProjectID
,
framework
.
TestContext
.
CloudConfig
.
Zone
)
framework
.
ExpectNoError
(
err
,
fmt
.
Sprintf
(
"Failed to delete host0pod: err=%v output=%s"
,
err
,
output
))
output
,
err
=
exec
.
Command
(
"gcloud"
,
"compute"
,
"instances"
,
"list"
,
"--project="
+
framework
.
TestContext
.
CloudConfig
.
ProjectID
)
.
CombinedOutput
()
framework
.
ExpectNoError
(
err
,
fmt
.
Sprintf
(
"Unable to get list of node instances err=%v output=%s"
,
err
,
output
))
framework
.
ExpectNoError
(
err
,
fmt
.
Sprintf
(
"Unable to get list of node instances err=%v output=%s"
,
err
,
output
))
Expect
(
false
,
strings
.
Contains
(
string
(
output
),
string
(
host0Name
)))
Expect
(
false
,
strings
.
Contains
(
string
(
output
),
string
(
host0Name
)))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment