Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nmaas Janitor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nmaas
nmaas Janitor
Commits
1631e55f
Commit
1631e55f
authored
6 years ago
by
Michał Bień
Browse files
Options
Downloads
Patches
Plain Diff
Added janitor tests part 2
parent
381ff806
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pkg/service/v1/config-service_test.go
+41
-8
41 additions, 8 deletions
pkg/service/v1/config-service_test.go
with
41 additions
and
8 deletions
pkg/service/v1/config-service_test.go
+
41
−
8
View file @
1631e55f
...
@@ -3,8 +3,8 @@ package v1
...
@@ -3,8 +3,8 @@ package v1
import
(
import
(
"code.geant.net/stash/scm/nmaas/nmaas-janitor/pkg/api/v1"
"code.geant.net/stash/scm/nmaas/nmaas-janitor/pkg/api/v1"
"context"
"context"
extension
"k8s.io/api/extensions/v1beta1"
corev1
"k8s.io/api/core/v1"
corev1
"k8s.io/api/core/v1"
v12
"k8s.io/apimachinery/pkg/apis/meta/v1"
"testing"
"testing"
testclient
"k8s.io/client-go/kubernetes/fake"
testclient
"k8s.io/client-go/kubernetes/fake"
)
)
...
@@ -40,12 +40,6 @@ func TestReadinessServiceServer_CheckIfReady(t *testing.T) {
...
@@ -40,12 +40,6 @@ func TestReadinessServiceServer_CheckIfReady(t *testing.T) {
t
.
Fail
()
t
.
Fail
()
}
}
_
,
_
=
client
.
CoreV1
()
.
Namespaces
()
.
Create
(
&
corev1
.
Namespace
{
ObjectMeta
:
v12
.
ObjectMeta
{
Name
:
"test-namespace"
,
},
})
//Fail on namespace check
//Fail on namespace check
freq
:=
v1
.
InstanceRequest
{
Api
:
apiVersion
,
Deployment
:&
fake_ns_inst
}
freq
:=
v1
.
InstanceRequest
{
Api
:
apiVersion
,
Deployment
:&
fake_ns_inst
}
res
,
err
=
server
.
CheckIfReady
(
context
.
Background
(),
&
freq
)
res
,
err
=
server
.
CheckIfReady
(
context
.
Background
(),
&
freq
)
...
@@ -53,15 +47,54 @@ func TestReadinessServiceServer_CheckIfReady(t *testing.T) {
...
@@ -53,15 +47,54 @@ func TestReadinessServiceServer_CheckIfReady(t *testing.T) {
t
.
Fail
()
t
.
Fail
()
}
}
//create mock namespace
ns
:=
corev1
.
Namespace
{}
ns
.
Name
=
"test-namespace"
_
,
_
=
client
.
CoreV1
()
.
Namespaces
()
.
Create
(
&
ns
)
//Fail on deployment
//Fail on deployment
res
,
err
=
server
.
CheckIfReady
(
context
.
Background
(),
&
req
)
if
err
==
nil
||
res
.
Status
!=
v1
.
Status_FAILED
{
t
.
Fail
()
}
//create mock deployment
depl
:=
extension
.
Deployment
{}
depl
.
Name
=
"test-uid"
q
:=
int32
(
5
)
depl
.
Spec
.
Replicas
=
&
q
depl
.
Status
.
Replicas
=
q
_
,
_
=
client
.
ExtensionsV1beta1
()
.
Deployments
(
"test-namespace"
)
.
Create
(
&
depl
)
}
}
func
TestCertManagerServiceServer_DeleteIfExists
(
t
*
testing
.
T
)
{
func
TestCertManagerServiceServer_DeleteIfExists
(
t
*
testing
.
T
)
{
server
:=
NewCertManagerServiceServer
(
testclient
.
NewSimpleClientset
())
client
:=
testclient
.
NewSimpleClientset
()
server
:=
NewCertManagerServiceServer
(
client
)
//Fail on API version check
res
,
err
:=
server
.
DeleteIfExists
(
context
.
Background
(),
&
illegal_req
)
res
,
err
:=
server
.
DeleteIfExists
(
context
.
Background
(),
&
illegal_req
)
if
err
==
nil
||
res
!=
nil
{
if
err
==
nil
||
res
!=
nil
{
t
.
Fail
()
t
.
Fail
()
}
}
//Fail on namespace check
freq
:=
v1
.
InstanceRequest
{
Api
:
apiVersion
,
Deployment
:&
fake_ns_inst
}
res
,
err
=
server
.
DeleteIfExists
(
context
.
Background
(),
&
freq
)
if
err
==
nil
||
res
.
Status
!=
v1
.
Status_FAILED
{
t
.
Fail
()
}
//create mock namespace
ns
:=
corev1
.
Namespace
{}
ns
.
Name
=
"test-namespace"
_
,
_
=
client
.
CoreV1
()
.
Namespaces
()
.
Create
(
&
ns
)
//Pass if already nonexistent
res
,
err
=
server
.
DeleteIfExists
(
context
.
Background
(),
&
req
)
if
err
!=
nil
||
res
.
Status
!=
v1
.
Status_OK
{
t
.
Fail
()
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment