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
82f9d936
Commit
82f9d936
authored
May 29, 2018
by
Cheng Xing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modified regional PD test to fetch template name from GCE
parent
65a81933
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
3 deletions
+51
-3
google_compute.go
test/e2e/framework/google_compute.go
+48
-0
regional_pd.go
test/e2e/storage/regional_pd.go
+3
-3
No files found.
test/e2e/framework/google_compute.go
View file @
82f9d936
...
...
@@ -145,6 +145,28 @@ func CreateManagedInstanceGroup(size int64, zone, template string) error {
return
nil
}
func
GetManagedInstanceGroupTemplateName
(
zone
string
)
(
string
,
error
)
{
// TODO(verult): make this hit the compute API directly instead of
// shelling out to gcloud. Use InstanceGroupManager to get Instance Template name.
stdout
,
_
,
err
:=
retryCmd
(
"gcloud"
,
"compute"
,
"instance-groups"
,
"managed"
,
"list"
,
fmt
.
Sprintf
(
"--filter=name:%s"
,
TestContext
.
CloudConfig
.
NodeInstanceGroup
),
fmt
.
Sprintf
(
"--project=%s"
,
TestContext
.
CloudConfig
.
ProjectID
),
fmt
.
Sprintf
(
"--zones=%s"
,
zone
),
)
if
err
!=
nil
{
return
""
,
fmt
.
Errorf
(
"gcloud compute instance-groups managed list call failed with err: %v"
,
err
)
}
templateName
,
err
:=
parseInstanceTemplateName
(
stdout
)
if
err
!=
nil
{
return
""
,
fmt
.
Errorf
(
"error parsing gcloud output: %v"
,
err
)
}
return
templateName
,
nil
}
func
DeleteManagedInstanceGroup
(
zone
string
)
error
{
// TODO(verult): make this hit the compute API directly instead of
// shelling out to gcloud.
...
...
@@ -158,3 +180,29 @@ func DeleteManagedInstanceGroup(zone string) error {
}
return
nil
}
func
parseInstanceTemplateName
(
gcloudOutput
string
)
(
string
,
error
)
{
const
templateNameField
=
"INSTANCE_TEMPLATE"
lines
:=
strings
.
Split
(
gcloudOutput
,
"
\n
"
)
if
len
(
lines
)
<=
1
{
// Empty output or only contains column names
return
""
,
fmt
.
Errorf
(
"the list is empty"
)
}
// Otherwise, there should be exactly 1 entry, i.e. 2 lines
fieldNames
:=
strings
.
Fields
(
lines
[
0
])
instanceTemplateColumn
:=
0
for
instanceTemplateColumn
<
len
(
fieldNames
)
&&
fieldNames
[
instanceTemplateColumn
]
!=
templateNameField
{
instanceTemplateColumn
++
}
if
instanceTemplateColumn
==
len
(
fieldNames
)
{
return
""
,
fmt
.
Errorf
(
"the list does not contain instance template information"
)
}
fields
:=
strings
.
Fields
(
lines
[
1
])
instanceTemplateName
:=
fields
[
instanceTemplateColumn
]
return
instanceTemplateName
,
nil
}
test/e2e/storage/regional_pd.go
View file @
82f9d936
...
...
@@ -205,6 +205,9 @@ func testZonalFailover(c clientset.Interface, ns string) {
instanceGroup
,
err
:=
cloud
.
GetInstanceGroup
(
instanceGroupName
,
podZone
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
(),
"Error getting instance group %s in zone %s"
,
instanceGroupName
,
podZone
)
templateName
,
err
:=
framework
.
GetManagedInstanceGroupTemplateName
(
podZone
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
(),
"Error getting instance group template in zone %s"
,
podZone
)
err
=
framework
.
DeleteManagedInstanceGroup
(
podZone
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
(),
"Error deleting instance group in zone %s"
,
podZone
)
...
...
@@ -212,9 +215,6 @@ func testZonalFailover(c clientset.Interface, ns string) {
defer
func
()
{
framework
.
Logf
(
"recreating instance group %s"
,
instanceGroup
.
Name
)
// HACK improve this when Managed Instance Groups are available through the cloud provider API
templateName
:=
strings
.
Replace
(
instanceGroupName
,
"group"
,
"template"
,
1
/* n */
)
framework
.
ExpectNoError
(
framework
.
CreateManagedInstanceGroup
(
instanceGroup
.
Size
,
podZone
,
templateName
),
"Error recreating instance group %s in zone %s"
,
instanceGroup
.
Name
,
podZone
)
framework
.
ExpectNoError
(
framework
.
WaitForReadyNodes
(
c
,
nodeCount
,
framework
.
RestartNodeReadyAgainTimeout
),
...
...
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