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
8f2f4dda
Commit
8f2f4dda
authored
Oct 26, 2016
by
Anirudh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Review comments.
parent
b751e0da
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
8 deletions
+50
-8
resize_nodes.go
test/e2e/resize_nodes.go
+50
-8
No files found.
test/e2e/resize_nodes.go
View file @
8f2f4dda
...
@@ -18,6 +18,8 @@ package e2e
...
@@ -18,6 +18,8 @@ package e2e
import
(
import
(
"fmt"
"fmt"
"net"
"net/url"
"os/exec"
"os/exec"
"regexp"
"regexp"
"strings"
"strings"
...
@@ -51,8 +53,17 @@ const (
...
@@ -51,8 +53,17 @@ const (
podNotReadyTimeout
=
1
*
time
.
Minute
podNotReadyTimeout
=
1
*
time
.
Minute
podReadyTimeout
=
2
*
time
.
Minute
podReadyTimeout
=
2
*
time
.
Minute
testPort
=
9376
testPort
=
9376
// TODO(justinsb): Avoid hardcoding this.
awsMasterIP
=
"172.20.0.9"
)
)
type
Address
struct
{
internalIP
string
externalIP
string
hostname
string
}
func
ResizeGroup
(
group
string
,
size
int32
)
error
{
func
ResizeGroup
(
group
string
,
size
int32
)
error
{
if
framework
.
TestContext
.
ReportDir
!=
""
{
if
framework
.
TestContext
.
ReportDir
!=
""
{
framework
.
CoreDump
(
framework
.
TestContext
.
ReportDir
)
framework
.
CoreDump
(
framework
.
TestContext
.
ReportDir
)
...
@@ -259,18 +270,49 @@ func resizeRC(c clientset.Interface, ns, name string, replicas int32) error {
...
@@ -259,18 +270,49 @@ func resizeRC(c clientset.Interface, ns, name string, replicas int32) error {
return
err
return
err
}
}
func
getMaster
(
c
clientset
.
Interface
)
string
{
// getMaster populates the externalIP, internalIP and hostname fields of the master.
master
:=
""
// If any of these is unavailable, it is set to "".
func
getMaster
(
c
clientset
.
Interface
)
Address
{
master
:=
Address
{}
// Populate the internal IP.
eps
,
err
:=
c
.
Core
()
.
Endpoints
(
api
.
NamespaceDefault
)
.
Get
(
"kubernetes"
)
if
err
!=
nil
{
framework
.
Failf
(
"Failed to get kubernetes endpoints: %v"
,
err
)
}
if
len
(
eps
.
Subsets
)
!=
1
||
len
(
eps
.
Subsets
[
0
]
.
Addresses
)
!=
1
{
framework
.
Failf
(
"There are more than 1 endpoints for kubernetes service: %+v"
,
eps
)
}
master
.
internalIP
=
eps
.
Subsets
[
0
]
.
Addresses
[
0
]
.
IP
// Populate the external IP/hostname.
url
,
err
:=
url
.
Parse
(
framework
.
TestContext
.
Host
)
if
err
!=
nil
{
framework
.
Failf
(
"Failed to parse hostname: %v"
,
err
)
}
if
net
.
ParseIP
(
url
.
Host
)
!=
nil
{
// TODO: Check that it is external IP (not having a reserved IP address as per RFC1918).
master
.
externalIP
=
url
.
Host
}
else
{
master
.
hostname
=
url
.
Host
}
return
master
}
// getMasterAddress returns the hostname/external IP/internal IP as appropriate for e2e tests on a particular provider
// which is the address of the interface used for communication with the kubelet.
func
getMasterAddress
(
c
clientset
.
Interface
)
string
{
master
:=
getMaster
(
c
)
switch
framework
.
TestContext
.
Provider
{
switch
framework
.
TestContext
.
Provider
{
case
"gce"
,
"gke"
:
case
"gce"
,
"gke"
:
master
=
strings
.
TrimPrefix
(
framework
.
TestContext
.
Host
,
"https://"
)
return
master
.
externalIP
case
"aws"
:
case
"aws"
:
// TODO(justinsb): Avoid hardcoding this.
return
awsMasterIP
master
=
"172.20.0.9"
default
:
default
:
framework
.
Failf
(
"This test is not supported for provider %s and should be disabled"
,
framework
.
TestContext
.
Provider
)
framework
.
Failf
(
"This test is not supported for provider %s and should be disabled"
,
framework
.
TestContext
.
Provider
)
}
}
return
master
return
""
}
}
// Return node external IP concatenated with port 22 for ssh
// Return node external IP concatenated with port 22 for ssh
...
@@ -299,7 +341,7 @@ func getNodeExternalIP(node *api.Node) string {
...
@@ -299,7 +341,7 @@ func getNodeExternalIP(node *api.Node) string {
// environments.
// environments.
func
performTemporaryNetworkFailure
(
c
clientset
.
Interface
,
ns
,
rcName
string
,
replicas
int32
,
podNameToDisappear
string
,
node
*
api
.
Node
)
{
func
performTemporaryNetworkFailure
(
c
clientset
.
Interface
,
ns
,
rcName
string
,
replicas
int32
,
podNameToDisappear
string
,
node
*
api
.
Node
)
{
host
:=
getNodeExternalIP
(
node
)
host
:=
getNodeExternalIP
(
node
)
master
:=
getMaster
(
c
)
master
:=
getMaster
Address
(
c
)
By
(
fmt
.
Sprintf
(
"block network traffic from node %s to the master"
,
node
.
Name
))
By
(
fmt
.
Sprintf
(
"block network traffic from node %s to the master"
,
node
.
Name
))
defer
func
()
{
defer
func
()
{
// This code will execute even if setting the iptables rule failed.
// This code will execute even if setting the iptables rule failed.
...
@@ -605,7 +647,7 @@ var _ = framework.KubeDescribe("Nodes [Disruptive]", func() {
...
@@ -605,7 +647,7 @@ var _ = framework.KubeDescribe("Nodes [Disruptive]", func() {
By
(
fmt
.
Sprintf
(
"Block traffic from node %s to the master"
,
node
.
Name
))
By
(
fmt
.
Sprintf
(
"Block traffic from node %s to the master"
,
node
.
Name
))
host
:=
getNodeExternalIP
(
&
node
)
host
:=
getNodeExternalIP
(
&
node
)
master
:=
getMaster
(
c
)
master
:=
getMaster
Address
(
c
)
defer
func
()
{
defer
func
()
{
By
(
fmt
.
Sprintf
(
"Unblock traffic from node %s to the master"
,
node
.
Name
))
By
(
fmt
.
Sprintf
(
"Unblock traffic from node %s to the master"
,
node
.
Name
))
framework
.
UnblockNetwork
(
host
,
master
)
framework
.
UnblockNetwork
(
host
,
master
)
...
...
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