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
a3bc56ff
Unverified
Commit
a3bc56ff
authored
Mar 22, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Mar 22, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #74746 from oomichi/golint-e2e-framework-gce
Fix golint failures under test/e2e/[..]/gce
parents
290cf142
da7c9f70
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
61 additions
and
44 deletions
+61
-44
.golint_failures
hack/.golint_failures
+0
-1
firewall.go
test/e2e/framework/providers/gce/firewall.go
+5
-10
gce.go
test/e2e/framework/providers/gce/gce.go
+18
-2
ingress.go
test/e2e/framework/providers/gce/ingress.go
+0
-0
firewall.go
test/e2e/network/firewall.go
+17
-10
ingress.go
test/e2e/network/ingress.go
+18
-18
ingress.go
test/e2e/network/scale/ingress.go
+3
-3
No files found.
hack/.golint_failures
View file @
a3bc56ff
...
@@ -649,7 +649,6 @@ test/e2e/autoscaling
...
@@ -649,7 +649,6 @@ test/e2e/autoscaling
test/e2e/chaosmonkey
test/e2e/chaosmonkey
test/e2e/common
test/e2e/common
test/e2e/framework
test/e2e/framework
test/e2e/framework/providers/gce
test/e2e/lifecycle
test/e2e/lifecycle
test/e2e/lifecycle/bootstrap
test/e2e/lifecycle/bootstrap
test/e2e/network
test/e2e/network
...
...
test/e2e/framework/providers/gce/firewall.go
View file @
a3bc56ff
...
@@ -33,14 +33,6 @@ import (
...
@@ -33,14 +33,6 @@ import (
"k8s.io/kubernetes/test/e2e/framework"
"k8s.io/kubernetes/test/e2e/framework"
)
)
const
(
FirewallTimeoutDefault
=
3
*
time
.
Minute
FirewallTestTcpTimeout
=
time
.
Duration
(
1
*
time
.
Second
)
// Set ports outside of 30000-32767, 80 and 8080 to avoid being whitelisted by the e2e cluster
FirewallTestHttpPort
=
int32
(
29999
)
FirewallTestUdpPort
=
int32
(
29998
)
)
// MakeFirewallNameForLBService return the expected firewall name for a LB service.
// MakeFirewallNameForLBService return the expected firewall name for a LB service.
// This should match the formatting of makeFirewallName() in pkg/cloudprovider/providers/gce/gce_loadbalancer.go
// This should match the formatting of makeFirewallName() in pkg/cloudprovider/providers/gce/gce_loadbalancer.go
func
MakeFirewallNameForLBService
(
name
string
)
string
{
func
MakeFirewallNameForLBService
(
name
string
)
string
{
...
@@ -69,6 +61,8 @@ func ConstructFirewallForLBService(svc *v1.Service, nodeTag string) *compute.Fir
...
@@ -69,6 +61,8 @@ func ConstructFirewallForLBService(svc *v1.Service, nodeTag string) *compute.Fir
return
&
fw
return
&
fw
}
}
// MakeHealthCheckFirewallNameForLBService returns the firewall name used by the GCE load
// balancers for performing health checks.
func
MakeHealthCheckFirewallNameForLBService
(
clusterID
,
name
string
,
isNodesHealthCheck
bool
)
string
{
func
MakeHealthCheckFirewallNameForLBService
(
clusterID
,
name
string
,
isNodesHealthCheck
bool
)
string
{
return
gcecloud
.
MakeHealthCheckFirewallName
(
clusterID
,
name
,
isNodesHealthCheck
)
return
gcecloud
.
MakeHealthCheckFirewallName
(
clusterID
,
name
,
isNodesHealthCheck
)
}
}
...
@@ -114,7 +108,7 @@ func GetClusterName(instancePrefix string) string {
...
@@ -114,7 +108,7 @@ func GetClusterName(instancePrefix string) string {
// GetE2eFirewalls returns all firewall rules we create for an e2e cluster.
// GetE2eFirewalls returns all firewall rules we create for an e2e cluster.
// From cluster/gce/util.sh, all firewall rules should be consistent with the ones created by startup scripts.
// From cluster/gce/util.sh, all firewall rules should be consistent with the ones created by startup scripts.
func
GetE2eFirewalls
(
masterName
,
masterTag
,
nodeTag
,
network
,
clusterI
p
Range
string
)
[]
*
compute
.
Firewall
{
func
GetE2eFirewalls
(
masterName
,
masterTag
,
nodeTag
,
network
,
clusterI
P
Range
string
)
[]
*
compute
.
Firewall
{
instancePrefix
,
err
:=
GetInstancePrefix
(
masterName
)
instancePrefix
,
err
:=
GetInstancePrefix
(
masterName
)
framework
.
ExpectNoError
(
err
)
framework
.
ExpectNoError
(
err
)
clusterName
:=
GetClusterName
(
instancePrefix
)
clusterName
:=
GetClusterName
(
instancePrefix
)
...
@@ -198,7 +192,7 @@ func GetE2eFirewalls(masterName, masterTag, nodeTag, network, clusterIpRange str
...
@@ -198,7 +192,7 @@ func GetE2eFirewalls(masterName, masterTag, nodeTag, network, clusterIpRange str
})
})
fws
=
append
(
fws
,
&
compute
.
Firewall
{
fws
=
append
(
fws
,
&
compute
.
Firewall
{
Name
:
nodeTag
+
"-all"
,
Name
:
nodeTag
+
"-all"
,
SourceRanges
:
[]
string
{
clusterI
p
Range
},
SourceRanges
:
[]
string
{
clusterI
P
Range
},
TargetTags
:
[]
string
{
nodeTag
},
TargetTags
:
[]
string
{
nodeTag
},
Allowed
:
[]
*
compute
.
FirewallAllowed
{
Allowed
:
[]
*
compute
.
FirewallAllowed
{
{
{
...
@@ -399,6 +393,7 @@ func VerifyFirewallRule(res, exp *compute.Firewall, network string, portsSubset
...
@@ -399,6 +393,7 @@ func VerifyFirewallRule(res, exp *compute.Firewall, network string, portsSubset
return
nil
return
nil
}
}
// WaitForFirewallRule waits for the specified firewall existence
func
WaitForFirewallRule
(
gceCloud
*
gcecloud
.
Cloud
,
fwName
string
,
exist
bool
,
timeout
time
.
Duration
)
(
*
compute
.
Firewall
,
error
)
{
func
WaitForFirewallRule
(
gceCloud
*
gcecloud
.
Cloud
,
fwName
string
,
exist
bool
,
timeout
time
.
Duration
)
(
*
compute
.
Firewall
,
error
)
{
framework
.
Logf
(
"Waiting up to %v for firewall %v exist=%v"
,
timeout
,
fwName
,
exist
)
framework
.
Logf
(
"Waiting up to %v for firewall %v exist=%v"
,
timeout
,
fwName
,
exist
)
var
fw
*
compute
.
Firewall
var
fw
*
compute
.
Firewall
...
...
test/e2e/framework/providers/gce/gce.go
View file @
a3bc56ff
...
@@ -89,17 +89,20 @@ func factory() (framework.ProviderInterface, error) {
...
@@ -89,17 +89,20 @@ func factory() (framework.ProviderInterface, error) {
return
NewProvider
(
gceCloud
),
nil
return
NewProvider
(
gceCloud
),
nil
}
}
// NewProvider returns a cloud provider interface for GCE
func
NewProvider
(
gceCloud
*
gcecloud
.
Cloud
)
framework
.
ProviderInterface
{
func
NewProvider
(
gceCloud
*
gcecloud
.
Cloud
)
framework
.
ProviderInterface
{
return
&
Provider
{
return
&
Provider
{
gceCloud
:
gceCloud
,
gceCloud
:
gceCloud
,
}
}
}
}
// Provider is a structure to handle GCE clouds for e2e testing
type
Provider
struct
{
type
Provider
struct
{
framework
.
NullProvider
framework
.
NullProvider
gceCloud
*
gcecloud
.
Cloud
gceCloud
*
gcecloud
.
Cloud
}
}
// ResizeGroup resizes an instance group
func
(
p
*
Provider
)
ResizeGroup
(
group
string
,
size
int32
)
error
{
func
(
p
*
Provider
)
ResizeGroup
(
group
string
,
size
int32
)
error
{
// 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
...
@@ -116,6 +119,7 @@ func (p *Provider) ResizeGroup(group string, size int32) error {
...
@@ -116,6 +119,7 @@ func (p *Provider) ResizeGroup(group string, size int32) error {
return
nil
return
nil
}
}
// GetGroupNodes returns a node name for the specified node group
func
(
p
*
Provider
)
GetGroupNodes
(
group
string
)
([]
string
,
error
)
{
func
(
p
*
Provider
)
GetGroupNodes
(
group
string
)
([]
string
,
error
)
{
// 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
...
@@ -137,6 +141,7 @@ func (p *Provider) GetGroupNodes(group string) ([]string, error) {
...
@@ -137,6 +141,7 @@ func (p *Provider) GetGroupNodes(group string) ([]string, error) {
return
lines
,
nil
return
lines
,
nil
}
}
// GroupSize returns the size of an instance group
func
(
p
*
Provider
)
GroupSize
(
group
string
)
(
int
,
error
)
{
func
(
p
*
Provider
)
GroupSize
(
group
string
)
(
int
,
error
)
{
// 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
...
@@ -154,6 +159,7 @@ func (p *Provider) GroupSize(group string) (int, error) {
...
@@ -154,6 +159,7 @@ func (p *Provider) GroupSize(group string) (int, error) {
return
len
(
re
.
FindAllString
(
string
(
output
),
-
1
)),
nil
return
len
(
re
.
FindAllString
(
string
(
output
),
-
1
)),
nil
}
}
// EnsureLoadBalancerResourcesDeleted ensures that cloud load balancer resources that were created
func
(
p
*
Provider
)
EnsureLoadBalancerResourcesDeleted
(
ip
,
portRange
string
)
error
{
func
(
p
*
Provider
)
EnsureLoadBalancerResourcesDeleted
(
ip
,
portRange
string
)
error
{
project
:=
framework
.
TestContext
.
CloudConfig
.
ProjectID
project
:=
framework
.
TestContext
.
CloudConfig
.
ProjectID
region
,
err
:=
gcecloud
.
GetGCERegion
(
framework
.
TestContext
.
CloudConfig
.
Zone
)
region
,
err
:=
gcecloud
.
GetGCERegion
(
framework
.
TestContext
.
CloudConfig
.
Zone
)
...
@@ -190,6 +196,7 @@ func getGCEZoneForGroup(group string) (string, error) {
...
@@ -190,6 +196,7 @@ func getGCEZoneForGroup(group string) (string, error) {
return
zone
,
nil
return
zone
,
nil
}
}
// DeleteNode deletes a node which is specified as the argument
func
(
p
*
Provider
)
DeleteNode
(
node
*
v1
.
Node
)
error
{
func
(
p
*
Provider
)
DeleteNode
(
node
*
v1
.
Node
)
error
{
zone
:=
framework
.
TestContext
.
CloudConfig
.
Zone
zone
:=
framework
.
TestContext
.
CloudConfig
.
Zone
project
:=
framework
.
TestContext
.
CloudConfig
.
ProjectID
project
:=
framework
.
TestContext
.
CloudConfig
.
ProjectID
...
@@ -197,6 +204,7 @@ func (p *Provider) DeleteNode(node *v1.Node) error {
...
@@ -197,6 +204,7 @@ func (p *Provider) DeleteNode(node *v1.Node) error {
return
p
.
gceCloud
.
DeleteInstance
(
project
,
zone
,
node
.
Name
)
return
p
.
gceCloud
.
DeleteInstance
(
project
,
zone
,
node
.
Name
)
}
}
// CreatePD creates a persistent volume
func
(
p
*
Provider
)
CreatePD
(
zone
string
)
(
string
,
error
)
{
func
(
p
*
Provider
)
CreatePD
(
zone
string
)
(
string
,
error
)
{
pdName
:=
fmt
.
Sprintf
(
"%s-%s"
,
framework
.
TestContext
.
Prefix
,
string
(
uuid
.
NewUUID
()))
pdName
:=
fmt
.
Sprintf
(
"%s-%s"
,
framework
.
TestContext
.
Prefix
,
string
(
uuid
.
NewUUID
()))
...
@@ -215,6 +223,7 @@ func (p *Provider) CreatePD(zone string) (string, error) {
...
@@ -215,6 +223,7 @@ func (p *Provider) CreatePD(zone string) (string, error) {
return
pdName
,
nil
return
pdName
,
nil
}
}
// DeletePD deletes a persistent volume
func
(
p
*
Provider
)
DeletePD
(
pdName
string
)
error
{
func
(
p
*
Provider
)
DeletePD
(
pdName
string
)
error
{
err
:=
p
.
gceCloud
.
DeleteDisk
(
pdName
)
err
:=
p
.
gceCloud
.
DeleteDisk
(
pdName
)
...
@@ -229,6 +238,7 @@ func (p *Provider) DeletePD(pdName string) error {
...
@@ -229,6 +238,7 @@ func (p *Provider) DeletePD(pdName string) error {
return
err
return
err
}
}
// CreatePVSource creates a persistent volume source
func
(
p
*
Provider
)
CreatePVSource
(
zone
,
diskName
string
)
(
*
v1
.
PersistentVolumeSource
,
error
)
{
func
(
p
*
Provider
)
CreatePVSource
(
zone
,
diskName
string
)
(
*
v1
.
PersistentVolumeSource
,
error
)
{
return
&
v1
.
PersistentVolumeSource
{
return
&
v1
.
PersistentVolumeSource
{
GCEPersistentDisk
:
&
v1
.
GCEPersistentDiskVolumeSource
{
GCEPersistentDisk
:
&
v1
.
GCEPersistentDiskVolumeSource
{
...
@@ -239,11 +249,12 @@ func (p *Provider) CreatePVSource(zone, diskName string) (*v1.PersistentVolumeSo
...
@@ -239,11 +249,12 @@ func (p *Provider) CreatePVSource(zone, diskName string) (*v1.PersistentVolumeSo
},
nil
},
nil
}
}
// DeletePVSource deletes a persistent volume source
func
(
p
*
Provider
)
DeletePVSource
(
pvSource
*
v1
.
PersistentVolumeSource
)
error
{
func
(
p
*
Provider
)
DeletePVSource
(
pvSource
*
v1
.
PersistentVolumeSource
)
error
{
return
framework
.
DeletePDWithRetry
(
pvSource
.
GCEPersistentDisk
.
PDName
)
return
framework
.
DeletePDWithRetry
(
pvSource
.
GCEPersistentDisk
.
PDName
)
}
}
// CleanupResources cleans up GCE Service Type=LoadBalancer resources with
// Cleanup
Service
Resources cleans up GCE Service Type=LoadBalancer resources with
// the given name. The name is usually the UUID of the Service prefixed with an
// the given name. The name is usually the UUID of the Service prefixed with an
// alpha-numeric character ('a') to work around cloudprovider rules.
// alpha-numeric character ('a') to work around cloudprovider rules.
func
(
p
*
Provider
)
CleanupServiceResources
(
c
clientset
.
Interface
,
loadBalancerName
,
region
,
zone
string
)
{
func
(
p
*
Provider
)
CleanupServiceResources
(
c
clientset
.
Interface
,
loadBalancerName
,
region
,
zone
string
)
{
...
@@ -301,10 +312,13 @@ func (p *Provider) cleanupGCEResources(c clientset.Interface, loadBalancerName,
...
@@ -301,10 +312,13 @@ func (p *Provider) cleanupGCEResources(c clientset.Interface, loadBalancerName,
return
return
}
}
// LoadBalancerSrcRanges contains the ranges of ips used by the GCE load balancers (l4 & L7)
// for proxying client requests and performing health checks.
func
(
p
*
Provider
)
LoadBalancerSrcRanges
()
[]
string
{
func
(
p
*
Provider
)
LoadBalancerSrcRanges
()
[]
string
{
return
gcecloud
.
LoadBalancerSrcRanges
()
return
gcecloud
.
LoadBalancerSrcRanges
()
}
}
// EnableAndDisableInternalLB returns functions for both enabling and disabling internal Load Balancer
func
(
p
*
Provider
)
EnableAndDisableInternalLB
()
(
enable
,
disable
func
(
svc
*
v1
.
Service
))
{
func
(
p
*
Provider
)
EnableAndDisableInternalLB
()
(
enable
,
disable
func
(
svc
*
v1
.
Service
))
{
enable
=
func
(
svc
*
v1
.
Service
)
{
enable
=
func
(
svc
*
v1
.
Service
)
{
svc
.
ObjectMeta
.
Annotations
=
map
[
string
]
string
{
gcecloud
.
ServiceAnnotationLoadBalancerType
:
string
(
gcecloud
.
LBTypeInternal
)}
svc
.
ObjectMeta
.
Annotations
=
map
[
string
]
string
{
gcecloud
.
ServiceAnnotationLoadBalancerType
:
string
(
gcecloud
.
LBTypeInternal
)}
...
@@ -351,13 +365,14 @@ func GetNodeTags(c clientset.Interface, cloudConfig framework.CloudConfig) []str
...
@@ -351,13 +365,14 @@ func GetNodeTags(c clientset.Interface, cloudConfig framework.CloudConfig) []str
return
GetInstanceTags
(
cloudConfig
,
nodes
.
Items
[
0
]
.
Name
)
.
Items
return
GetInstanceTags
(
cloudConfig
,
nodes
.
Items
[
0
]
.
Name
)
.
Items
}
}
// IsHTTPErrorCode returns true if the error is a google api
// Is
GoogleAPI
HTTPErrorCode returns true if the error is a google api
// error matching the corresponding HTTP error code.
// error matching the corresponding HTTP error code.
func
IsGoogleAPIHTTPErrorCode
(
err
error
,
code
int
)
bool
{
func
IsGoogleAPIHTTPErrorCode
(
err
error
,
code
int
)
bool
{
apiErr
,
ok
:=
err
.
(
*
googleapi
.
Error
)
apiErr
,
ok
:=
err
.
(
*
googleapi
.
Error
)
return
ok
&&
apiErr
.
Code
==
code
return
ok
&&
apiErr
.
Code
==
code
}
}
// GetGCECloud returns GCE cloud provider
func
GetGCECloud
()
(
*
gcecloud
.
Cloud
,
error
)
{
func
GetGCECloud
()
(
*
gcecloud
.
Cloud
,
error
)
{
p
,
ok
:=
framework
.
TestContext
.
CloudConfig
.
Provider
.
(
*
Provider
)
p
,
ok
:=
framework
.
TestContext
.
CloudConfig
.
Provider
.
(
*
Provider
)
if
!
ok
{
if
!
ok
{
...
@@ -366,6 +381,7 @@ func GetGCECloud() (*gcecloud.Cloud, error) {
...
@@ -366,6 +381,7 @@ func GetGCECloud() (*gcecloud.Cloud, error) {
return
p
.
gceCloud
,
nil
return
p
.
gceCloud
,
nil
}
}
// GetClusterID returns cluster ID
func
GetClusterID
(
c
clientset
.
Interface
)
(
string
,
error
)
{
func
GetClusterID
(
c
clientset
.
Interface
)
(
string
,
error
)
{
cm
,
err
:=
c
.
CoreV1
()
.
ConfigMaps
(
metav1
.
NamespaceSystem
)
.
Get
(
gcecloud
.
UIDConfigMapName
,
metav1
.
GetOptions
{})
cm
,
err
:=
c
.
CoreV1
()
.
ConfigMaps
(
metav1
.
NamespaceSystem
)
.
Get
(
gcecloud
.
UIDConfigMapName
,
metav1
.
GetOptions
{})
if
err
!=
nil
||
cm
==
nil
{
if
err
!=
nil
||
cm
==
nil
{
...
...
test/e2e/framework/providers/gce/ingress.go
View file @
a3bc56ff
This diff is collapsed.
Click to expand it.
test/e2e/network/firewall.go
View file @
a3bc56ff
...
@@ -33,6 +33,13 @@ import (
...
@@ -33,6 +33,13 @@ import (
.
"github.com/onsi/gomega"
.
"github.com/onsi/gomega"
)
)
const
(
firewallTestTCPTimeout
=
time
.
Duration
(
1
*
time
.
Second
)
// Set ports outside of 30000-32767, 80 and 8080 to avoid being whitelisted by the e2e cluster
firewallTestHTTPPort
=
int32
(
29999
)
firewallTestUDPPort
=
int32
(
29998
)
)
var
_
=
SIGDescribe
(
"Firewall rule"
,
func
()
{
var
_
=
SIGDescribe
(
"Firewall rule"
,
func
()
{
var
firewall_test_name
=
"firewall-test"
var
firewall_test_name
=
"firewall-test"
f
:=
framework
.
NewDefaultFramework
(
firewall_test_name
)
f
:=
framework
.
NewDefaultFramework
(
firewall_test_name
)
...
@@ -74,7 +81,7 @@ var _ = SIGDescribe("Firewall rule", func() {
...
@@ -74,7 +81,7 @@ var _ = SIGDescribe("Firewall rule", func() {
By
(
"Creating a LoadBalancer type service with ExternalTrafficPolicy=Global"
)
By
(
"Creating a LoadBalancer type service with ExternalTrafficPolicy=Global"
)
svc
:=
jig
.
CreateLoadBalancerService
(
ns
,
serviceName
,
framework
.
LoadBalancerCreateTimeoutDefault
,
func
(
svc
*
v1
.
Service
)
{
svc
:=
jig
.
CreateLoadBalancerService
(
ns
,
serviceName
,
framework
.
LoadBalancerCreateTimeoutDefault
,
func
(
svc
*
v1
.
Service
)
{
svc
.
Spec
.
Ports
=
[]
v1
.
ServicePort
{{
Protocol
:
v1
.
ProtocolTCP
,
Port
:
gce
.
FirewallTestHttp
Port
}}
svc
.
Spec
.
Ports
=
[]
v1
.
ServicePort
{{
Protocol
:
v1
.
ProtocolTCP
,
Port
:
firewallTestHTTP
Port
}}
svc
.
Spec
.
LoadBalancerSourceRanges
=
firewallTestSourceRanges
svc
.
Spec
.
LoadBalancerSourceRanges
=
firewallTestSourceRanges
})
})
defer
func
()
{
defer
func
()
{
...
@@ -121,7 +128,7 @@ var _ = SIGDescribe("Firewall rule", func() {
...
@@ -121,7 +128,7 @@ var _ = SIGDescribe("Firewall rule", func() {
By
(
fmt
.
Sprintf
(
"Creating netexec pods on at most %v nodes"
,
framework
.
MaxNodesForEndpointsTests
))
By
(
fmt
.
Sprintf
(
"Creating netexec pods on at most %v nodes"
,
framework
.
MaxNodesForEndpointsTests
))
for
i
,
nodeName
:=
range
nodesNames
{
for
i
,
nodeName
:=
range
nodesNames
{
podName
:=
fmt
.
Sprintf
(
"netexec%v"
,
i
)
podName
:=
fmt
.
Sprintf
(
"netexec%v"
,
i
)
jig
.
LaunchNetexecPodOnNode
(
f
,
nodeName
,
podName
,
gce
.
FirewallTestHttpPort
,
gce
.
FirewallTestUdp
Port
,
true
)
jig
.
LaunchNetexecPodOnNode
(
f
,
nodeName
,
podName
,
firewallTestHTTPPort
,
firewallTestUDP
Port
,
true
)
defer
func
()
{
defer
func
()
{
framework
.
Logf
(
"Cleaning up the netexec pod: %v"
,
podName
)
framework
.
Logf
(
"Cleaning up the netexec pod: %v"
,
podName
)
Expect
(
cs
.
CoreV1
()
.
Pods
(
ns
)
.
Delete
(
podName
,
nil
))
.
NotTo
(
HaveOccurred
())
Expect
(
cs
.
CoreV1
()
.
Pods
(
ns
)
.
Delete
(
podName
,
nil
))
.
NotTo
(
HaveOccurred
())
...
@@ -130,7 +137,7 @@ var _ = SIGDescribe("Firewall rule", func() {
...
@@ -130,7 +137,7 @@ var _ = SIGDescribe("Firewall rule", func() {
// Send requests from outside of the cluster because internal traffic is whitelisted
// Send requests from outside of the cluster because internal traffic is whitelisted
By
(
"Accessing the external service ip from outside, all non-master nodes should be reached"
)
By
(
"Accessing the external service ip from outside, all non-master nodes should be reached"
)
Expect
(
framework
.
TestHitNodesFromOutside
(
svcExternalIP
,
gce
.
FirewallTestHttp
Port
,
framework
.
LoadBalancerCreateTimeoutDefault
,
nodesSet
))
.
NotTo
(
HaveOccurred
())
Expect
(
framework
.
TestHitNodesFromOutside
(
svcExternalIP
,
firewallTestHTTP
Port
,
framework
.
LoadBalancerCreateTimeoutDefault
,
nodesSet
))
.
NotTo
(
HaveOccurred
())
// Check if there are overlapping tags on the firewall that extend beyond just the vms in our cluster
// Check if there are overlapping tags on the firewall that extend beyond just the vms in our cluster
// by removing the tag on one vm and make sure it doesn't get any traffic. This is an imperfect
// by removing the tag on one vm and make sure it doesn't get any traffic. This is an imperfect
...
@@ -150,11 +157,11 @@ var _ = SIGDescribe("Firewall rule", func() {
...
@@ -150,11 +157,11 @@ var _ = SIGDescribe("Firewall rule", func() {
nodesSet
.
Insert
(
nodesNames
[
0
])
nodesSet
.
Insert
(
nodesNames
[
0
])
gce
.
SetInstanceTags
(
cloudConfig
,
nodesNames
[
0
],
zone
,
removedTags
)
gce
.
SetInstanceTags
(
cloudConfig
,
nodesNames
[
0
],
zone
,
removedTags
)
// Make sure traffic is recovered before exit
// Make sure traffic is recovered before exit
Expect
(
framework
.
TestHitNodesFromOutside
(
svcExternalIP
,
gce
.
FirewallTestHttp
Port
,
framework
.
LoadBalancerCreateTimeoutDefault
,
nodesSet
))
.
NotTo
(
HaveOccurred
())
Expect
(
framework
.
TestHitNodesFromOutside
(
svcExternalIP
,
firewallTestHTTP
Port
,
framework
.
LoadBalancerCreateTimeoutDefault
,
nodesSet
))
.
NotTo
(
HaveOccurred
())
}()
}()
By
(
"Accessing serivce through the external ip and examine got no response from the node without tags"
)
By
(
"Accessing serivce through the external ip and examine got no response from the node without tags"
)
Expect
(
framework
.
TestHitNodesFromOutsideWithCount
(
svcExternalIP
,
gce
.
FirewallTestHttp
Port
,
framework
.
LoadBalancerCreateTimeoutDefault
,
nodesSet
,
15
))
.
NotTo
(
HaveOccurred
())
Expect
(
framework
.
TestHitNodesFromOutsideWithCount
(
svcExternalIP
,
firewallTestHTTP
Port
,
framework
.
LoadBalancerCreateTimeoutDefault
,
nodesSet
,
15
))
.
NotTo
(
HaveOccurred
())
})
})
It
(
"should have correct firewall rules for e2e cluster"
,
func
()
{
It
(
"should have correct firewall rules for e2e cluster"
,
func
()
{
...
@@ -178,12 +185,12 @@ var _ = SIGDescribe("Firewall rule", func() {
...
@@ -178,12 +185,12 @@ var _ = SIGDescribe("Firewall rule", func() {
masterAddresses
:=
framework
.
GetAllMasterAddresses
(
cs
)
masterAddresses
:=
framework
.
GetAllMasterAddresses
(
cs
)
for
_
,
masterAddress
:=
range
masterAddresses
{
for
_
,
masterAddress
:=
range
masterAddresses
{
assertNotReachableHTTPTimeout
(
masterAddress
,
ports
.
InsecureKubeControllerManagerPort
,
gce
.
FirewallTestTcp
Timeout
)
assertNotReachableHTTPTimeout
(
masterAddress
,
ports
.
InsecureKubeControllerManagerPort
,
firewallTestTCP
Timeout
)
assertNotReachableHTTPTimeout
(
masterAddress
,
ports
.
InsecureSchedulerPort
,
gce
.
FirewallTestTcp
Timeout
)
assertNotReachableHTTPTimeout
(
masterAddress
,
ports
.
InsecureSchedulerPort
,
firewallTestTCP
Timeout
)
}
}
assertNotReachableHTTPTimeout
(
nodeAddrs
[
0
],
ports
.
KubeletPort
,
gce
.
FirewallTestTcp
Timeout
)
assertNotReachableHTTPTimeout
(
nodeAddrs
[
0
],
ports
.
KubeletPort
,
firewallTestTCP
Timeout
)
assertNotReachableHTTPTimeout
(
nodeAddrs
[
0
],
ports
.
KubeletReadOnlyPort
,
gce
.
FirewallTestTcp
Timeout
)
assertNotReachableHTTPTimeout
(
nodeAddrs
[
0
],
ports
.
KubeletReadOnlyPort
,
firewallTestTCP
Timeout
)
assertNotReachableHTTPTimeout
(
nodeAddrs
[
0
],
ports
.
ProxyStatusPort
,
gce
.
FirewallTestTcp
Timeout
)
assertNotReachableHTTPTimeout
(
nodeAddrs
[
0
],
ports
.
ProxyStatusPort
,
firewallTestTCP
Timeout
)
})
})
})
})
...
...
test/e2e/network/ingress.go
View file @
a3bc56ff
...
@@ -83,13 +83,13 @@ var _ = SIGDescribe("Loadbalancing: L7", func() {
...
@@ -83,13 +83,13 @@ var _ = SIGDescribe("Loadbalancing: L7", func() {
// Slow by design ~10m for each "It" block dominated by loadbalancer setup time
// Slow by design ~10m for each "It" block dominated by loadbalancer setup time
// TODO: write similar tests for nginx, haproxy and AWS Ingress.
// TODO: write similar tests for nginx, haproxy and AWS Ingress.
Describe
(
"GCE [Slow] [Feature:Ingress]"
,
func
()
{
Describe
(
"GCE [Slow] [Feature:Ingress]"
,
func
()
{
var
gceController
*
gce
.
GCE
IngressController
var
gceController
*
gce
.
IngressController
// Platform specific setup
// Platform specific setup
BeforeEach
(
func
()
{
BeforeEach
(
func
()
{
framework
.
SkipUnlessProviderIs
(
"gce"
,
"gke"
)
framework
.
SkipUnlessProviderIs
(
"gce"
,
"gke"
)
By
(
"Initializing gce controller"
)
By
(
"Initializing gce controller"
)
gceController
=
&
gce
.
GCE
IngressController
{
gceController
=
&
gce
.
IngressController
{
Ns
:
ns
,
Ns
:
ns
,
Client
:
jig
.
Client
,
Client
:
jig
.
Client
,
Cloud
:
framework
.
TestContext
.
CloudConfig
,
Cloud
:
framework
.
TestContext
.
CloudConfig
,
...
@@ -111,7 +111,7 @@ var _ = SIGDescribe("Loadbalancing: L7", func() {
...
@@ -111,7 +111,7 @@ var _ = SIGDescribe("Loadbalancing: L7", func() {
jig
.
TryDeleteIngress
()
jig
.
TryDeleteIngress
()
By
(
"Cleaning up cloud resources"
)
By
(
"Cleaning up cloud resources"
)
Expect
(
gceController
.
Cleanup
GCE
IngressController
())
.
NotTo
(
HaveOccurred
())
Expect
(
gceController
.
CleanupIngressController
())
.
NotTo
(
HaveOccurred
())
})
})
It
(
"should conform to Ingress spec"
,
func
()
{
It
(
"should conform to Ingress spec"
,
func
()
{
...
@@ -125,7 +125,7 @@ var _ = SIGDescribe("Loadbalancing: L7", func() {
...
@@ -125,7 +125,7 @@ var _ = SIGDescribe("Loadbalancing: L7", func() {
})
})
It
(
"should create ingress with given static-ip"
,
func
()
{
It
(
"should create ingress with given static-ip"
,
func
()
{
// ip released when the rest of lb resources are deleted in Cleanup
GCE
IngressController
// ip released when the rest of lb resources are deleted in CleanupIngressController
ip
:=
gceController
.
CreateStaticIP
(
ns
)
ip
:=
gceController
.
CreateStaticIP
(
ns
)
By
(
fmt
.
Sprintf
(
"allocated static ip %v: %v through the GCE cloud provider"
,
ns
,
ip
))
By
(
fmt
.
Sprintf
(
"allocated static ip %v: %v through the GCE cloud provider"
,
ns
,
ip
))
executeStaticIPHttpsOnlyTest
(
f
,
jig
,
ns
,
ip
)
executeStaticIPHttpsOnlyTest
(
f
,
jig
,
ns
,
ip
)
...
@@ -401,17 +401,17 @@ var _ = SIGDescribe("Loadbalancing: L7", func() {
...
@@ -401,17 +401,17 @@ var _ = SIGDescribe("Loadbalancing: L7", func() {
// Verify that the controller does not create any other resource except instance group.
// Verify that the controller does not create any other resource except instance group.
// TODO(59778): Check GCE resources specific to this ingress instead of listing all resources.
// TODO(59778): Check GCE resources specific to this ingress instead of listing all resources.
if
len
(
gceController
.
ListU
rl
Maps
())
!=
0
{
if
len
(
gceController
.
ListU
RL
Maps
())
!=
0
{
framework
.
Failf
(
"unexpected url maps, expected none, got: %v"
,
gceController
.
ListU
rl
Maps
())
framework
.
Failf
(
"unexpected url maps, expected none, got: %v"
,
gceController
.
ListU
RL
Maps
())
}
}
if
len
(
gceController
.
ListGlobalForwardingRules
())
!=
0
{
if
len
(
gceController
.
ListGlobalForwardingRules
())
!=
0
{
framework
.
Failf
(
"unexpected forwarding rules, expected none, got: %v"
,
gceController
.
ListGlobalForwardingRules
())
framework
.
Failf
(
"unexpected forwarding rules, expected none, got: %v"
,
gceController
.
ListGlobalForwardingRules
())
}
}
if
len
(
gceController
.
ListTargetH
ttp
Proxies
())
!=
0
{
if
len
(
gceController
.
ListTargetH
TTP
Proxies
())
!=
0
{
framework
.
Failf
(
"unexpected target http proxies, expected none, got: %v"
,
gceController
.
ListTargetH
ttp
Proxies
())
framework
.
Failf
(
"unexpected target http proxies, expected none, got: %v"
,
gceController
.
ListTargetH
TTP
Proxies
())
}
}
if
len
(
gceController
.
ListTargetH
ttps
Proxies
())
!=
0
{
if
len
(
gceController
.
ListTargetH
TTPS
Proxies
())
!=
0
{
framework
.
Failf
(
"unexpected target https proxies, expected none, got: %v"
,
gceController
.
ListTargetH
ttp
Proxies
())
framework
.
Failf
(
"unexpected target https proxies, expected none, got: %v"
,
gceController
.
ListTargetH
TTP
Proxies
())
}
}
if
len
(
gceController
.
ListSslCertificates
())
!=
0
{
if
len
(
gceController
.
ListSslCertificates
())
!=
0
{
framework
.
Failf
(
"unexpected ssl certificates, expected none, got: %v"
,
gceController
.
ListSslCertificates
())
framework
.
Failf
(
"unexpected ssl certificates, expected none, got: %v"
,
gceController
.
ListSslCertificates
())
...
@@ -466,13 +466,13 @@ var _ = SIGDescribe("Loadbalancing: L7", func() {
...
@@ -466,13 +466,13 @@ var _ = SIGDescribe("Loadbalancing: L7", func() {
})
})
Describe
(
"GCE [Slow] [Feature:NEG]"
,
func
()
{
Describe
(
"GCE [Slow] [Feature:NEG]"
,
func
()
{
var
gceController
*
gce
.
GCE
IngressController
var
gceController
*
gce
.
IngressController
// Platform specific setup
// Platform specific setup
BeforeEach
(
func
()
{
BeforeEach
(
func
()
{
framework
.
SkipUnlessProviderIs
(
"gce"
,
"gke"
)
framework
.
SkipUnlessProviderIs
(
"gce"
,
"gke"
)
By
(
"Initializing gce controller"
)
By
(
"Initializing gce controller"
)
gceController
=
&
gce
.
GCE
IngressController
{
gceController
=
&
gce
.
IngressController
{
Ns
:
ns
,
Ns
:
ns
,
Client
:
jig
.
Client
,
Client
:
jig
.
Client
,
Cloud
:
framework
.
TestContext
.
CloudConfig
,
Cloud
:
framework
.
TestContext
.
CloudConfig
,
...
@@ -494,7 +494,7 @@ var _ = SIGDescribe("Loadbalancing: L7", func() {
...
@@ -494,7 +494,7 @@ var _ = SIGDescribe("Loadbalancing: L7", func() {
jig
.
TryDeleteIngress
()
jig
.
TryDeleteIngress
()
By
(
"Cleaning up cloud resources"
)
By
(
"Cleaning up cloud resources"
)
Expect
(
gceController
.
Cleanup
GCE
IngressController
())
.
NotTo
(
HaveOccurred
())
Expect
(
gceController
.
CleanupIngressController
())
.
NotTo
(
HaveOccurred
())
})
})
It
(
"should conform to Ingress spec"
,
func
()
{
It
(
"should conform to Ingress spec"
,
func
()
{
...
@@ -808,7 +808,7 @@ var _ = SIGDescribe("Loadbalancing: L7", func() {
...
@@ -808,7 +808,7 @@ var _ = SIGDescribe("Loadbalancing: L7", func() {
})
})
Describe
(
"GCE [Slow] [Feature:kubemci]"
,
func
()
{
Describe
(
"GCE [Slow] [Feature:kubemci]"
,
func
()
{
var
gceController
*
gce
.
GCE
IngressController
var
gceController
*
gce
.
IngressController
var
ipName
,
ipAddress
string
var
ipName
,
ipAddress
string
// Platform specific setup
// Platform specific setup
...
@@ -817,7 +817,7 @@ var _ = SIGDescribe("Loadbalancing: L7", func() {
...
@@ -817,7 +817,7 @@ var _ = SIGDescribe("Loadbalancing: L7", func() {
jig
.
Class
=
ingress
.
MulticlusterIngressClassValue
jig
.
Class
=
ingress
.
MulticlusterIngressClassValue
jig
.
PollInterval
=
5
*
time
.
Second
jig
.
PollInterval
=
5
*
time
.
Second
By
(
"Initializing gce controller"
)
By
(
"Initializing gce controller"
)
gceController
=
&
gce
.
GCE
IngressController
{
gceController
=
&
gce
.
IngressController
{
Ns
:
ns
,
Ns
:
ns
,
Client
:
jig
.
Client
,
Client
:
jig
.
Client
,
Cloud
:
framework
.
TestContext
.
CloudConfig
,
Cloud
:
framework
.
TestContext
.
CloudConfig
,
...
@@ -828,7 +828,7 @@ var _ = SIGDescribe("Loadbalancing: L7", func() {
...
@@ -828,7 +828,7 @@ var _ = SIGDescribe("Loadbalancing: L7", func() {
// TODO(https://github.com/GoogleCloudPlatform/k8s-multicluster-ingress/issues/19):
// TODO(https://github.com/GoogleCloudPlatform/k8s-multicluster-ingress/issues/19):
// Kubemci should reserve a static ip if user has not specified one.
// Kubemci should reserve a static ip if user has not specified one.
ipName
=
"kubemci-"
+
string
(
uuid
.
NewUUID
())
ipName
=
"kubemci-"
+
string
(
uuid
.
NewUUID
())
// ip released when the rest of lb resources are deleted in Cleanup
GCE
IngressController
// ip released when the rest of lb resources are deleted in CleanupIngressController
ipAddress
=
gceController
.
CreateStaticIP
(
ipName
)
ipAddress
=
gceController
.
CreateStaticIP
(
ipName
)
By
(
fmt
.
Sprintf
(
"allocated static ip %v: %v through the GCE cloud provider"
,
ipName
,
ipAddress
))
By
(
fmt
.
Sprintf
(
"allocated static ip %v: %v through the GCE cloud provider"
,
ipName
,
ipAddress
))
})
})
...
@@ -846,7 +846,7 @@ var _ = SIGDescribe("Loadbalancing: L7", func() {
...
@@ -846,7 +846,7 @@ var _ = SIGDescribe("Loadbalancing: L7", func() {
}
}
By
(
"Cleaning up cloud resources"
)
By
(
"Cleaning up cloud resources"
)
Expect
(
gceController
.
Cleanup
GCE
IngressController
())
.
NotTo
(
HaveOccurred
())
Expect
(
gceController
.
CleanupIngressController
())
.
NotTo
(
HaveOccurred
())
})
})
It
(
"should conform to Ingress spec"
,
func
()
{
It
(
"should conform to Ingress spec"
,
func
()
{
...
@@ -1118,7 +1118,7 @@ func detectHttpVersionAndSchemeTest(f *framework.Framework, jig *ingress.TestJig
...
@@ -1118,7 +1118,7 @@ func detectHttpVersionAndSchemeTest(f *framework.Framework, jig *ingress.TestJig
Expect
(
err
)
.
NotTo
(
HaveOccurred
(),
fmt
.
Sprintf
(
"Failed to get %s or %s, response body: %s"
,
version
,
scheme
,
resp
))
Expect
(
err
)
.
NotTo
(
HaveOccurred
(),
fmt
.
Sprintf
(
"Failed to get %s or %s, response body: %s"
,
version
,
scheme
,
resp
))
}
}
func
detectNegAnnotation
(
f
*
framework
.
Framework
,
jig
*
ingress
.
TestJig
,
gceController
*
gce
.
GCE
IngressController
,
ns
,
name
string
,
negs
int
)
{
func
detectNegAnnotation
(
f
*
framework
.
Framework
,
jig
*
ingress
.
TestJig
,
gceController
*
gce
.
IngressController
,
ns
,
name
string
,
negs
int
)
{
if
err
:=
wait
.
Poll
(
5
*
time
.
Second
,
negUpdateTimeout
,
func
()
(
bool
,
error
)
{
if
err
:=
wait
.
Poll
(
5
*
time
.
Second
,
negUpdateTimeout
,
func
()
(
bool
,
error
)
{
svc
,
err
:=
f
.
ClientSet
.
CoreV1
()
.
Services
(
ns
)
.
Get
(
name
,
metav1
.
GetOptions
{})
svc
,
err
:=
f
.
ClientSet
.
CoreV1
()
.
Services
(
ns
)
.
Get
(
name
,
metav1
.
GetOptions
{})
if
err
!=
nil
{
if
err
!=
nil
{
...
...
test/e2e/network/scale/ingress.go
View file @
a3bc56ff
...
@@ -63,7 +63,7 @@ var (
...
@@ -63,7 +63,7 @@ var (
type
IngressScaleFramework
struct
{
type
IngressScaleFramework
struct
{
Clientset
clientset
.
Interface
Clientset
clientset
.
Interface
Jig
*
ingress
.
TestJig
Jig
*
ingress
.
TestJig
GCEController
*
gce
.
GCE
IngressController
GCEController
*
gce
.
IngressController
CloudConfig
framework
.
CloudConfig
CloudConfig
framework
.
CloudConfig
Logger
ingress
.
TestLogger
Logger
ingress
.
TestLogger
...
@@ -112,7 +112,7 @@ func (f *IngressScaleFramework) PrepareScaleTest() error {
...
@@ -112,7 +112,7 @@ func (f *IngressScaleFramework) PrepareScaleTest() error {
f
.
Jig
=
ingress
.
NewIngressTestJig
(
f
.
Clientset
)
f
.
Jig
=
ingress
.
NewIngressTestJig
(
f
.
Clientset
)
f
.
Jig
.
Logger
=
f
.
Logger
f
.
Jig
.
Logger
=
f
.
Logger
f
.
Jig
.
PollInterval
=
scaleTestPollInterval
f
.
Jig
.
PollInterval
=
scaleTestPollInterval
f
.
GCEController
=
&
gce
.
GCE
IngressController
{
f
.
GCEController
=
&
gce
.
IngressController
{
Client
:
f
.
Clientset
,
Client
:
f
.
Clientset
,
Cloud
:
f
.
CloudConfig
,
Cloud
:
f
.
CloudConfig
,
}
}
...
@@ -154,7 +154,7 @@ func (f *IngressScaleFramework) CleanupScaleTest() []error {
...
@@ -154,7 +154,7 @@ func (f *IngressScaleFramework) CleanupScaleTest() []error {
}
}
f
.
Logger
.
Infof
(
"Cleaning up cloud resources..."
)
f
.
Logger
.
Infof
(
"Cleaning up cloud resources..."
)
if
err
:=
f
.
GCEController
.
Cleanup
GCE
IngressControllerWithTimeout
(
ingressesCleanupTimeout
);
err
!=
nil
{
if
err
:=
f
.
GCEController
.
CleanupIngressControllerWithTimeout
(
ingressesCleanupTimeout
);
err
!=
nil
{
errs
=
append
(
errs
,
err
)
errs
=
append
(
errs
,
err
)
}
}
...
...
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