diff --git a/Jenkinsfile b/Jenkinsfile index 5c873df..b1ef94a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,174 +1,174 @@ pipeline { - agent {label 'xretorch-agent'} + agent {label 'slave-xretorch'} environment { - ET_EUS_API = "http://selenoid:4444/wd/hub" - CURRENT_DATE = " date +\'[%m-%d-%y] %T - \'" - //Used to avoid the UnixHTTPConnectionPool(host='localhost', port=None): Read timed out and - DOCKER_CLIENT_TIMEOUT = 120 - COMPOSE_HTTP_TIMEOUT = 120 - }//EndEnvironment + SELENOID_PRESENT = "TRUE" + SUT_LOCATION = "$WORKSPACE" + SCRIPTS_FOLDER = "$WORKSPACE/retorchfiles/scripts" + }// EndEnvironment options { - disableConcurrentBuilds() - }//EndPipOptions + disableConcurrentBuilds() + }// EndPipOptions stages{ + stage('Clean Workspace') { + steps{ + cleanWs() + }// EndStepsCleanWS + }// EndStageCleanWS + stage('Clone Project') { + steps{ + checkout scm + }// EndStepsCloneProject + }// EndStageCloneProject stage('SETUP-Infrastructure') { steps{ - //Change the permisions to the scripts folder the - sh 'chmod +x -R ./retorchfiles/scripts' - sh './retorchfiles/scripts/coilifecycles/coi-setup.sh' + sh 'chmod +x -R $SCRIPTS_FOLDER' + sh '$SCRIPTS_FOLDER/coilifecycles/coi-setup.sh' }// EndStepsSETUPINF - }//EndStageSETUPInf + }// EndStageSETUPInf stage('Stage 0'){ failFast false parallel{ stage('TJobC IdResource: Attenders LoginService OpenViduMock ') { steps { catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') { - sh 'retorchfiles/scripts/tjoblifecycles/tjob-setup.sh tjobc 0' - sh 'retorchfiles/scripts/tjoblifecycles/tjob-testexecution.sh tjobc 0 "FullTeachingEndToEndRESTTests#attendersRestOperations"' - sh 'retorchfiles/scripts/tjoblifecycles/tjob-teardown.sh tjobc 0' - }//EndExecutionStageErrorTJobC - }//EndStepsTJobC - }//EndStageTJobC + 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' + }// EndExecutionStageErrorTJobC + }// EndStepsTJobC + }// EndStageTJobC stage('TJobD IdResource: Configuration LoginService OpenViduMock ') { steps { catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') { - sh 'retorchfiles/scripts/tjoblifecycles/tjob-setup.sh tjobd 0' - sh 'retorchfiles/scripts/tjoblifecycles/tjob-testexecution.sh tjobd 0 "FullTeachingEndToEndRESTTests#courseRestOperations,CourseTeacherTest#teacherEditCourseValues"' - sh 'retorchfiles/scripts/tjoblifecycles/tjob-teardown.sh tjobd 0' - }//EndExecutionStageErrorTJobD - }//EndStepsTJobD - }//EndStageTJobD + 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' + }// EndExecutionStageErrorTJobD + }// EndStepsTJobD + }// EndStageTJobD stage('TJobE IdResource: Configuration LoginService OpenVidu ') { steps { catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') { - sh 'retorchfiles/scripts/tjoblifecycles/tjob-setup.sh tjobe 0' - sh 'retorchfiles/scripts/tjoblifecycles/tjob-testexecution.sh tjobe 0 "FullTeachingEndToEndEChatTests#oneToOneChatInSessionChrome"' - sh 'retorchfiles/scripts/tjoblifecycles/tjob-teardown.sh tjobe 0' - }//EndExecutionStageErrorTJobE - }//EndStepsTJobE - }//EndStageTJobE + 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' + }// EndExecutionStageErrorTJobE + }// EndStepsTJobE + }// EndStageTJobE stage('TJobF IdResource: Course LoginService OpenViduMock ') { steps { catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') { - sh 'retorchfiles/scripts/tjoblifecycles/tjob-setup.sh tjobf 0' - sh 'retorchfiles/scripts/tjoblifecycles/tjob-testexecution.sh tjobf 0 "LoggedLinksTests#spiderLoggedTest,UnLoggedLinksTests#spiderUnloggedTest,CourseTeacherTest#teacherDeleteCourseTest"' - sh 'retorchfiles/scripts/tjoblifecycles/tjob-teardown.sh tjobf 0' - }//EndExecutionStageErrorTJobF - }//EndStepsTJobF - }//EndStageTJobF + 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' + }// EndExecutionStageErrorTJobF + }// EndStepsTJobF + }// EndStageTJobF stage('TJobG IdResource: Course LoginService OpenViduMock ') { steps { catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') { - sh 'retorchfiles/scripts/tjoblifecycles/tjob-setup.sh tjobg 0' - sh 'retorchfiles/scripts/tjoblifecycles/tjob-testexecution.sh tjobg 0 "CourseStudentTest#studentCourseMainTest,CourseTeacherTest#teacherCourseMainTest,CourseTeacherTest#teacherCreateAndDeleteCourseTest"' - sh 'retorchfiles/scripts/tjoblifecycles/tjob-teardown.sh tjobg 0' - }//EndExecutionStageErrorTJobG - }//EndStepsTJobG - }//EndStageTJobG - }//End Parallel - }//End Stage + 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' + }// EndExecutionStageErrorTJobG + }// EndStepsTJobG + }// EndStageTJobG + }// End Parallel + }// End Stage stage('Stage 1'){ failFast false parallel{ stage('TJobH IdResource: Information LoginService OpenViduMock ') { steps { catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') { - sh 'retorchfiles/scripts/tjoblifecycles/tjob-setup.sh tjobh 1' - sh 'retorchfiles/scripts/tjoblifecycles/tjob-testexecution.sh tjobh 1 "FullTeachingEndToEndRESTTests#courseInfoRestOperations"' - sh 'retorchfiles/scripts/tjoblifecycles/tjob-teardown.sh tjobh 1' - }//EndExecutionStageErrorTJobH - }//EndStepsTJobH - }//EndStageTJobH + 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' + }// EndExecutionStageErrorTJobH + }// EndStepsTJobH + }// EndStageTJobH stage('TJobI IdResource: Files LoginService OpenViduMock ') { steps { catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') { - sh 'retorchfiles/scripts/tjoblifecycles/tjob-setup.sh tjobi 1' - sh 'retorchfiles/scripts/tjoblifecycles/tjob-testexecution.sh tjobi 1 "FullTeachingEndToEndRESTTests#filesRestOperations"' - sh 'retorchfiles/scripts/tjoblifecycles/tjob-teardown.sh tjobi 1' - }//EndExecutionStageErrorTJobI - }//EndStepsTJobI - }//EndStageTJobI + 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' + }// EndExecutionStageErrorTJobI + }// EndStepsTJobI + }// EndStageTJobI stage('TJobJ IdResource: Forum LoginService OpenViduMock ') { steps { catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') { - sh 'retorchfiles/scripts/tjoblifecycles/tjob-setup.sh tjobj 1' - sh 'retorchfiles/scripts/tjoblifecycles/tjob-testexecution.sh tjobj 1 "LoggedForumTest#forumLoadEntriesTest"' - sh 'retorchfiles/scripts/tjoblifecycles/tjob-teardown.sh tjobj 1' - }//EndExecutionStageErrorTJobJ - }//EndStepsTJobJ - }//EndStageTJobJ + 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' + }// EndExecutionStageErrorTJobJ + }// EndStepsTJobJ + }// EndStageTJobJ stage('TJobK IdResource: Forum LoginService OpenViduMock ') { steps { catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') { - sh 'retorchfiles/scripts/tjoblifecycles/tjob-setup.sh tjobk 1' - sh 'retorchfiles/scripts/tjoblifecycles/tjob-testexecution.sh tjobk 1 "LoggedForumTest#forumNewCommentTest,LoggedForumTest#forumNewEntryTest,LoggedForumTest#forumNewReply2CommentTest,FullTeachingEndToEndRESTTests#forumRestOperations"' - sh 'retorchfiles/scripts/tjoblifecycles/tjob-teardown.sh tjobk 1' - }//EndExecutionStageErrorTJobK - }//EndStepsTJobK - }//EndStageTJobK + 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' + }// EndExecutionStageErrorTJobK + }// EndStepsTJobK + }// EndStageTJobK stage('TJobL IdResource: LoginService OpenViduMock ') { steps { catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') { - sh 'retorchfiles/scripts/tjoblifecycles/tjob-setup.sh tjobl 1' - sh 'retorchfiles/scripts/tjoblifecycles/tjob-testexecution.sh tjobl 1 "UserTest#loginTest"' - sh 'retorchfiles/scripts/tjoblifecycles/tjob-teardown.sh tjobl 1' - }//EndExecutionStageErrorTJobL - }//EndStepsTJobL - }//EndStageTJobL - }//End Parallel - }//End Stage + 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' + }// EndExecutionStageErrorTJobL + }// EndStepsTJobL + }// EndStageTJobL + }// End Parallel + }// End Stage stage('Stage 2'){ failFast false parallel{ stage('TJobM IdResource: Session LoginService OpenVidu ') { steps { catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') { - sh 'retorchfiles/scripts/tjoblifecycles/tjob-setup.sh tjobm 2' - sh 'retorchfiles/scripts/tjoblifecycles/tjob-testexecution.sh tjobm 2 "FullTeachingTestEndToEndVideoSessionTests#oneToOneVideoAudioSessionChrome,FullTeachingLoggedVideoSessionTests#sessionTest"' - sh 'retorchfiles/scripts/tjoblifecycles/tjob-teardown.sh tjobm 2' - }//EndExecutionStageErrorTJobM - }//EndStepsTJobM - }//EndStageTJobM + 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' + }// EndExecutionStageErrorTJobM + }// EndStepsTJobM + }// EndStageTJobM stage('TJobN IdResource: Session LoginService OpenViduMock ') { steps { catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') { - sh 'retorchfiles/scripts/tjoblifecycles/tjob-setup.sh tjobn 2' - sh 'retorchfiles/scripts/tjoblifecycles/tjob-testexecution.sh tjobn 2 "FullTeachingEndToEndRESTTests#sessionRestOperations"' - sh 'retorchfiles/scripts/tjoblifecycles/tjob-teardown.sh tjobn 2' - }//EndExecutionStageErrorTJobN - }//EndStepsTJobN - }//EndStageTJobN - }//End Parallel - }//End Stage - stage('TEARDOWN-Infrastructure'){ - stages{ - stage('PublishReports'){ - steps{ - sh 'retorchfiles/scripts/coilifecycles/coi-teardown.sh' - sh 'retorchfiles/scripts/saveTJobLifecycledata.sh' - publishHTML (target : [allowMissing: false, - alwaysLinkToLastBuild: true, - keepAll: true, - reportDir: 'target/site/', - reportFiles: 'surefire-report.html', - reportName: 'Test Execution Report']) - - }//EndStepsPublishReports - }//EndStagePublishReports - }//EndStagesINFTearDown - - }//EndStageTearDown -}//EndStagesPipeline + 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' + }// EndExecutionStageErrorTJobN + }// EndStepsTJobN + }// EndStageTJobN + }// End Parallel + }// End Stage +stage('TEARDOWN-Infrastructure') { + stages { + stage('PublishReports') { + steps { + sh '$SCRIPTS_FOLDER/coilifecycles/coi-teardown.sh' + publishHTML( + target: [ + allowMissing: false, + alwaysLinkToLastBuild: true, + keepAll: true, + reportDir: 'target/site/', + reportFiles: 'surefire-report.html', + reportName: 'Test Execution Report' + ]) + }// EndStepsPublishReports + }// EndStagePublishReports + }// EndStagesINFTearDown +}// EndStageTearDown + }// EndStagesPipeline post { always { - archiveArtifacts artifacts: 'artifacts/*.csv', onlyIfSuccessful: true }//EndAlways - cleanup { - cleanWs() - sh """(eval \$CURRENT_DATE ; echo "Cleaning Environment ") | cat |tr '\n' ' ' """ - echo 'Switch off all containers...' - sh """docker stop \$(docker ps | grep tjob | awk '{print \$1}') || echo 'All the containers are stopped!'""" - sh """docker rm --volumes \$(docker ps -a | grep tjob | awk '{print \$1}') || echo 'All the containers are removed!'""" - }//EndCleanUp + archiveArtifacts artifacts: '$WORKSPACE/artifacts/*.csv', onlyIfSuccessful: true }//EndAlways }//EndPostActions -}//EndPipeline +}// EndPipeline diff --git a/retorchfiles/configurations/retorch-ciinfo.json b/retorchfiles/configurations/retorch-ciinfo.json new file mode 100644 index 0000000..bafae36 --- /dev/null +++ b/retorchfiles/configurations/retorch-ciinfo.json @@ -0,0 +1,9 @@ +{ + "agentCIName": "xretorch-agent", + "sut-wait-html": "FullTeaching", + "sut-location": "$WORKSPACE", + "docker-frontend-name": "https://full-teaching-", + "docker-frontend-port": "5000", + "external-binded-port": "" + +} \ No newline at end of file diff --git a/retorchfiles/configurations/retorch-info.json b/retorchfiles/configurations/retorch-info.json new file mode 100644 index 0000000..90c134a --- /dev/null +++ b/retorchfiles/configurations/retorch-info.json @@ -0,0 +1,28 @@ +{ + "OpenViduMock": { + "dockerImageResource": [ + { + "placeHolderId": "OpenViduImage", + "imageName": "eexit/mirror-http-server" + }, + { + "placeHolderId": "mysqlImage", + "imageName": "mysql:5.7.21" + } + ], + "testsBasePath": "./" + }, + "generic": { + "dockerImageResource": [ + { + "placeHolderId": "OpenViduImage", + "imageName": "openvidu/openvidu-server-kms:1.7.0" + }, + { + "placeHolderId": "mysqlImage", + "imageName": "mysql:5.7.21" + } + ], + "testsBasePath": "./" + } +} diff --git a/retorchfiles/envfiles/tjobc.env b/retorchfiles/envfiles/tjobc.env new file mode 100644 index 0000000..09fa289 --- /dev/null +++ b/retorchfiles/envfiles/tjobc.env @@ -0,0 +1,17 @@ +testsBasePath=./ +tjobname=tjobc +frontend_port=5000 +retorchportj=5009 +retorchportk=5010 +retorchporth=5007 +mysqlImage=mysql:5.7.21 +retorchporti=5008 +retorchportf=5005 +retorchportg=5006 +retorchportd=5003 +retorchporte=5004 +retorchportb=5001 +retorchportc=5002 +retorchporta=5000 +OpenViduImage=eexit/mirror-http-server + diff --git a/retorchfiles/envfiles/tjobd.env b/retorchfiles/envfiles/tjobd.env new file mode 100644 index 0000000..30717a4 --- /dev/null +++ b/retorchfiles/envfiles/tjobd.env @@ -0,0 +1,17 @@ +testsBasePath=./ +tjobname=tjobd +frontend_port=5000 +retorchportj=5020 +retorchportk=5021 +retorchporth=5018 +mysqlImage=mysql:5.7.21 +retorchporti=5019 +retorchportf=5016 +retorchportg=5017 +retorchportd=5014 +retorchporte=5015 +retorchportb=5012 +retorchportc=5013 +retorchporta=5011 +OpenViduImage=eexit/mirror-http-server + diff --git a/retorchfiles/envfiles/tjobe.env b/retorchfiles/envfiles/tjobe.env new file mode 100644 index 0000000..844d9dd --- /dev/null +++ b/retorchfiles/envfiles/tjobe.env @@ -0,0 +1,17 @@ +testsBasePath=./ +tjobname=tjobe +frontend_port=5000 +retorchportj=5031 +retorchportk=5032 +retorchporth=5029 +mysqlImage=mysql:5.7.21 +retorchporti=5030 +retorchportf=5027 +retorchportg=5028 +retorchportd=5025 +retorchporte=5026 +retorchportb=5023 +retorchportc=5024 +retorchporta=5022 +OpenViduImage=openvidu/openvidu-server-kms:1.7.0 + diff --git a/retorchfiles/envfiles/tjobf.env b/retorchfiles/envfiles/tjobf.env new file mode 100644 index 0000000..4948a47 --- /dev/null +++ b/retorchfiles/envfiles/tjobf.env @@ -0,0 +1,17 @@ +testsBasePath=./ +tjobname=tjobf +frontend_port=5000 +retorchportj=5042 +retorchportk=5043 +retorchporth=5040 +mysqlImage=mysql:5.7.21 +retorchporti=5041 +retorchportf=5038 +retorchportg=5039 +retorchportd=5036 +retorchporte=5037 +retorchportb=5034 +retorchportc=5035 +retorchporta=5033 +OpenViduImage=eexit/mirror-http-server + diff --git a/retorchfiles/envfiles/tjobg.env b/retorchfiles/envfiles/tjobg.env new file mode 100644 index 0000000..65642ed --- /dev/null +++ b/retorchfiles/envfiles/tjobg.env @@ -0,0 +1,17 @@ +testsBasePath=./ +tjobname=tjobg +frontend_port=5000 +retorchportj=5053 +retorchportk=5054 +retorchporth=5051 +mysqlImage=mysql:5.7.21 +retorchporti=5052 +retorchportf=5049 +retorchportg=5050 +retorchportd=5047 +retorchporte=5048 +retorchportb=5045 +retorchportc=5046 +retorchporta=5044 +OpenViduImage=eexit/mirror-http-server + diff --git a/retorchfiles/envfiles/tjobh.env b/retorchfiles/envfiles/tjobh.env new file mode 100644 index 0000000..9c78b43 --- /dev/null +++ b/retorchfiles/envfiles/tjobh.env @@ -0,0 +1,17 @@ +testsBasePath=./ +tjobname=tjobh +frontend_port=5000 +retorchportj=5064 +retorchportk=5065 +retorchporth=5062 +mysqlImage=mysql:5.7.21 +retorchporti=5063 +retorchportf=5060 +retorchportg=5061 +retorchportd=5058 +retorchporte=5059 +retorchportb=5056 +retorchportc=5057 +retorchporta=5055 +OpenViduImage=eexit/mirror-http-server + diff --git a/retorchfiles/envfiles/tjobi.env b/retorchfiles/envfiles/tjobi.env new file mode 100644 index 0000000..b245760 --- /dev/null +++ b/retorchfiles/envfiles/tjobi.env @@ -0,0 +1,17 @@ +testsBasePath=./ +tjobname=tjobi +frontend_port=5000 +retorchportj=5075 +retorchportk=5076 +retorchporth=5073 +mysqlImage=mysql:5.7.21 +retorchporti=5074 +retorchportf=5071 +retorchportg=5072 +retorchportd=5069 +retorchporte=5070 +retorchportb=5067 +retorchportc=5068 +retorchporta=5066 +OpenViduImage=eexit/mirror-http-server + diff --git a/retorchfiles/envfiles/tjobj.env b/retorchfiles/envfiles/tjobj.env new file mode 100644 index 0000000..1c7081c --- /dev/null +++ b/retorchfiles/envfiles/tjobj.env @@ -0,0 +1,17 @@ +testsBasePath=./ +tjobname=tjobj +frontend_port=5000 +retorchportj=5086 +retorchportk=5087 +retorchporth=5084 +mysqlImage=mysql:5.7.21 +retorchporti=5085 +retorchportf=5082 +retorchportg=5083 +retorchportd=5080 +retorchporte=5081 +retorchportb=5078 +retorchportc=5079 +retorchporta=5077 +OpenViduImage=eexit/mirror-http-server + diff --git a/retorchfiles/envfiles/tjobk.env b/retorchfiles/envfiles/tjobk.env new file mode 100644 index 0000000..3fc301b --- /dev/null +++ b/retorchfiles/envfiles/tjobk.env @@ -0,0 +1,17 @@ +testsBasePath=./ +tjobname=tjobk +frontend_port=5000 +retorchportj=5097 +retorchportk=5098 +retorchporth=5095 +mysqlImage=mysql:5.7.21 +retorchporti=5096 +retorchportf=5093 +retorchportg=5094 +retorchportd=5091 +retorchporte=5092 +retorchportb=5089 +retorchportc=5090 +retorchporta=5088 +OpenViduImage=eexit/mirror-http-server + diff --git a/retorchfiles/envfiles/tjobl.env b/retorchfiles/envfiles/tjobl.env new file mode 100644 index 0000000..a95cd93 --- /dev/null +++ b/retorchfiles/envfiles/tjobl.env @@ -0,0 +1,17 @@ +testsBasePath=./ +tjobname=tjobl +frontend_port=5000 +retorchportj=5108 +retorchportk=5109 +retorchporth=5106 +mysqlImage=mysql:5.7.21 +retorchporti=5107 +retorchportf=5104 +retorchportg=5105 +retorchportd=5102 +retorchporte=5103 +retorchportb=5100 +retorchportc=5101 +retorchporta=5099 +OpenViduImage=eexit/mirror-http-server + diff --git a/retorchfiles/envfiles/tjobm.env b/retorchfiles/envfiles/tjobm.env new file mode 100644 index 0000000..ac2be6f --- /dev/null +++ b/retorchfiles/envfiles/tjobm.env @@ -0,0 +1,17 @@ +testsBasePath=./ +tjobname=tjobm +frontend_port=5000 +retorchportj=5119 +retorchportk=5120 +retorchporth=5117 +mysqlImage=mysql:5.7.21 +retorchporti=5118 +retorchportf=5115 +retorchportg=5116 +retorchportd=5113 +retorchporte=5114 +retorchportb=5111 +retorchportc=5112 +retorchporta=5110 +OpenViduImage=openvidu/openvidu-server-kms:1.7.0 + diff --git a/retorchfiles/envfiles/tjobn.env b/retorchfiles/envfiles/tjobn.env new file mode 100644 index 0000000..0895a12 --- /dev/null +++ b/retorchfiles/envfiles/tjobn.env @@ -0,0 +1,17 @@ +testsBasePath=./ +tjobname=tjobn +frontend_port=5000 +retorchportj=5130 +retorchportk=5131 +retorchporth=5128 +mysqlImage=mysql:5.7.21 +retorchporti=5129 +retorchportf=5126 +retorchportg=5127 +retorchportd=5124 +retorchporte=5125 +retorchportb=5122 +retorchportc=5123 +retorchporta=5121 +OpenViduImage=eexit/mirror-http-server + diff --git a/retorchfiles/resources/FullTeachingSystemResources.json b/retorchfiles/resources/FullTeachingSystemResources.json new file mode 100644 index 0000000..f56c8a0 --- /dev/null +++ b/retorchfiles/resources/FullTeachingSystemResources.json @@ -0,0 +1,130 @@ +{ + "Configuration": { + "hierarchyParent": [ + "Course" + ], + "replaceable": [], + "elasticityModel": { + "elasticityID": "elasModelConfiguration", + "elasticity": 40, + "elasticityCost": 15.0 + }, + "resourceType": "LOGICAL", + "resourceID": "Configuration" + }, + "OpenViduMock": { + "hierarchyParent": [ + "OpenVidu" + ], + "replaceable": [], + "elasticityModel": { + "elasticityID": "elasModelOpenViduMock", + "elasticity": 30, + "elasticityCost": 10.0 + }, + "resourceType": "LOGICAL", + "resourceID": "OpenViduMock" + }, + "OpenVidu": { + "hierarchyParent": [], + "replaceable": [], + "elasticityModel": { + "elasticityID": "elasModelOpenVidu", + "elasticity": 1, + "elasticityCost": 300.0 + }, + "resourceType": "LOGICAL", + "resourceID": "OpenVidu" + }, + "Course": { + "hierarchyParent": [ + "MySQL" + ], + "replaceable": [], + "elasticityModel": { + "elasticityID": "elasModelCourse", + "elasticity": 5, + "elasticityCost": 100.0 + }, + "resourceType": "LOGICAL", + "resourceID": "Course" + }, + "Information": { + "hierarchyParent": [ + "Course" + ], + "replaceable": [], + "elasticityModel": { + "elasticityID": "elasModelInformation", + "elasticity": 20, + "elasticityCost": 15.0 + }, + "resourceType": "LOGICAL", + "resourceID": "Information" + }, + "Files": { + "hierarchyParent": [ + "Course" + ], + "replaceable": [], + "elasticityModel": { + "elasticityID": "elasModelFiles", + "elasticity": 20, + "elasticityCost": 15.0 + }, + "resourceType": "LOGICAL", + "resourceID": "Files" + }, + "Attenders": { + "hierarchyParent": [ + "Course" + ], + "replaceable": [], + "elasticityModel": { + "elasticityID": "elasModelAttenders", + "elasticity": 20, + "elasticityCost": 15.0 + }, + "resourceType": "LOGICAL", + "resourceID": "Attenders" + }, + "LoginService": { + "hierarchyParent": [ + "MySQL" + ], + "replaceable": [], + "elasticityModel": { + "elasticityID": "elasModelLoginService", + "elasticity": 5, + "elasticityCost": 30.0 + }, + "resourceType": "LOGICAL", + "resourceID": "LoginService" + }, + "Session": { + "hierarchyParent": [ + "Course" + ], + "replaceable": [], + "elasticityModel": { + "elasticityID": "elasModelSession", + "elasticity": 20, + "elasticityCost": 15.0 + }, + "resourceType": "LOGICAL", + "resourceID": "Session" + }, + "Forum": { + "hierarchyParent": [ + "Course" + ], + "replaceable": [], + "elasticityModel": { + "elasticityID": "elasModelForum", + "elasticity": 20, + "elasticityCost": 15.0 + }, + "resourceType": "LOGICAL", + "resourceID": "Forum" + } +} \ No newline at end of file diff --git a/retorchfiles/retorchdockercomposesenvfiles/tjobc.env b/retorchfiles/retorchdockercomposesenvfiles/tjobc.env deleted file mode 100644 index bce6519..0000000 --- a/retorchfiles/retorchdockercomposesenvfiles/tjobc.env +++ /dev/null @@ -1,5 +0,0 @@ -mysqlImage=mysql:5.7.21 -testsBasePath=./ -OpenViduImage=eexit/mirror-http-server -tjobname=tjobc - diff --git a/retorchfiles/retorchdockercomposesenvfiles/tjobd.env b/retorchfiles/retorchdockercomposesenvfiles/tjobd.env deleted file mode 100644 index 8bd3643..0000000 --- a/retorchfiles/retorchdockercomposesenvfiles/tjobd.env +++ /dev/null @@ -1,5 +0,0 @@ -mysqlImage=mysql:5.7.21 -testsBasePath=./ -OpenViduImage=eexit/mirror-http-server -tjobname=tjobd - diff --git a/retorchfiles/retorchdockercomposesenvfiles/tjobe.env b/retorchfiles/retorchdockercomposesenvfiles/tjobe.env deleted file mode 100644 index 613e445..0000000 --- a/retorchfiles/retorchdockercomposesenvfiles/tjobe.env +++ /dev/null @@ -1,5 +0,0 @@ -mysqlImage=mysql:5.7.21 -testsBasePath=./ -OpenViduImage=openvidu/openvidu-server-kms:1.7.0 -tjobname=tjobe - diff --git a/retorchfiles/retorchdockercomposesenvfiles/tjobf.env b/retorchfiles/retorchdockercomposesenvfiles/tjobf.env deleted file mode 100644 index 4c5891c..0000000 --- a/retorchfiles/retorchdockercomposesenvfiles/tjobf.env +++ /dev/null @@ -1,5 +0,0 @@ -mysqlImage=mysql:5.7.21 -testsBasePath=./ -OpenViduImage=eexit/mirror-http-server -tjobname=tjobf - diff --git a/retorchfiles/retorchdockercomposesenvfiles/tjobg.env b/retorchfiles/retorchdockercomposesenvfiles/tjobg.env deleted file mode 100644 index 3fcb65c..0000000 --- a/retorchfiles/retorchdockercomposesenvfiles/tjobg.env +++ /dev/null @@ -1,5 +0,0 @@ -mysqlImage=mysql:5.7.21 -testsBasePath=./ -OpenViduImage=eexit/mirror-http-server -tjobname=tjobg - diff --git a/retorchfiles/retorchdockercomposesenvfiles/tjobh.env b/retorchfiles/retorchdockercomposesenvfiles/tjobh.env deleted file mode 100644 index b7d1b54..0000000 --- a/retorchfiles/retorchdockercomposesenvfiles/tjobh.env +++ /dev/null @@ -1,5 +0,0 @@ -mysqlImage=mysql:5.7.21 -testsBasePath=./ -OpenViduImage=eexit/mirror-http-server -tjobname=tjobh - diff --git a/retorchfiles/retorchdockercomposesenvfiles/tjobi.env b/retorchfiles/retorchdockercomposesenvfiles/tjobi.env deleted file mode 100644 index c6ef1b9..0000000 --- a/retorchfiles/retorchdockercomposesenvfiles/tjobi.env +++ /dev/null @@ -1,5 +0,0 @@ -mysqlImage=mysql:5.7.21 -testsBasePath=./ -OpenViduImage=eexit/mirror-http-server -tjobname=tjobi - diff --git a/retorchfiles/retorchdockercomposesenvfiles/tjobj.env b/retorchfiles/retorchdockercomposesenvfiles/tjobj.env deleted file mode 100644 index 7ca7908..0000000 --- a/retorchfiles/retorchdockercomposesenvfiles/tjobj.env +++ /dev/null @@ -1,5 +0,0 @@ -mysqlImage=mysql:5.7.21 -testsBasePath=./ -OpenViduImage=eexit/mirror-http-server -tjobname=tjobj - diff --git a/retorchfiles/retorchdockercomposesenvfiles/tjobk.env b/retorchfiles/retorchdockercomposesenvfiles/tjobk.env deleted file mode 100644 index 7eeab50..0000000 --- a/retorchfiles/retorchdockercomposesenvfiles/tjobk.env +++ /dev/null @@ -1,5 +0,0 @@ -mysqlImage=mysql:5.7.21 -testsBasePath=./ -OpenViduImage=eexit/mirror-http-server -tjobname=tjobk - diff --git a/retorchfiles/retorchdockercomposesenvfiles/tjobl.env b/retorchfiles/retorchdockercomposesenvfiles/tjobl.env deleted file mode 100644 index da9c6bf..0000000 --- a/retorchfiles/retorchdockercomposesenvfiles/tjobl.env +++ /dev/null @@ -1,5 +0,0 @@ -mysqlImage=mysql:5.7.21 -testsBasePath=./ -OpenViduImage=eexit/mirror-http-server -tjobname=tjobl - diff --git a/retorchfiles/retorchdockercomposesenvfiles/tjobm.env b/retorchfiles/retorchdockercomposesenvfiles/tjobm.env deleted file mode 100644 index 0b8bd89..0000000 --- a/retorchfiles/retorchdockercomposesenvfiles/tjobm.env +++ /dev/null @@ -1,5 +0,0 @@ -mysqlImage=mysql:5.7.21 -testsBasePath=./ -OpenViduImage=openvidu/openvidu-server-kms:1.7.0 -tjobname=tjobm - diff --git a/retorchfiles/retorchdockercomposesenvfiles/tjobn.env b/retorchfiles/retorchdockercomposesenvfiles/tjobn.env deleted file mode 100644 index b891da4..0000000 --- a/retorchfiles/retorchdockercomposesenvfiles/tjobn.env +++ /dev/null @@ -1,5 +0,0 @@ -mysqlImage=mysql:5.7.21 -testsBasePath=./ -OpenViduImage=eexit/mirror-http-server -tjobname=tjobn - diff --git a/retorchfiles/scripts/coilifecycles/coi-setup.sh b/retorchfiles/scripts/coilifecycles/coi-setup.sh index 75fbf51..4474bde 100644 --- a/retorchfiles/scripts/coilifecycles/coi-setup.sh +++ b/retorchfiles/scripts/coilifecycles/coi-setup.sh @@ -1,30 +1,60 @@ #!/bin/bash -OUTPUTDIRCOI="./src/retorchcostestimationdata/exec$BUILD_NUMBER/COI.data" + +SEL_VIDEO_DIR="/opt/selenoid/video/" +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 +} + +# Set output directory for COI +OUTPUTDIRCOI="$WORKSPACE/retorchcostestimationdata/exec$BUILD_NUMBER/COI.data" + +# Record start time for COI setup COISETUPSTART=$(date +%s%3N) -echo 'Remove older videos (7 days)! The number of videos prior remove :' -find /opt/selenoid/video/ | wc -l -find /opt/selenoid/video/ -mindepth 1 -maxdepth 1 -mtime +7 -name '*.mp4' | xargs rm -rf -echo 'Remove older videos (7 days)! The number of videos after remove : ' -find /opt/selenoid/video/ | wc -l -echo 'Remove older logs (7days)! The number of logs prior remove :' -find /opt/selenoid/logs/ | wc -l -find /opt/selenoid/logs/ -mindepth 1 -maxdepth 1 -mtime +7 -name '*.log' | xargs rm -rf -echo 'Remove older logs (7days)! The number of logs prior remove : ' -find /opt/selenoid/logs/ | wc -l -mkdir -p "./src/retorchcostestimationdata/exec$BUILD_NUMBER" -mkdir -p "./artifacts" -echo "Pulling the Docker Images required by Selenoid (if are not pulled)" -docker pull selenoid/vnc_chrome:116.0 -docker pull selenoid/video-recorder:latest-release -echo "Pulling the Docker Images requirede by the Test suite" -docker pull eexit/mirror-http-server -docker pull mysql:5.7.21 -docker pull openvidu/openvidu-server-kms:1.7.0 -docker pull codeurjc/full-teaching:demo -COISETUPEND=$(date +%s%3N) +# Remove older videos (older than 15 days) +remove_old_files "$SEL_VIDEO_DIR" 15 + +# Remove older logs (older than 7 days) +remove_old_files "$SEL_LOG_DIR" 7 +# Create necessary directories +mkdir -p "$WORKSPACE/retorchcostestimationdata/exec$BUILD_NUMBER" +mkdir -p "$WORKSPACE/artifacts" +mkdir -p "$SUT_LOCATION/tmp" -echo "COI-SETUP-START;COI-SETUP-END;COI-TEARDOWN-START;COI-TEARDOWN-END" >"$OUTPUTDIRCOI" -echo -n "$COISETUPSTART;$COISETUPEND">>"$OUTPUTDIRCOI" +# 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." +else + echo "Failed to pull Docker images." +fi + +echo "Building images of SUT" + +# Use double quotes for Docker Compose files +docker compose -f "docker-compose.yml" --ansi never build + +# Check the exit status of the last command +if [ $? -eq 0 ]; then + echo "Images for SUT" +else + 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" diff --git a/retorchfiles/scripts/coilifecycles/coi-teardown.sh b/retorchfiles/scripts/coilifecycles/coi-teardown.sh index b0cd055..3bae4ce 100644 --- a/retorchfiles/scripts/coilifecycles/coi-teardown.sh +++ b/retorchfiles/scripts/coilifecycles/coi-teardown.sh @@ -1,13 +1,21 @@ #!/bin/bash +set -e # Exit immediately if any command exits with a non-zero status COITEARDOWNSTART="$(date +%s%3N)" -echo 'Switch off all containers...' -docker stop "$(docker ps | grep tjob | awk '{print \$1}')" || echo 'All the containers are stopped!' -docker rm --volumes "$(docker ps -a | grep tjob | awk '{print \$1}')" || echo 'All the containers are removed!' -sh 'retorchfiles/scripts/saveTJobLifecycledata.sh' +echo "Switch off all containers that start with *tjob*..." +docker rm $(docker stop $(docker ps -a -q --filter name=tjob --format="{{.ID}}") || echo 'Any Container to remove') || echo 'All the containers are removed!' + +echo "Pruning also its volumes" +docker volume prune --all -f + +# Run saveTJobLifecycledata.sh script +echo "Running saveTJobLifecycledata.sh script..." +sh "$SCRIPTS_FOLDER/savetjoblifecycledata.sh" + COITEARDOWNEND="$(date +%s%3N)" -OUTPUTDIRCOI="./src/retorchcostestimationdata/exec$BUILD_NUMBER/COI.data" -echo -n ";$COITEARDOWNSTART;$COITEARDOWNEND" >>"$OUTPUTDIRCOI" +OUTPUTDIRCOI="$WORKSPACE/retorchcostestimationdata/exec$BUILD_NUMBER/COI.data" +echo -n ";$COITEARDOWNSTART;$COITEARDOWNEND" >> "$OUTPUTDIRCOI" +echo "COI teardown script completed successfully." diff --git a/retorchfiles/scripts/saveTJobLifecycledata.sh b/retorchfiles/scripts/saveTJobLifecycledata.sh index 5fd3a30..b660324 100644 --- a/retorchfiles/scripts/saveTJobLifecycledata.sh +++ b/retorchfiles/scripts/saveTJobLifecycledata.sh @@ -1,14 +1,29 @@ #!/bin/bash -PATH_FILES="./src/retorchcostestimationdata/exec${BUILD_NUMBER}/tjob*" -OUTPUT_FILE="./artifacts/lifecycletimmingsexec${BRANCH_NAME///}-${BUILD_NUMBER}.csv" -OUTPUTDIRCOI="./src/retorchcostestimationdata/exec$BUILD_NUMBER/COI.data" +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 +fi + +PATH_FILES="$WORKSPACE/retorchcostestimationdata/exec${BUILD_NUMBER}/tjob*" +OUTPUT_FILE="$WORKSPACE/artifacts/lifecycletimingsexec${BRANCH_NAME///}-${BUILD_NUMBER}.csv" +OUTPUT_DIR_COI="$WORKSPACE/retorchcostestimationdata/exec$BUILD_NUMBER/COI.data" + echo "tjobname;stage;COI-setup-start;COI-setup-end;tjob-setup-start;tjob-setup-end;tjob-testexec-start;tjob-testexec-end;tjob-teardown-start;tjob-teardown-end;coi-teardown-start;coi-teardown-end" >"$OUTPUT_FILE" + for csvfile in $PATH_FILES; do - { - tail -n +2 "$csvfile" - echo -n ";" - tail -n +2 "$OUTPUTDIRCOI" | rev | cut -d ';' -f 2 | rev | tr -d '\n' - echo -n ";" - tail -n +2 "$OUTPUTDIRCOI" | rev | cut -d ';' -f 1 | rev - } >>"$OUTPUT_FILE" + if [ -e "$csvfile" ] && [ -e "$OUTPUT_DIR_COI" ]; then + { + tail -n +2 "$csvfile" + echo -n ";" + tail -n +2 "$OUTPUT_DIR_COI" | rev | cut -d ';' -f 2 | rev | tr -d '\n' + echo -n ";" + tail -n +2 "$OUTPUT_DIR_COI" | rev | cut -d ';' -f 1 | rev + } >>"$OUTPUT_FILE" + else + echo "Error: One or more files do not exist." + exit 1 + fi done diff --git a/retorchfiles/scripts/tjoblifecycles/tjob-setup.sh b/retorchfiles/scripts/tjoblifecycles/tjob-setup.sh index 757045c..01a64f4 100644 --- a/retorchfiles/scripts/tjoblifecycles/tjob-setup.sh +++ b/retorchfiles/scripts/tjoblifecycles/tjob-setup.sh @@ -1,7 +1,28 @@ #!/bin/bash -retorchfiles/scripts/writetime.sh "$2" "$1" #$2 is the stage, $1 tjob -docker compose --env-file "./retorchfiles/retorchdockercomposesenvfiles/${1}.env" --ansi never -p "$1" up -d -echo "Waiting for the SUT... " -retorchfiles/scripts/waitForFullteaching.sh "$1" -echo "SUT READY!" -retorchfiles/scripts/writetime.sh "$2" "$1" #$2 is the stage, $1 tjob +set -e +# Execute the script to write timestamp +"$SCRIPTS_FOLDER/writetime.sh" "$2" "$1" + +# Export Docker Host IP +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" + + + +# Deploy containers +cd "$SUT_LOCATION/src" +echo "Deploying containers for TJOB $1" +docker compose -f docker-compose.yml --env-file "$WORKSPACE/retorchfiles/envfiles/$1.env" --ansi never -p "$1" up -d + +echo "Waiting for the system to be up..." +"$WORKSPACE/retorchfiles/scripts/waitforSUT.sh" "$1" +cd "$WORKSPACE" + +echo "System READY!! Test execution can start!" + +# Execute the script to write timestamp again +"$SCRIPTS_FOLDER/writetime.sh" "$2" "$1" diff --git a/retorchfiles/scripts/tjoblifecycles/tjob-teardown.sh b/retorchfiles/scripts/tjoblifecycles/tjob-teardown.sh index 46d3ae2..5cb50de 100644 --- a/retorchfiles/scripts/tjoblifecycles/tjob-teardown.sh +++ b/retorchfiles/scripts/tjoblifecycles/tjob-teardown.sh @@ -1,4 +1,18 @@ #!/bin/bash -retorchfiles/scripts/writetime.sh "$2" "$1" #$2 is the stage, $1 tjob -docker compose --env-file "./retorchfiles/retorchdockercomposesenvfiles/${1}.env" --ansi never -p "$1" down --volumes -retorchfiles/scripts/writetime.sh "$2" "$1" #$2 is the stage, $1 tjob +set -e + +# Execute the script to write timestamp +"$SCRIPTS_FOLDER/writetime.sh" "$2" "$1" + +# Change to SUT location +cd "$SUT_LOCATION" + +# Tear down Docker containers and volumes +echo "Tearing down Docker containers and volumes for TJOB $1" +docker compose -f docker-compose.yml --env-file "$WORKSPACE/retorchfiles/envfiles/$1.env" --ansi never -p "$1" down --volumes + +# Return to the original working directory +cd "$WORKSPACE" + +# Execute the script to write timestamp again +"$SCRIPTS_FOLDER/writetime.sh" "$2" "$1" diff --git a/retorchfiles/scripts/tjoblifecycles/tjob-testexecution.sh b/retorchfiles/scripts/tjoblifecycles/tjob-testexecution.sh index 4446a40..8b85e44 100644 --- a/retorchfiles/scripts/tjoblifecycles/tjob-testexecution.sh +++ b/retorchfiles/scripts/tjoblifecycles/tjob-testexecution.sh @@ -1,15 +1,52 @@ #!/bin/bash -URL="https://full-teaching-$1:5000" -#https://stackoverflow.com/questions/4365418/get-state-of-maven-execution-within-shell-script set -e -retorchfiles/scripts/writetime.sh "$2" "$1" #$2 is the stage, $1 tjob -mvn -Dapp.url="${URL}" -Dtest="$3" test -Ddirtarget="$1" -retorchfiles/scripts/writetime.sh "$2" "$1" #$2 is the stage, $1 tjob -#if [[$EXECUTION_RESULT -eq 0]] -# then -# echo "EXECUTION TJOB $1 FINISHED" -# return 0 -# else -# echo "SOMETHING GO WRONG WITH TJOB $1" -# return 1 -# fi +# Function to execute timestamp script +EXECUTE_TIMESTAMP_SCRIPT() { + local STAGE="$1" + local TJOB_NAME="$2" + $SCRIPTS_FOLDER/writetime.sh "$STAGE" "$TJOB_NAME" +} + +# Check if the required parameters are provided +if [ "$#" -lt 5 ]; then + echo "Usage: $0 " + exit 1 +fi +# Constants +DOCKER_HOST_IP=$(/sbin/ip route | awk '/default/ { print $3 }') +# Define variables +TJOB_NAME="$1" +STAGE="$2" +PORT="$4" +TEST_NAME="$5" +if [[ $url == "https://" || $url == "http://" ]]; then + echo "Only http:// || https:// protocol provided, using HOST DOCKER INTERNAL IP " + SUT_URL="$3"+DOCKER_HOST_IP +else + echo "Using the provided URL" + SUT_URL="$3" +fi +echo "The URL IS $SUT_URL" + +# Execute the script to write timestamp +EXECUTE_TIMESTAMP_SCRIPT "$STAGE" "$TJOB_NAME" + +# Display HOST_IP and PORT information +echo "The HOST_IP is: $DOCKER_HOST_IP and PORT $PORT for the TJOB $TJOB_NAME" + +LOCALHOST="$DOCKER_HOST_IP:$PORT" +# Run Maven test +mvn test -Ddirtarget="$TJOBNAME" -Dtest="$TEST_NAME" -Dtjob_name="$TJOB_NAME" -DSUT_URL="$SUT_URL:$PORT" + +# Check if Maven test failed +if [ $? -ne 0 ]; then + echo "Maven test FAILED with 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 diff --git a/retorchfiles/scripts/waitforSUT.sh b/retorchfiles/scripts/waitforSUT.sh new file mode 100644 index 0000000..55cda36 --- /dev/null +++ b/retorchfiles/scripts/waitforSUT.sh @@ -0,0 +1,19 @@ +#!/bin/bash +if [ "$#" -ne 1 ]; then + echo "Usage: $0 " + exit 1 +fi +DOCKER_HOST_IP=$(/sbin/ip route | awk '/default/ { print $3 }') +COUNTER=0 +WAIT_LIMIT=40 + +while ! curl --insecure -s "https://full-teaching-$1:5000" | grep -q "FullTeaching"; do + echo "Waiting $COUNTER seconds for $1 with URL https://full-teaching-$1:5000" + sleep 5 + ((COUNTER++)) + + if ((COUNTER > WAIT_LIMIT)); then + echo "The container is down" + exit 1 + fi +done diff --git a/retorchfiles/scripts/writetime.sh b/retorchfiles/scripts/writetime.sh index 980d4b6..dea11af 100644 --- a/retorchfiles/scripts/writetime.sh +++ b/retorchfiles/scripts/writetime.sh @@ -1,16 +1,34 @@ #!/bin/bash -OUTPUTDIR="./src/retorchcostestimationdata/exec$BUILD_NUMBER/$2.data" -OUTPUTDIRCOI="./src/retorchcostestimationdata/exec$BUILD_NUMBER/COI.data" -if [ -f "$OUTPUTDIR" ]; then - echo -n ";$(date +%s%3N)" >>"$OUTPUTDIR" -else +# Check if the correct number of parameters is provided +if [ "$#" -ne 2 ]; then + echo "Usage: $0 " + exit 1 +fi +STAGE=$2 +# Constants +WORKSPACE_DIR="$WORKSPACE/retorchcostestimationdata/exec$BUILD_NUMBER" +OUTPUT_FILE="$WORKSPACE_DIR/$STAGE.data" +OUTPUT_DIR_COI="$WORKSPACE_DIR/COI.data" + +# Function to append timestamp +append_timestamp() { + if [ -f "$1" ]; then + echo -n ";$(date +%s%3N)" >>"$1" + else + echo "Error: File $1 does not exist." + exit 1 + fi +} - echo "tjobname;stage;COI-setup-start;COI-setup-end;setup-start;setup-end;testexec-start;testexec-end;teardown-start;teardown-end" >"$OUTPUTDIR" +# Check if the output file exists +if [ -f "$OUTPUT_FILE" ]; then + append_timestamp "$OUTPUT_FILE" +else + echo "tjobname;stage;COI-setup-start;COI-setup-end;setup-start;setup-end;testexec-start;testexec-end;teardown-start;teardown-end" >"$OUTPUT_FILE" { - echo -n "$2;$1;" - tail -n +2 "$OUTPUTDIRCOI" + echo -n "$STAGE;$BUILD_NUMBER;" + tail -n +2 "$OUTPUT_DIR_COI" echo -n ";$(date +%s%3N)" - } >>"$OUTPUTDIR" - + } >>"$OUTPUT_FILE" fi