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
def49db0
Commit
def49db0
authored
Nov 10, 2017
by
Beata Skiba
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support multizone clusters in GCE and GKE e2e tests
parent
7c04a684
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
8 deletions
+32
-8
size.go
test/e2e/framework/size.go
+32
-8
No files found.
test/e2e/framework/size.go
View file @
def49db0
...
@@ -41,13 +41,17 @@ func ResizeGroup(group string, size int32) error {
...
@@ -41,13 +41,17 @@ func ResizeGroup(group string, size int32) error {
if
TestContext
.
Provider
==
"gce"
||
TestContext
.
Provider
==
"gke"
{
if
TestContext
.
Provider
==
"gce"
||
TestContext
.
Provider
==
"gke"
{
// TODO: make this hit the compute API directly instead of shelling out to gcloud.
// TODO: make this hit the compute API directly instead of shelling out to gcloud.
// TODO: make gce/gke implement InstanceGroups, so we can eliminate the per-provider logic
// TODO: make gce/gke implement InstanceGroups, so we can eliminate the per-provider logic
zone
,
err
:=
getGCEZoneForGroup
(
group
)
if
err
!=
nil
{
return
err
}
output
,
err
:=
exec
.
Command
(
"gcloud"
,
"compute"
,
"instance-groups"
,
"managed"
,
"resize"
,
output
,
err
:=
exec
.
Command
(
"gcloud"
,
"compute"
,
"instance-groups"
,
"managed"
,
"resize"
,
group
,
fmt
.
Sprintf
(
"--size=%v"
,
size
),
group
,
fmt
.
Sprintf
(
"--size=%v"
,
size
),
"--project="
+
TestContext
.
CloudConfig
.
ProjectID
,
"--zone="
+
TestContext
.
CloudConfig
.
Z
one
)
.
CombinedOutput
()
"--project="
+
TestContext
.
CloudConfig
.
ProjectID
,
"--zone="
+
z
one
)
.
CombinedOutput
()
if
err
!=
nil
{
if
err
!=
nil
{
Logf
(
"Failed to resize node instance group: %v"
,
string
(
output
)
)
return
fmt
.
Errorf
(
"Failed to resize node instance group %s: %s"
,
group
,
output
)
}
}
return
err
return
nil
}
else
if
TestContext
.
Provider
==
"aws"
{
}
else
if
TestContext
.
Provider
==
"aws"
{
client
:=
autoscaling
.
New
(
session
.
New
())
client
:=
autoscaling
.
New
(
session
.
New
())
return
awscloud
.
ResizeInstanceGroup
(
client
,
group
,
int
(
size
))
return
awscloud
.
ResizeInstanceGroup
(
client
,
group
,
int
(
size
))
...
@@ -62,12 +66,15 @@ func GetGroupNodes(group string) ([]string, error) {
...
@@ -62,12 +66,15 @@ func GetGroupNodes(group string) ([]string, error) {
if
TestContext
.
Provider
==
"gce"
||
TestContext
.
Provider
==
"gke"
{
if
TestContext
.
Provider
==
"gce"
||
TestContext
.
Provider
==
"gke"
{
// TODO: make this hit the compute API directly instead of shelling out to gcloud.
// TODO: make this hit the compute API directly instead of shelling out to gcloud.
// TODO: make gce/gke implement InstanceGroups, so we can eliminate the per-provider logic
// TODO: make gce/gke implement InstanceGroups, so we can eliminate the per-provider logic
zone
,
err
:=
getGCEZoneForGroup
(
group
)
if
err
!=
nil
{
return
nil
,
err
}
output
,
err
:=
exec
.
Command
(
"gcloud"
,
"compute"
,
"instance-groups"
,
"managed"
,
output
,
err
:=
exec
.
Command
(
"gcloud"
,
"compute"
,
"instance-groups"
,
"managed"
,
"list-instances"
,
group
,
"--project="
+
TestContext
.
CloudConfig
.
ProjectID
,
"list-instances"
,
group
,
"--project="
+
TestContext
.
CloudConfig
.
ProjectID
,
"--zone="
+
TestContext
.
CloudConfig
.
Z
one
)
.
CombinedOutput
()
"--zone="
+
z
one
)
.
CombinedOutput
()
if
err
!=
nil
{
if
err
!=
nil
{
Logf
(
"Failed to get nodes in instance group: %v"
,
string
(
output
))
return
nil
,
fmt
.
Errorf
(
"Failed to get nodes in instance group %s: %s"
,
group
,
output
)
return
nil
,
err
}
}
re
:=
regexp
.
MustCompile
(
".*RUNNING"
)
re
:=
regexp
.
MustCompile
(
".*RUNNING"
)
lines
:=
re
.
FindAllString
(
string
(
output
),
-
1
)
lines
:=
re
.
FindAllString
(
string
(
output
),
-
1
)
...
@@ -86,11 +93,15 @@ func GroupSize(group string) (int, error) {
...
@@ -86,11 +93,15 @@ func GroupSize(group string) (int, error) {
if
TestContext
.
Provider
==
"gce"
||
TestContext
.
Provider
==
"gke"
{
if
TestContext
.
Provider
==
"gce"
||
TestContext
.
Provider
==
"gke"
{
// TODO: make this hit the compute API directly instead of shelling out to gcloud.
// TODO: make this hit the compute API directly instead of shelling out to gcloud.
// TODO: make gce/gke implement InstanceGroups, so we can eliminate the per-provider logic
// TODO: make gce/gke implement InstanceGroups, so we can eliminate the per-provider logic
zone
,
err
:=
getGCEZoneForGroup
(
group
)
if
err
!=
nil
{
return
-
1
,
err
}
output
,
err
:=
exec
.
Command
(
"gcloud"
,
"compute"
,
"instance-groups"
,
"managed"
,
output
,
err
:=
exec
.
Command
(
"gcloud"
,
"compute"
,
"instance-groups"
,
"managed"
,
"list-instances"
,
group
,
"--project="
+
TestContext
.
CloudConfig
.
ProjectID
,
"list-instances"
,
group
,
"--project="
+
TestContext
.
CloudConfig
.
ProjectID
,
"--zone="
+
TestContext
.
CloudConfig
.
Z
one
)
.
CombinedOutput
()
"--zone="
+
z
one
)
.
CombinedOutput
()
if
err
!=
nil
{
if
err
!=
nil
{
return
-
1
,
err
return
-
1
,
fmt
.
Errorf
(
"Failed to get group size for group %s: %s"
,
group
,
output
)
}
}
re
:=
regexp
.
MustCompile
(
"RUNNING"
)
re
:=
regexp
.
MustCompile
(
"RUNNING"
)
return
len
(
re
.
FindAllString
(
string
(
output
),
-
1
)),
nil
return
len
(
re
.
FindAllString
(
string
(
output
),
-
1
)),
nil
...
@@ -128,3 +139,16 @@ func WaitForGroupSize(group string, size int32) error {
...
@@ -128,3 +139,16 @@ func WaitForGroupSize(group string, size int32) error {
}
}
return
fmt
.
Errorf
(
"timeout waiting %v for node instance group size to be %d"
,
timeout
,
size
)
return
fmt
.
Errorf
(
"timeout waiting %v for node instance group size to be %d"
,
timeout
,
size
)
}
}
func
getGCEZoneForGroup
(
group
string
)
(
string
,
error
)
{
zone
:=
TestContext
.
CloudConfig
.
Zone
if
TestContext
.
CloudConfig
.
MultiZone
{
output
,
err
:=
exec
.
Command
(
"gcloud"
,
"compute"
,
"instance-groups"
,
"managed"
,
"list"
,
"--project="
+
TestContext
.
CloudConfig
.
ProjectID
,
"--format=value(zone)"
,
"--filter=name="
+
group
)
.
CombinedOutput
()
if
err
!=
nil
{
return
""
,
fmt
.
Errorf
(
"Failed to get zone for node group %s: %s"
,
group
,
output
)
}
zone
=
strings
.
TrimSpace
(
string
(
output
))
}
return
zone
,
nil
}
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