Skip to content

Commit

Permalink
Improvements in the .env Jenkinsfiles and all the scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
augustocristian committed Feb 17, 2024
1 parent 3c8d2b7 commit 50ba6cc
Show file tree
Hide file tree
Showing 8 changed files with 151 additions and 64 deletions.
156 changes: 120 additions & 36 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,45 +31,80 @@ pipeline {
stage('TJobC IdResource: Attenders LoginService OpenViduMock ') {
steps {
catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') {
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-setup.sh tjobc 0'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-testexecution.sh tjobc 0 https://full-teaching- 5000 "FullTeachingEndToEndRESTTests#attendersRestOperations"'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-teardown.sh tjobc 0'
script {
try{
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-setup.sh tjobc 0'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-testexecution.sh tjobc 0 https://full-teaching- 5000 "FullTeachingEndToEndRESTTests#attendersRestOperations"'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-teardown.sh tjobc 0'
} catch (err) {
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-teardown.sh tjobc 0'
throw err
} // EndCatch
} // EndScript
}// EndExecutionStageErrorTJobC
}// EndStepsTJobC
}// EndStageTJobC
stage('TJobD IdResource: Configuration LoginService OpenViduMock ') {
steps {
catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') {
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-setup.sh tjobd 0'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-testexecution.sh tjobd 0 https://full-teaching- 5000 "FullTeachingEndToEndRESTTests#courseRestOperations,CourseTeacherTest#teacherEditCourseValues"'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-teardown.sh tjobd 0'
script {
try{
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-setup.sh tjobd 0'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-testexecution.sh tjobd 0 https://full-teaching- 5000 "FullTeachingEndToEndRESTTests#courseRestOperations,CourseTeacherTest#teacherEditCourseValues"'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-teardown.sh tjobd 0'
} catch (err) {
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-teardown.sh tjobd 0'
throw err
} // EndCatch
} // EndScript
}// EndExecutionStageErrorTJobD
}// EndStepsTJobD
}// EndStageTJobD
stage('TJobE IdResource: Configuration LoginService OpenVidu ') {
steps {
catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') {
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-setup.sh tjobe 0'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-testexecution.sh tjobe 0 https://full-teaching- 5000 "FullTeachingEndToEndEChatTests#oneToOneChatInSessionChrome"'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-teardown.sh tjobe 0'
script {
try{
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-setup.sh tjobe 0'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-testexecution.sh tjobe 0 https://full-teaching- 5000 "FullTeachingEndToEndEChatTests#oneToOneChatInSessionChrome"'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-teardown.sh tjobe 0'
} catch (err) {
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-teardown.sh tjobe 0'
throw err
} // EndCatch
} // EndScript
}// EndExecutionStageErrorTJobE
}// EndStepsTJobE
}// EndStageTJobE
stage('TJobF IdResource: Course LoginService OpenViduMock ') {
steps {
catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') {
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-setup.sh tjobf 0'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-testexecution.sh tjobf 0 https://full-teaching- 5000 "LoggedLinksTests#spiderLoggedTest,UnLoggedLinksTests#spiderUnloggedTest,CourseTeacherTest#teacherDeleteCourseTest"'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-teardown.sh tjobf 0'
script {
try{
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-setup.sh tjobf 0'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-testexecution.sh tjobf 0 https://full-teaching- 5000 "LoggedLinksTests#spiderLoggedTest,UnLoggedLinksTests#spiderUnloggedTest,CourseTeacherTest#teacherDeleteCourseTest"'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-teardown.sh tjobf 0'
} catch (err) {
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-teardown.sh tjobf 0'
throw err
} // EndCatch
} // EndScript
}// EndExecutionStageErrorTJobF
}// EndStepsTJobF
}// EndStageTJobF
stage('TJobG IdResource: Course LoginService OpenViduMock ') {
steps {
catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') {
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-setup.sh tjobg 0'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-testexecution.sh tjobg 0 https://full-teaching- 5000 "CourseStudentTest#studentCourseMainTest,CourseTeacherTest#teacherCourseMainTest,CourseTeacherTest#teacherCreateAndDeleteCourseTest"'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-teardown.sh tjobg 0'
script {
try{
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-setup.sh tjobg 0'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-testexecution.sh tjobg 0 https://full-teaching- 5000 "CourseStudentTest#studentCourseMainTest,CourseTeacherTest#teacherCourseMainTest,CourseTeacherTest#teacherCreateAndDeleteCourseTest"'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-teardown.sh tjobg 0'
} catch (err) {
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-teardown.sh tjobg 0'
throw err
} // EndCatch
} // EndScript
}// EndExecutionStageErrorTJobG
}// EndStepsTJobG
}// EndStageTJobG
Expand All @@ -81,45 +116,80 @@ pipeline {
stage('TJobH IdResource: Information LoginService OpenViduMock ') {
steps {
catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') {
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-setup.sh tjobh 1'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-testexecution.sh tjobh 1 https://full-teaching- 5000 "FullTeachingEndToEndRESTTests#courseInfoRestOperations"'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-teardown.sh tjobh 1'
script {
try{
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-setup.sh tjobh 1'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-testexecution.sh tjobh 1 https://full-teaching- 5000 "FullTeachingEndToEndRESTTests#courseInfoRestOperations"'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-teardown.sh tjobh 1'
} catch (err) {
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-teardown.sh tjobh 1'
throw err
} // EndCatch
} // EndScript
}// EndExecutionStageErrorTJobH
}// EndStepsTJobH
}// EndStageTJobH
stage('TJobI IdResource: Files LoginService OpenViduMock ') {
steps {
catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') {
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-setup.sh tjobi 1'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-testexecution.sh tjobi 1 https://full-teaching- 5000 "FullTeachingEndToEndRESTTests#filesRestOperations"'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-teardown.sh tjobi 1'
script {
try{
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-setup.sh tjobi 1'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-testexecution.sh tjobi 1 https://full-teaching- 5000 "FullTeachingEndToEndRESTTests#filesRestOperations"'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-teardown.sh tjobi 1'
} catch (err) {
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-teardown.sh tjobi 1'
throw err
} // EndCatch
} // EndScript
}// EndExecutionStageErrorTJobI
}// EndStepsTJobI
}// EndStageTJobI
stage('TJobJ IdResource: Forum LoginService OpenViduMock ') {
steps {
catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') {
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-setup.sh tjobj 1'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-testexecution.sh tjobj 1 https://full-teaching- 5000 "LoggedForumTest#forumLoadEntriesTest"'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-teardown.sh tjobj 1'
script {
try{
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-setup.sh tjobj 1'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-testexecution.sh tjobj 1 https://full-teaching- 5000 "LoggedForumTest#forumLoadEntriesTest"'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-teardown.sh tjobj 1'
} catch (err) {
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-teardown.sh tjobj 1'
throw err
} // EndCatch
} // EndScript
}// EndExecutionStageErrorTJobJ
}// EndStepsTJobJ
}// EndStageTJobJ
stage('TJobK IdResource: Forum LoginService OpenViduMock ') {
steps {
catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') {
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-setup.sh tjobk 1'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-testexecution.sh tjobk 1 https://full-teaching- 5000 "LoggedForumTest#forumNewCommentTest,LoggedForumTest#forumNewEntryTest,LoggedForumTest#forumNewReply2CommentTest,FullTeachingEndToEndRESTTests#forumRestOperations"'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-teardown.sh tjobk 1'
script {
try{
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-setup.sh tjobk 1'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-testexecution.sh tjobk 1 https://full-teaching- 5000 "LoggedForumTest#forumNewCommentTest,LoggedForumTest#forumNewEntryTest,LoggedForumTest#forumNewReply2CommentTest,FullTeachingEndToEndRESTTests#forumRestOperations"'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-teardown.sh tjobk 1'
} catch (err) {
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-teardown.sh tjobk 1'
throw err
} // EndCatch
} // EndScript
}// EndExecutionStageErrorTJobK
}// EndStepsTJobK
}// EndStageTJobK
stage('TJobL IdResource: LoginService OpenViduMock ') {
steps {
catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') {
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-setup.sh tjobl 1'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-testexecution.sh tjobl 1 https://full-teaching- 5000 "UserTest#loginTest"'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-teardown.sh tjobl 1'
script {
try{
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-setup.sh tjobl 1'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-testexecution.sh tjobl 1 https://full-teaching- 5000 "UserTest#loginTest"'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-teardown.sh tjobl 1'
} catch (err) {
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-teardown.sh tjobl 1'
throw err
} // EndCatch
} // EndScript
}// EndExecutionStageErrorTJobL
}// EndStepsTJobL
}// EndStageTJobL
Expand All @@ -131,18 +201,32 @@ pipeline {
stage('TJobM IdResource: Session LoginService OpenVidu ') {
steps {
catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') {
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-setup.sh tjobm 2'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-testexecution.sh tjobm 2 https://full-teaching- 5000 "FullTeachingTestEndToEndVideoSessionTests#oneToOneVideoAudioSessionChrome,FullTeachingLoggedVideoSessionTests#sessionTest"'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-teardown.sh tjobm 2'
script {
try{
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-setup.sh tjobm 2'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-testexecution.sh tjobm 2 https://full-teaching- 5000 "FullTeachingTestEndToEndVideoSessionTests#oneToOneVideoAudioSessionChrome,FullTeachingLoggedVideoSessionTests#sessionTest"'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-teardown.sh tjobm 2'
} catch (err) {
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-teardown.sh tjobm 2'
throw err
} // EndCatch
} // EndScript
}// EndExecutionStageErrorTJobM
}// EndStepsTJobM
}// EndStageTJobM
stage('TJobN IdResource: Session LoginService OpenViduMock ') {
steps {
catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') {
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-setup.sh tjobn 2'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-testexecution.sh tjobn 2 https://full-teaching- 5000 "FullTeachingEndToEndRESTTests#sessionRestOperations"'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-teardown.sh tjobn 2'
script {
try{
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-setup.sh tjobn 2'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-testexecution.sh tjobn 2 https://full-teaching- 5000 "FullTeachingEndToEndRESTTests#sessionRestOperations"'
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-teardown.sh tjobn 2'
} catch (err) {
sh '$SCRIPTS_FOLDER/tjoblifecycles/tjob-teardown.sh tjobn 2'
throw err
} // EndCatch
} // EndScript
}// EndExecutionStageErrorTJobN
}// EndStepsTJobN
}// EndStageTJobN
Expand Down
28 changes: 14 additions & 14 deletions retorchfiles/scripts/coilifecycles/coi-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ SEL_LOG_DIR="/opt/selenoid/logs/"

