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
ea61af57
Commit
ea61af57
authored
May 12, 2017
by
Maru Newby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fed: Refactor integ test fixture to support cluster addition by test
parent
e401dc74
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
35 deletions
+37
-35
federation.go
test/integration/federation/framework/federation.go
+37
-35
No files found.
test/integration/federation/framework/federation.go
View file @
ea61af57
...
...
@@ -23,6 +23,7 @@ import (
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
federationapi
"k8s.io/kubernetes/federation/apis/federation/v1beta1"
federationclientset
"k8s.io/kubernetes/federation/client/clientset_generated/federation_clientset"
clustercontroller
"k8s.io/kubernetes/federation/pkg/federation-controller/cluster"
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
"k8s.io/kubernetes/pkg/master"
...
...
@@ -43,6 +44,7 @@ type FederationFixture struct {
Clusters
[]
*
MemberCluster
ClusterClients
[]
clientset
.
Interface
ClusterController
*
clustercontroller
.
ClusterController
fedClient
federationclientset
.
Interface
stopChan
chan
struct
{}
}
...
...
@@ -64,46 +66,46 @@ func (f *FederationFixture) SetUp(t *testing.T) {
monitorPeriod
:=
1
*
time
.
Second
clustercontroller
.
StartClusterController
(
f
.
APIFixture
.
NewConfig
(),
f
.
stopChan
,
monitorPeriod
)
f
.
startClusters
()
f
.
fedClient
=
f
.
APIFixture
.
NewClient
(
"federation-fixture"
)
for
i
:=
0
;
i
<
f
.
DesiredClusterCount
;
i
++
{
f
.
StartCluster
(
t
)
}
}
func
(
f
*
FederationFixture
)
startClusters
()
{
fedClient
:=
f
.
APIFixture
.
NewClient
(
"federation-fixture"
)
for
i
:=
0
;
i
<
f
.
DesiredClusterCount
;
i
++
{
config
:=
framework
.
NewMasterConfig
()
_
,
_
,
closeFn
:=
framework
.
RunAMaster
(
config
)
host
:=
config
.
GenericConfig
.
LoopbackClientConfig
.
Host
// Use fmt to ensure the output will be visible when run with go test -v
fmt
.
Printf
(
"Federated cluster %d serving on %s"
,
i
,
host
)
clusterClient
:=
clientset
.
NewForConfigOrDie
(
config
.
GenericConfig
.
LoopbackClientConfig
)
f
.
Clusters
=
append
(
f
.
Clusters
,
&
MemberCluster
{
CloseFn
:
closeFn
,
Config
:
config
,
Client
:
clusterClient
,
Host
:
host
,
})
f
.
ClusterClients
=
append
(
f
.
ClusterClients
,
clusterClient
)
cluster
:=
&
federationapi
.
Cluster
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
fmt
.
Sprintf
(
"cluster-%d"
,
i
),
},
Spec
:
federationapi
.
ClusterSpec
{
ServerAddressByClientCIDRs
:
[]
federationapi
.
ServerAddressByClientCIDR
{
{
ClientCIDR
:
"0.0.0.0/0"
,
ServerAddress
:
host
,
},
func
(
f
*
FederationFixture
)
StartCluster
(
t
*
testing
.
T
)
{
config
:=
framework
.
NewMasterConfig
()
_
,
_
,
closeFn
:=
framework
.
RunAMaster
(
config
)
host
:=
config
.
GenericConfig
.
LoopbackClientConfig
.
Host
clusterClient
:=
clientset
.
NewForConfigOrDie
(
config
.
GenericConfig
.
LoopbackClientConfig
)
f
.
ClusterClients
=
append
(
f
.
ClusterClients
,
clusterClient
)
f
.
Clusters
=
append
(
f
.
Clusters
,
&
MemberCluster
{
CloseFn
:
closeFn
,
Config
:
config
,
Client
:
clusterClient
,
Host
:
host
,
})
clusterId
:=
len
(
f
.
ClusterClients
)
t
.
Logf
(
"Federated cluster %d serving on %s"
,
clusterId
,
host
)
cluster
:=
&
federationapi
.
Cluster
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
fmt
.
Sprintf
(
"cluster-%d"
,
clusterId
),
},
Spec
:
federationapi
.
ClusterSpec
{
ServerAddressByClientCIDRs
:
[]
federationapi
.
ServerAddressByClientCIDR
{
{
ClientCIDR
:
"0.0.0.0/0"
,
ServerAddress
:
host
,
},
// Use insecure access
SecretRef
:
nil
,
},
}
fedClient
.
FederationV1beta1
()
.
Clusters
()
.
Create
(
cluster
)
// Use insecure access
SecretRef
:
nil
,
},
}
f
.
fedClient
.
FederationV1beta1
()
.
Clusters
()
.
Create
(
cluster
)
}
func
(
f
*
FederationFixture
)
TearDown
(
t
*
testing
.
T
)
{
...
...
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