Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frontend-clients
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OZG-Cloud
app
frontend-clients
Commits
6188f82b
Commit
6188f82b
authored
1 year ago
by
OZGCloud
Browse files
Options
Downloads
Patches
Plain Diff
e2e use danymic ports for mongodb port forward
parent
e9478854
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
alfa-client/apps/alfa-e2e/Jenkinsfile
+35
-14
35 additions, 14 deletions
alfa-client/apps/alfa-e2e/Jenkinsfile
with
35 additions
and
14 deletions
alfa-client/apps/alfa-e2e/Jenkinsfile
+
35
−
14
View file @
6188f82b
...
...
@@ -218,11 +218,12 @@ pipeline {
catchError
(
buildResult:
'FAILURE'
,
stageResult:
'FAILURE'
)
{
script
{
def
bezeichner
=
env
.
EA_BEZEICHNER
def
dbPort
=
27018
forwardServices
(
generateNamespace
(
bezeichner
)
,
dbPort
)
Integer
mongoDbPort
=
forwardMongoDbPort
(
generateNamespace
(
bezeichner
))
runTests
(
bezeichner
,
'einheitlicher-ansprechpartner'
,
'user-ea'
,
dbPort
,
env
.
STAGE_NAME
)
runTests
(
bezeichner
,
'einheitlicher-ansprechpartner'
,
'user-ea'
,
mongoDbPort
,
env
.
STAGE_NAME
)
stopForwardMongoDbPort
(
generateNamespace
(
bezeichner
))
}
}
}
...
...
@@ -242,17 +243,18 @@ pipeline {
stage
(
'E2E-Main'
)
{
when
{
expression
{
SKIP_RUN
}
expression
{
!
SKIP_RUN
}
}
steps
{
catchError
(
buildResult:
'FAILURE'
,
stageResult:
'FAILURE'
)
{
script
{
def
bezeichner
=
env
.
MAIN_BEZEICHNER
def
dbPort
=
27019
forwardServices
(
generateNamespace
(
bezeichner
)
,
dbPort
)
Integer
mongoDbPort
=
forwardMongoDbPort
(
generateNamespace
(
bezeichner
))
runTests
(
bezeichner
,
'main-tests'
,
'user-main'
,
dbPort
,
env
.
STAGE_NAME
)
runTests
(
bezeichner
,
'main-tests'
,
'user-main'
,
mongoDbPort
,
env
.
STAGE_NAME
)
stopForwardMongoDbPort
(
generateNamespace
(
bezeichner
))
}
}
}
...
...
@@ -772,16 +774,39 @@ Map getElasticsearchEnv(String namespace) {
]
}
Void
forward
Services
(
String
namespace
,
Integer
dbPort
)
{
Void
forward
MongoDbPort
(
String
namespace
)
{
try
{
forwardDatenbank
(
namespace
,
dbPort
)
def
minPort
=
20000
def
portRange
=
20000
//def dbPort = "${Math.abs(new Random().nextInt(portRange+1))+minPort}" as Integer
def
dbPort
=
Math
.
abs
(
new
Random
().
nextInt
(
portRange
+
1
))+
minPort
echo
"Forwarding MongoDB Port to local port ${dbPort}"
def
pidFile
=
generateMongoDbPortForwardPidFile
(
namespace
)
sh
"kubectl port-forward ozg-mongodb-0 ${dbPort}:27017 -n ${namespace} & echo \$! > ${pidFile}"
return
dbPort
}
catch
(
Exception
e
)
{
echo
"forward
Services
Exception: ${e}"
echo
"forward
MongoDbPort
Exception: ${e}"
error
(
"Error forwarding service"
)
}
}
Void
stopForwardMongoDbPort
(
String
namespace
)
{
echo
"Removing forwarding MongoDB Port to local port for ${namespace}"
def
pidFile
=
generateMongoDbPortForwardPidFile
(
namespace
)
dir
(
'alfa-client/apps/alfa-e2e/src/jenkins-build-files'
)
{
sh
"./kill-pid-by-filename.sh ${pidFile}"
}
}
Void
generateMongoDbPortForwardPidFile
(
String
namespace
)
{
return
"/tmp/pid_file_mongodb_port_forward_${namespace}.pid"
}
Void
forwardElasticSearch
()
{
if
(!
isElasticSearchForwarded
())
{
sh
"kubectl port-forward ozg-search-cluster-es-ozg-search-0 9200:9200 -n elastic-system &"
...
...
@@ -792,10 +817,6 @@ Boolean isElasticSearchForwarded() {
return
sh
(
script:
"lsof -i -P -n | grep LISTEN | grep :9200"
,
returnStatus:
true
)
==
env
.
SH_SUCCESS_STATUS_CODE
as
Integer
}
Void
forwardDatenbank
(
String
namespace
,
port
)
{
sh
"kubectl port-forward ozg-mongodb-0 ${port}:27017 -n ${namespace} &"
}
String
generateNamespace
(
String
bezeichner
)
{
return
"${env.BUNDESLAND}-${bezeichner}-dev"
}
...
...
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