# Function to remove older files
remove_old_files() {
dir=$1
days=$2
echo "Removing older files ($days days) in $dir! The number of files prior to remove:"
find "$dir" | wc -l
find "$dir" -mindepth 1 -maxdepth 1 -mtime +$days -exec rm -rf {} \;
echo "Removing older files ($days days) in $dir! The number of files after remove:"
find "$dir" | wc -l
dir=$1
days=$2
echo "Removing older files ($days days) in $dir! The number of files prior to remove:"
find "$dir" | wc -l
find "$dir" -mindepth 1 -maxdepth 1 -mtime +$days -exec rm -rf {} \;
echo "Removing older files ($days days) in $dir! The number of files after remove:"
find "$dir" | wc -l
}

# Set output directory for COI
Expand All @@ -34,9 +34,9 @@ mkdir -p "$SUT_LOCATION/tmp"
# Pull Docker images
echo "Pulling images"
if docker pull selenoid/vnc_chrome:116.0 && docker pull selenoid/video-recorder:latest-release; then
echo "Images pulled successfully."
echo "Images pulled successfully."
else
echo "Failed to pull Docker images."
echo "Failed to pull Docker images."
fi

echo "Building images of SUT"
Expand All @@ -47,15 +47,15 @@ docker compose -f "docker-compose.yml" --env-file "$WORKSPACE/retorchfiles/envfi

