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
caf2411f
Commit
caf2411f
authored
Sep 07, 2016
by
Maciej Kwiek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PetSet replica count status test
parent
5d218f93
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
2 deletions
+54
-2
pet_set_test.go
pkg/controller/petset/pet_set_test.go
+54
-2
No files found.
pkg/controller/petset/pet_set_test.go
View file @
caf2411f
...
...
@@ -25,6 +25,9 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/apps"
"k8s.io/kubernetes/pkg/client/cache"
fake_internal
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/apps/unversioned"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/apps/unversioned/fake"
"k8s.io/kubernetes/pkg/controller"
"k8s.io/kubernetes/pkg/util/errors"
)
...
...
@@ -268,8 +271,7 @@ func TestPetSetBlockingPetIsCleared(t *testing.T) {
}
}
// TODO(mkwiek): test if the petset.Status.Replicas is actually correct
func
TestPetSetReplicaCount
(
t
*
testing
.
T
)
{
func
TestSyncPetSetBlockedPet
(
t
*
testing
.
T
)
{
psc
,
fc
:=
newFakePetSetController
()
ps
:=
newPetSet
(
3
)
i
,
_
:=
psc
.
syncPetSet
(
ps
,
fc
.
getPodList
())
...
...
@@ -277,3 +279,53 @@ func TestPetSetReplicaCount(t *testing.T) {
t
.
Errorf
(
"syncPetSet should return actual amount of pods"
)
}
}
type
fakeClient
struct
{
fake_internal
.
Clientset
petSetClient
*
fakePetSetClient
}
func
(
c
*
fakeClient
)
Apps
()
unversioned
.
AppsInterface
{
return
&
fakeApps
{
c
,
&
fake
.
FakeApps
{}}
}
type
fakeApps
struct
{
*
fakeClient
*
fake
.
FakeApps
}
func
(
c
*
fakeApps
)
PetSets
(
namespace
string
)
unversioned
.
PetSetInterface
{
c
.
petSetClient
.
Namespace
=
namespace
return
c
.
petSetClient
}
type
fakePetSetClient
struct
{
*
fake
.
FakePetSets
Namespace
string
replicas
int
}
func
(
f
*
fakePetSetClient
)
UpdateStatus
(
petSet
*
apps
.
PetSet
)
(
*
apps
.
PetSet
,
error
)
{
f
.
replicas
=
petSet
.
Status
.
Replicas
return
petSet
,
nil
}
func
TestPetSetReplicaCount
(
t
*
testing
.
T
)
{
fpsc
:=
&
fakePetSetClient
{}
psc
,
_
:=
newFakePetSetController
()
psc
.
kubeClient
=
&
fakeClient
{
petSetClient
:
fpsc
,
}
ps
:=
newPetSet
(
3
)
psKey
:=
fmt
.
Sprintf
(
"%v/%v"
,
ps
.
Namespace
,
ps
.
Name
)
psc
.
psStore
.
Store
.
Add
(
ps
)
if
err
:=
psc
.
Sync
(
psKey
);
err
!=
nil
{
t
.
Errorf
(
"Error during sync of deleted petset %v"
,
err
)
}
if
fpsc
.
replicas
!=
1
{
t
.
Errorf
(
"Replicas count sent as status update for PetSet should be 1, is %d instead"
,
fpsc
.
replicas
)
}
}
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