Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
goSDN
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
danet
goSDN
Commits
a33003b6
Commit
a33003b6
authored
4 years ago
by
Manuel Kieweg
Browse files
Options
Downloads
Patches
Plain Diff
get k8s coordinated from k8s bot
parent
0783cfc9
No related branches found
No related tags found
1 merge request
!159
Resolve "Integration Tests Fail"
Pipeline
#73951
passed with warnings
4 years ago
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
build/cd/deploy.go
+34
-0
34 additions, 0 deletions
build/cd/deploy.go
build/ci/.test.yml
+9
-2
9 additions, 2 deletions
build/ci/.test.yml
test/integration/cmdIntegration_test.go
+6
-3
6 additions, 3 deletions
test/integration/cmdIntegration_test.go
with
49 additions
and
5 deletions
build/cd/deploy.go
+
34
−
0
View file @
a33003b6
...
@@ -3,9 +3,11 @@ package main
...
@@ -3,9 +3,11 @@ package main
import
(
import
(
"context"
"context"
"os"
"os"
"strconv"
nucleus
"code.fbi.h-da.de/cocsn/gosdn/nucleus/errors"
nucleus
"code.fbi.h-da.de/cocsn/gosdn/nucleus/errors"
log
"github.com/sirupsen/logrus"
log
"github.com/sirupsen/logrus"
"github.com/spf13/viper"
appv1
"k8s.io/api/apps/v1"
appv1
"k8s.io/api/apps/v1"
corev1
"k8s.io/api/core/v1"
corev1
"k8s.io/api/core/v1"
netv1
"k8s.io/api/networking/v1"
netv1
"k8s.io/api/networking/v1"
...
@@ -52,11 +54,42 @@ func main() {
...
@@ -52,11 +54,42 @@ func main() {
if
err
:=
remove
(
clientset
,
tag
);
err
!=
nil
{
if
err
:=
remove
(
clientset
,
tag
);
err
!=
nil
{
log
.
Fatal
(
err
)
log
.
Fatal
(
err
)
}
}
case
"getenv"
:
if
err
:=
getenv
(
clientset
,
tag
);
err
!=
nil
{
log
.
Fatal
(
err
)
}
default
:
default
:
log
.
Fatal
(
"invalid option"
)
log
.
Fatal
(
"invalid option"
)
}
}
}
}
func
getenv
(
clientset
*
kubernetes
.
Clientset
,
tag
string
)
error
{
env
:=
"gosdn-"
+
tag
opts
:=
metav1
.
GetOptions
{}
ctx
:=
context
.
Background
()
service
,
err
:=
clientset
.
CoreV1
()
.
Services
(
"cocsn"
)
.
Get
(
ctx
,
env
,
opts
)
if
err
!=
nil
{
return
err
}
var
ip
string
for
_
,
ingress
:=
range
service
.
Status
.
LoadBalancer
.
Ingress
{
ip
=
ingress
.
IP
}
var
port
string
for
_
,
p
:=
range
service
.
Spec
.
Ports
{
if
p
.
Name
==
"grpc"
{
port
=
strconv
.
Itoa
(
int
(
p
.
NodePort
))
}
}
log
.
WithFields
(
log
.
Fields
{
"ip"
:
ip
,
"port"
:
port
,
})
.
Info
(
env
)
viper
.
Set
(
"GOSDN_TEST_API_ENDPOINT"
,
ip
+
":"
+
port
)
return
viper
.
SafeWriteConfigAs
(
".k8s.toml"
)
}
// nolint
// nolint
func
create
(
clientset
*
kubernetes
.
Clientset
,
tag
string
)
error
{
func
create
(
clientset
*
kubernetes
.
Clientset
,
tag
string
)
error
{
env
:=
"gosdn-"
+
tag
env
:=
"gosdn-"
+
tag
...
@@ -82,6 +115,7 @@ func create(clientset *kubernetes.Clientset, tag string) error {
...
@@ -82,6 +115,7 @@ func create(clientset *kubernetes.Clientset, tag string) error {
}
else
{
}
else
{
log
.
Printf
(
"service %v created"
,
service
.
Name
)
log
.
Printf
(
"service %v created"
,
service
.
Name
)
}
}
_
,
err
=
clientset
.
CoreV1
()
.
ConfigMaps
(
"cocsn"
)
.
Create
(
ctx
,
config
,
opts
)
_
,
err
=
clientset
.
CoreV1
()
.
ConfigMaps
(
"cocsn"
)
.
Create
(
ctx
,
config
,
opts
)
if
err
!=
nil
{
if
err
!=
nil
{
switch
err
.
(
type
)
{
switch
err
.
(
type
)
{
...
...
This diff is collapsed.
Click to expand it.
build/ci/.test.yml
+
9
−
2
View file @
a33003b6
...
@@ -4,8 +4,6 @@
...
@@ -4,8 +4,6 @@
needs
:
needs
:
-
job
:
"
apply"
-
job
:
"
apply"
-
job
:
"
deploy:integration-test"
-
job
:
"
deploy:integration-test"
variables
:
GOSDN_TEST_API_ENDPOINT
:
gosdn-$CI_COMMIT_SHA.apps.ocp.fbi.h-da.de:80
rules
:
rules
:
-
if
:
$CI_NIGHTLY
-
if
:
$CI_NIGHTLY
when
:
delayed
when
:
delayed
...
@@ -29,8 +27,17 @@ integration-test:nucleus:
...
@@ -29,8 +27,17 @@ integration-test:nucleus:
integration-test:cmd
:
integration-test:cmd
:
<<
:
*integration-test
<<
:
*integration-test
variables
:
K8S_OP
:
"
getenv"
needs
:
-
job
:
"
build:merge-request"
-
job
:
"
apply"
-
job
:
"
deploy:integration-test"
-
job
:
"
build:k8s-bot"
artifacts
:
true
script
:
script
:
-
cd ./test/integration
-
cd ./test/integration
-
./../build/cd/k8s-bot
-
go test -race -v -run TestCmdIntegration
-
go test -race -v -run TestCmdIntegration
integration-test:cli
:
integration-test:cli
:
...
...
This diff is collapsed.
Click to expand it.
test/integration/cmdIntegration_test.go
+
6
−
3
View file @
a33003b6
...
@@ -30,6 +30,11 @@ func TestMain(m *testing.M) {
...
@@ -30,6 +30,11 @@ func TestMain(m *testing.M) {
}
}
func
testSetupIntegration
()
{
func
testSetupIntegration
()
{
viper
.
SetConfigFile
(
".k8s.toml"
)
if
err
:=
viper
.
ReadInConfig
();
err
!=
nil
{
log
.
Fatal
(
err
)
}
if
os
.
Getenv
(
"GOSDN_LOG"
)
==
"nolog"
{
if
os
.
Getenv
(
"GOSDN_LOG"
)
==
"nolog"
{
log
.
SetLevel
(
log
.
PanicLevel
)
log
.
SetLevel
(
log
.
PanicLevel
)
}
}
...
@@ -39,7 +44,7 @@ func testSetupIntegration() {
...
@@ -39,7 +44,7 @@ func testSetupIntegration() {
testAddress
=
a
testAddress
=
a
log
.
Infof
(
"GOSDN_TEST_ENDPOINT set to %v"
,
testAddress
)
log
.
Infof
(
"GOSDN_TEST_ENDPOINT set to %v"
,
testAddress
)
}
}
api
:=
os
.
Getenv
(
"GOSDN_TEST_API_ENDPOINT
"
)
api
:=
viper
.
GetString
(
"gosdn_test_api_endpoint
"
)
if
api
!=
""
{
if
api
!=
""
{
testAPIEndpoint
=
api
testAPIEndpoint
=
api
log
.
Infof
(
"GOSDN_TEST_API_ENDPOINT set to %v"
,
testAPIEndpoint
)
log
.
Infof
(
"GOSDN_TEST_API_ENDPOINT set to %v"
,
testAPIEndpoint
)
...
@@ -83,8 +88,6 @@ func testSetupIntegration() {
...
@@ -83,8 +88,6 @@ func testSetupIntegration() {
}
}
func
TestCmdIntegration
(
t
*
testing
.
T
)
{
func
TestCmdIntegration
(
t
*
testing
.
T
)
{
// TDOO: Remove once openshift grpc support is available
t
.
Skip
(
"skipped due to openshift limitations"
)
if
testing
.
Short
()
{
if
testing
.
Short
()
{
t
.
Skip
(
"skipping integration test"
)
t
.
Skip
(
"skipping integration test"
)
}
}
...
...
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