# Check the exit status of the last command
if [ $? -eq 0 ]; then
echo "Images for SUT"
echo "Images for SUT"
else
echo "Failed to build images of SUT"
exit 1
echo "Failed to build images of SUT"
exit 1
fi

# Record end time for COI setup
COISETUPEND=$(date +%s%3N)

# Write setup timestamps to output file
echo "COI-SETUP-START;COI-SETUP-END;COI-TEARDOWN-START;COI-TEARDOWN-END" > "$OUTPUTDIRCOI"
echo -n "$COISETUPSTART;$COISETUPEND" >> "$OUTPUTDIRCOI"
echo "COI-SETUP-START;COI-SETUP-END;COI-TEARDOWN-START;COI-TEARDOWN-END" >"$OUTPUTDIRCOI"
echo -n "$COISETUPSTART;$COISETUPEND" >>"$OUTPUTDIRCOI"
4 changes: 2 additions & 2 deletions retorchfiles/scripts/coilifecycles/coi-teardown.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
set -e # Exit immediately if any command exits with a non-zero status
set -e # Exit immediately if any command exits with a non-zero status

COITEARDOWNSTART="$(date +%s%3N)"

Expand All @@ -16,6 +16,6 @@ sh "$SCRIPTS_FOLDER/savetjoblifecycledata.sh"
COITEARDOWNEND="$(date +%s%3N)"

