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
7fff54cf
Commit
7fff54cf
authored
Mar 12, 2018
by
Ashley Gau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move shared test cluster vars into method + type
parent
ac6ff68e
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
8 deletions
+26
-8
gce_loadbalancer_external_test.go
...dprovider/providers/gce/gce_loadbalancer_external_test.go
+0
-0
gce_loadbalancer_internal_test.go
...dprovider/providers/gce/gce_loadbalancer_internal_test.go
+0
-0
gce_loadbalancer_utils_test.go
...loudprovider/providers/gce/gce_loadbalancer_utils_test.go
+26
-8
No files found.
pkg/cloudprovider/providers/gce/gce_loadbalancer_external_test.go
View file @
7fff54cf
This diff is collapsed.
Click to expand it.
pkg/cloudprovider/providers/gce/gce_loadbalancer_internal_test.go
View file @
7fff54cf
This diff is collapsed.
Click to expand it.
pkg/cloudprovider/providers/gce/gce_loadbalancer_utils_test.go
View file @
7fff54cf
...
@@ -34,6 +34,24 @@ import (
...
@@ -34,6 +34,24 @@ import (
kubeletapis
"k8s.io/kubernetes/pkg/kubelet/apis"
kubeletapis
"k8s.io/kubernetes/pkg/kubelet/apis"
)
)
type
TestClusterValues
struct
{
ProjectID
string
Region
string
ZoneName
string
ClusterID
string
ClusterName
string
}
func
DefaultTestClusterValues
()
TestClusterValues
{
return
TestClusterValues
{
ProjectID
:
"test-project"
,
Region
:
"us-central1"
,
ZoneName
:
"us-central1-b"
,
ClusterID
:
"test-cluster-id"
,
ClusterName
:
"Test Cluster Name"
,
}
}
var
fakeApiService
=
&
v1
.
Service
{
var
fakeApiService
=
&
v1
.
Service
{
Spec
:
v1
.
ServiceSpec
{
Spec
:
v1
.
ServiceSpec
{
SessionAffinity
:
v1
.
ServiceAffinityClientIP
,
SessionAffinity
:
v1
.
ServiceAffinityClientIP
,
...
@@ -48,7 +66,7 @@ func (*fakeRoundTripper) RoundTrip(*http.Request) (*http.Response, error) {
...
@@ -48,7 +66,7 @@ func (*fakeRoundTripper) RoundTrip(*http.Request) (*http.Response, error) {
return
nil
,
fmt
.
Errorf
(
"err: test used fake http client"
)
return
nil
,
fmt
.
Errorf
(
"err: test used fake http client"
)
}
}
func
fakeGCECloud
(
projectID
,
region
,
zoneName
string
)
(
*
GCECloud
,
error
)
{
func
fakeGCECloud
(
vals
TestClusterValues
)
(
*
GCECloud
,
error
)
{
client
:=
&
http
.
Client
{
Transport
:
&
fakeRoundTripper
{}}
client
:=
&
http
.
Client
{
Transport
:
&
fakeRoundTripper
{}}
service
,
err
:=
compute
.
New
(
client
)
service
,
err
:=
compute
.
New
(
client
)
...
@@ -57,8 +75,8 @@ func fakeGCECloud(projectID, region, zoneName string) (*GCECloud, error) {
...
@@ -57,8 +75,8 @@ func fakeGCECloud(projectID, region, zoneName string) (*GCECloud, error) {
}
}
// Used in disk unit tests
// Used in disk unit tests
fakeManager
:=
newFakeManager
(
projectID
,
r
egion
)
fakeManager
:=
newFakeManager
(
vals
.
ProjectID
,
vals
.
R
egion
)
zonesWithNodes
:=
createNodeZones
([]
string
{
z
oneName
})
zonesWithNodes
:=
createNodeZones
([]
string
{
vals
.
Z
oneName
})
alphaFeatureGate
,
err
:=
NewAlphaFeatureGate
([]
string
{})
alphaFeatureGate
,
err
:=
NewAlphaFeatureGate
([]
string
{})
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -66,12 +84,12 @@ func fakeGCECloud(projectID, region, zoneName string) (*GCECloud, error) {
...
@@ -66,12 +84,12 @@ func fakeGCECloud(projectID, region, zoneName string) (*GCECloud, error) {
}
}
gce
:=
&
GCECloud
{
gce
:=
&
GCECloud
{
region
:
r
egion
,
region
:
vals
.
R
egion
,
service
:
service
,
service
:
service
,
manager
:
fakeManager
,
manager
:
fakeManager
,
managedZones
:
[]
string
{
z
oneName
},
managedZones
:
[]
string
{
vals
.
Z
oneName
},
projectID
:
p
rojectID
,
projectID
:
vals
.
P
rojectID
,
networkProjectID
:
p
rojectID
,
networkProjectID
:
vals
.
P
rojectID
,
AlphaFeatureGate
:
alphaFeatureGate
,
AlphaFeatureGate
:
alphaFeatureGate
,
nodeZones
:
zonesWithNodes
,
nodeZones
:
zonesWithNodes
,
nodeInformerSynced
:
func
()
bool
{
return
true
},
nodeInformerSynced
:
func
()
bool
{
return
true
},
...
@@ -94,7 +112,7 @@ func fakeGCECloud(projectID, region, zoneName string) (*GCECloud, error) {
...
@@ -94,7 +112,7 @@ func fakeGCECloud(projectID, region, zoneName string) (*GCECloud, error) {
keyGA
:=
meta
.
GlobalKey
(
"key-ga"
)
keyGA
:=
meta
.
GlobalKey
(
"key-ga"
)
c
.
MockZones
.
Objects
[
*
keyGA
]
=
&
cloud
.
MockZonesObj
{
c
.
MockZones
.
Objects
[
*
keyGA
]
=
&
cloud
.
MockZonesObj
{
Obj
:
&
compute
.
Zone
{
Name
:
zoneName
,
Region
:
gce
.
getRegionLink
(
r
egion
)},
Obj
:
&
compute
.
Zone
{
Name
:
vals
.
ZoneName
,
Region
:
gce
.
getRegionLink
(
vals
.
R
egion
)},
}
}
gce
.
c
=
c
gce
.
c
=
c
...
...
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