OUTPUTDIRCOI="$WORKSPACE/retorchcostestimationdata/exec$BUILD_NUMBER/COI.data"
echo -n ";$COITEARDOWNSTART;$COITEARDOWNEND" >> "$OUTPUTDIRCOI"
echo -n ";$COITEARDOWNSTART;$COITEARDOWNEND" >>"$OUTPUTDIRCOI"

echo "COI teardown script completed successfully."
4 changes: 2 additions & 2 deletions retorchfiles/scripts/savetjoblifecycledata.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ set -e

# Check if the correct number of arguments is provided
if [ "$#" -ne 0 ]; then
echo "This script doesn't take any parameter"
exit 1
echo "This script doesn't take any parameter"
exit 1
fi

PATH_FILES="$WORKSPACE/retorchcostestimationdata/exec${BUILD_NUMBER}/tjob*"
Expand Down
2 changes: 1 addition & 1 deletion retorchfiles/scripts/tjoblifecycles/tjob-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set -e
DOCKER_HOST_IP=$(/sbin/ip route | awk '/default/ { print $3 }')
export DOCKER_HOST_IP
echo "Exporting the HOST_IP: $DOCKER_HOST_IP"
echo "The HOST_IP is: $DOCKER_HOST_IP"

# Custom Set-up commands
echo "Executing custom commands"

Expand Down
1 change: 0 additions & 1 deletion retorchfiles/scripts/tjoblifecycles/tjob-teardown.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,5 @@ docker compose -f docker-compose.yml --env-file "$WORKSPACE/retorchfiles/envfile
# Return to the original working directory
cd "$WORKSPACE"


# Execute the script to write timestamp again
"$SCRIPTS_FOLDER/writetime.sh" "$2" "$1"
16 changes: 10 additions & 6 deletions retorchfiles/scripts/tjoblifecycles/tjob-testexecution.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ TJOB_NAME="$1"
STAGE="$2"
PORT="$4"
TEST_NAME="$5"
if [[ $url == "https://" || $url == "http://" ]]; then
if [[ $3 == "https://" || $3 == "http://" ]]; then
echo "Only http:// || https:// protocol provided, using HOST DOCKER INTERNAL IP "
SUT_URL="$3"+DOCKER_HOST_IP
SUT_URL="$3$DOCKER_HOST_IP"
else
echo "Using the provided URL"
SUT_URL="$3"
Expand All @@ -38,15 +38,19 @@ LOCALHOST="$DOCKER_HOST_IP:$PORT"
# Run Maven test
mvn test -Ddirtarget="$TJOBNAME" -Dtest="$TEST_NAME" -Dtjob_name="$TJOB_NAME" -DSUT_URL="$SUT_URL" -DSUT_PORT="$PORT"

# Store Test result
MVN_EXIT_CODE=$?

# Execute the script to write timestamp again
EXECUTE_TIMESTAMP_SCRIPT "$STAGE" "$TJOB_NAME"

# Check if Maven test failed
if [ $? -ne 0 ]; then
echo "Maven test FAILED with exit code $?."
if [ $MVN_EXIT_CODE -ne 0 ]; then
echo "Maven test FAILED with exit code $MVN_EXIT_CODE."
exit 1 # Return 1 if the Maven test fails
fi

# If the script reaches here, the Maven test succeeded
echo "Maven test succeeded."

# Execute the script to write timestamp again
EXECUTE_TIMESTAMP_SCRIPT "$STAGE" "$TJOB_NAME"
exit 0
4 changes: 2 additions & 2 deletions retorchfiles/scripts/writetime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

# Check if the correct number of parameters is provided
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <STAGE> <TJOBNAME>"
exit 1
echo "Usage: $0 <STAGE> <TJOBNAME>"
exit 1
fi
STAGE=$2
# Constants
Expand Down

0 comments on commit 50ba6cc

Please sign in to comment.