diff --git a/Acceptancetest/src/test/java/acceptancetest/acat.java b/Acceptancetest/src/test/java/acceptancetest/acat.java index b66f0fe334..213aa1e459 100644 --- a/Acceptancetest/src/test/java/acceptancetest/acat.java +++ b/Acceptancetest/src/test/java/acceptancetest/acat.java @@ -12,8 +12,8 @@ public class acat { public HtmlUnitDriver driver; //public WebDriver driver; public WebDriverWait wait; - public String URL = "http://172.31.45.127:8080/ProdWebapp"; - public String URL1 = "http://172.31.45.127:8080/ProdWebapp/avncreatepage.jsp"; + public String URL = "http://squadprodserver:8080/ProdWebapp"; + public String URL1 = "http://squadprodserver:8080/ProdWebapp/avncreatepage.jsp"; //public String URL = "http://localhost:8080/AVNCommunication-1.0/avnlogin.jsp"; //public String URL1 = "http://localhost:8080/AVNCommunication-1.0/avncreatepage.jsp"; diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..49d5738846 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +# FROM openjdk:8-jre-alpine +# EXPOSE 8080 +# ADD target/*.jar app.jar +# ENTRYPOINT [ "sh", "-c", "java -jar /app.jar" ] +FROM squad5 +COPY target/AVNCommunication-1.0.war /usr/local/tomcat/webapps/AVNCommunication-1.0.war +RUN service tomcat8 start diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000000..6bd7dbce8b --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,336 @@ +def server +def buildInfo +def rtMaven +pipeline { + agent any + stages { + stage('Initalize') { + parallel { + stage('Static Code Analysis') { + steps { + slackSend channel: 'notify', message: "Static Code Analysis started for : ${env.JOB_NAME} ${env.BUILD_NUMBER}" + + withSonarQubeEnv('sonarqube-server') { + sh ''' + echo "PATH = ${PATH}" + echo "M2_HOME = ${M2_HOME}" + mvn "-Dsonar.test.exclusions=**/test/java/servlet/createpage_junit.java " -Dsonar.login=sonar -Dsonar.password=${SONAR_AUTH} -Dsonar.tests=. -Dsonar.inclusions=**/test/java/servlet/createpage_junit.java -Dsonar.sources=. sonar:sonar -Dsonar.host.url=${SONAR_HOST_URL} + ''' + } + } + post { + success { + slackSend channel: 'notify', message: "Static Code Analysis succesfully completed for : ${env.JOB_NAME} ${env.BUILD_NUMBER}" + } + failure { + slackSend channel: 'notify', message: "Static Code Analysis failed for : ${env.JOB_NAME} ${env.BUILD_NUMBER}" + } + } + } + + stage('Build the project') { + steps { + slackSend channel: 'notify', message: "Build the project started for : ${env.JOB_NAME} ${env.BUILD_NUMBER}" + script { + sh ''' + mvn -B -f pom.xml compile + ''' + } + } + post { + success { + slackSend channel: 'notify', message: "Build the project succesfully completed for : ${env.JOB_NAME} ${env.BUILD_NUMBER}" + } + failure { + slackSend channel: 'notify', message: "Build the project failed for : ${env.JOB_NAME} ${env.BUILD_NUMBER}" + } + } + } + stage('Initalize Docker Compose on Test & Prod Servers') { + steps { + slackSend channel: 'notify', message: "Initialize Test & Prod Server started for : ${env.JOB_NAME} ${env.BUILD_NUMBER}" + script { + sh ''' + testserver=`grep test-server /etc/ansible/hosts | awk '{print $2}' | cut -d '=' -f2` + prodserver=`grep prod-server /etc/ansible/hosts | awk '{print $2}' | cut -d '=' -f2` + for server in $testserver $prodserver + do + sudo scp -o StrictHostKeyChecking=no docker-compose.yml root@${server}:/root/docker-compose.yml + sudo ssh -o StrictHostKeyChecking=no root@${server} ' + if [[ `docker ps -q | wc -l` -gt 0 ]] + then + docker-compose down + fi + rm -fr /opt/tomcat/webapps/* + docker-compose up -d + ' + done + ''' + } + } + post { + success { + slackSend channel: 'notify', message: "Initialize Test & Prod Server succesfully completed for : ${env.JOB_NAME} ${env.BUILD_NUMBER}" + } + failure { + slackSend channel: 'notify', message: "Initialize Test & Prod Server failed for : ${env.JOB_NAME} ${env.BUILD_NUMBER}" + } + } + } + } + post { + success { + script { + sh ''' + ### Code to update the Story state + story_nbr=`git show ':/^Merge' --oneline| xargs| awk '{print $7}' | cut -d '/' -f2 | cut -d '-' -f1` + my_merge_branch=`git show ':/^Merge' --oneline| xargs| awk '{print $7}' | cut -d '/' -f2` + curl -v -X PUT -H "X-TrackerToken: $TRACKER_API_TOKEN" -H "Accept: application/json" -H "Content-Type: application/json" --data '{"current_state":"finished"}' "${MY_PIVOTAL_STORIES}/${story_nbr}" + + ### Code to add the comments to the pivotal story + curl -v -X POST -H "X-TrackerToken: $TRACKER_API_TOKEN" -H "Accept: application/json" -H "Content-Type: application/json" --data '{ "text":"Squad-5 Pipeline started due to new code merge to master from '${story_nbr}' in the github.\\n **BRANCH**: '${my_merge_branch}' \\n **REPO**: '${MY_REPO}'\\n \\n \\n Story status is updated to **FINISHED** " }' "${MY_PIVOTAL_STORIES}/${story_nbr}/comments" + ''' + } + } + } + } + + stage('Configure Test & Prod Server') { + steps { + slackSend channel: 'notify', message: "Configure Test & Prod Server started for : ${env.JOB_NAME} ${env.BUILD_NUMBER}" + script { + sh ''' + testserver=`grep test-server /etc/ansible/hosts | awk '{print $2}' | cut -d '=' -f2` + prodserver=`grep prod-server /etc/ansible/hosts | awk '{print $2}' | cut -d '=' -f2` + echo "Testserver: $testserver and Prodcution: $prodserver" + sed -i "s/squadtestserver/$testserver/g" $(find . -type f) + sed -i "s/squadprodserver/$prodserver/g" $(find . -type f) + grep URL functionaltest/src/test/java/functionaltest/ftat.java + grep URL Acceptancetest/src/test/java/acceptancetest/acat.java + ''' + } + } + post { + success { + slackSend channel: 'notify', message: "Configure Test & Prod Server succesfully completed for : ${env.JOB_NAME} ${env.BUILD_NUMBER}" + } + failure { + slackSend channel: 'notify', message: "Configure Test & Prod Server failed for : ${env.JOB_NAME} ${env.BUILD_NUMBER}" + } + } + } + + stage('Package the project') { + steps { + slackSend channel: 'notify', message: "Package the project started for : ${env.JOB_NAME} ${env.BUILD_NUMBER}" + script { + sh ''' + mvn package -Dmaven.test.skip=true + ''' + } + } + post { + success { + slackSend channel: 'notify', message: "Package the project succesfully completed for : ${env.JOB_NAME} ${env.BUILD_NUMBER}" + } + failure { + slackSend channel: 'notify', message: "Package the project failed for : ${env.JOB_NAME} ${env.BUILD_NUMBER}" + } + } + } + + stage('Store Artifacts') { + steps { + slackSend channel: 'notify', message: "Upload artifacts started for : ${env.JOB_NAME} ${env.BUILD_NUMBER}" + script { + server = Artifactory.server 'artifactory' + sh """ mvn package -Dmaven.test.skip=true """ + def uploadSpec = """{ + "files": [ + { + "pattern": "target/*.war", + "target": "squad5-libs-release-local" + }, + { + "pattern": "target/*.war", + "target": "squad5-libs-snapshot-local" + } + ] + }""" + server.upload spec: uploadSpec + + } + } + post { + success { + slackSend channel: 'notify', message: "Upload artifacts succesfully completed for : ${env.JOB_NAME} ${env.BUILD_NUMBER}" + } + failure { + slackSend channel: 'notify', message: "Upload artifacts failed for : ${env.JOB_NAME} ${env.BUILD_NUMBER}" + } + } + } + + stage('Deploy on Test Server') { + steps { + slackSend channel: 'notify', message: "Deployment of War on Test Server started for : ${env.JOB_NAME} ${env.BUILD_NUMBER}" + script { + sh ''' + sudo ansible-playbook -e 'deployservers="test-server" lcp="QA"' dwnldArtifact.yml + sleep 20s + ''' + } + } + post { + success { + slackSend channel: 'notify', message: "Deployment of War on Test Server succesfully completed for : ${env.JOB_NAME} ${env.BUILD_NUMBER}" + } + failure { + slackSend channel: 'notify', message: "Deployment of War on Test Server failed for : ${env.JOB_NAME} ${env.BUILD_NUMBER}" + } + } + } + + + stage('UI Testing on Test Server') { + steps { + slackSend channel: 'notify', message: "UI Testing started for : ${env.JOB_NAME} ${env.BUILD_NUMBER}" + script { + sh ''' + mvn -B -f functionaltest/pom.xml test + ''' + } + // publish html + publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: false, reportDir: '\\functionaltest\\target\\surefire-reports', reportFiles: 'index.html', reportName: 'HTML Report', reportTitles: '']) + } + post { + always { + jiraSendDeploymentInfo site: 'devopsbctcs03.atlassian.net', environmentId: 'test-${env.BUILD_NUMBER}', environmentName: 'testserver', environmentType: 'testing', issueKeys: ['DP-2'] + } + success { + slackSend channel: 'notify', message: "UI Testing succesfully completed for : ${env.JOB_NAME} ${env.BUILD_NUMBER}" + } + failure { + slackSend channel: 'notify', message: "UI Testing failed for : ${env.JOB_NAME} ${env.BUILD_NUMBER}" + } + } + } + + stage('Performance test'){ + steps { + slackSend channel: 'notify', message: "Performance Testing started for build : ${env.JOB_NAME} ${env.BUILD_NUMBER}" + // blazeMeterTest credentialsId: 'Blazemeter', testId: '9137429.taurus', workspaceId: '775624' + //blazeMeterTest credentialsId: 'bcb98eda-1130-4c9e-97e3-2262ffd3a6b7', testId: '9204220.taurus', workspaceId: '799387' + } + post { + success { + slackSend channel: 'notify', message: "Performance Testing succesfully completed for : ${env.JOB_NAME} ${env.BUILD_NUMBER}" + script { + sh ''' + ### Code to update the Story state + story_nbr=`git show ':/^Merge' --oneline| xargs| awk '{print $7}' | cut -d '/' -f2 | cut -d '-' -f1` + my_merge_branch=`git show ':/^Merge' --oneline| xargs| awk '{print $7}' | cut -d '/' -f2` + curl -v -X PUT -H "X-TrackerToken: $TRACKER_API_TOKEN" -H "Accept: application/json" -H "Content-Type: application/json" --data '{"current_state":"delivered"}' "${MY_PIVOTAL_STORIES}/${story_nbr}" + + ### Code to add the comments to the pivotal story + curl -v -X POST -H "X-TrackerToken: $TRACKER_API_TOKEN" -H "Accept: application/json" -H "Content-Type: application/json" --data '{ "text":"Squad-5 Pipeline deployed the new code to AWS Test-Server from artifactory using docker compose and ran the UI and Performance testing. \\n **Story ID**: '${story_nbr}' \\n **BRANCH**: '${my_merge_branch}' \\n **REPO**: '${MY_REPO}'\\n \\n \\n Story status is updated to **DELIVERED** " }' "${MY_PIVOTAL_STORIES}/${story_nbr}/comments" + ''' + } + } + failure { + slackSend channel: 'notify', message: "Performance Testing failed for : ${env.JOB_NAME} ${env.BUILD_NUMBER}" + } + } + } + + stage('Deploy on Prod Server') { + steps { + slackSend channel: 'notify', message: "Deployment of War on Prod Server started for : ${env.JOB_NAME} ${env.BUILD_NUMBER}" + script { + sh ''' + sudo ansible-playbook -e 'deployservers="prod-server" lcp="Prod"' dwnldArtifact.yml + sleep 20s + ''' + } + } + post { + success { + slackSend channel: 'notify', message: "Deployment of War on Prod Server succesfully completed for : ${env.JOB_NAME} ${env.BUILD_NUMBER}" + } + failure { + slackSend channel: 'notify', message: "Deployment of War on Prod Server failed for : ${env.JOB_NAME} ${env.BUILD_NUMBER}" + } + } + } + + stage('Sanity Tests') { + steps { + slackSend channel: 'notify', message: "Sanity Testing on Prod Server started for : ${env.JOB_NAME} ${env.BUILD_NUMBER}" + script { + sh ''' + mvn -B -f Acceptancetest/pom.xml test + ''' + } + // publish html + publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: false, reportDir: '\\Acceptancetest\\target\\surefire-reports', reportFiles: 'index.html', reportName: 'HTML Report', reportTitles: '']) + } + post { + always { + jiraSendDeploymentInfo site: 'devopsbctcs03.atlassian.net', environmentId: 'prod-${env.BUILD_NUMBER}', environmentName: 'prodserver', environmentType: 'production', issueKeys: ['DP-2'] + } + success { + slackSend channel: 'notify', message: "Sanity Testing on Prod Server succesfully completed for : ${env.JOB_NAME} ${env.BUILD_NUMBER}" + } + failure { + slackSend channel: 'notify', message: "Sanity Testing on Prod Server failed for : ${env.JOB_NAME} ${env.BUILD_NUMBER}" + } + } + } + + } + post { + success { + script { + sh ''' + ### Code to update the Story CICD Pipeline status + export story_nbr=`git show ':/^Merge' --oneline| xargs| awk '{print $7}' | cut -d '/' -f2 | cut -d '-' -f1` + export NEW_LATEST_GIT_SHA=$(git rev-parse HEAD) + my_merge_branch=`git show ':/^Merge' --oneline| xargs| awk '{print $7}' | cut -d '/' -f2` + + curl -v -X POST -H "X-TrackerToken: $TRACKER_API_TOKEN" -H "Content-Type: application/json" -d '{"status":"passed", "url":"'$BUILD_URL'", "uuid":"9c1a65985558b645d869c2adf0f162fc", "story_ids":['${story_nbr}'], "latest_git_sha":"'$NEW_LATEST_GIT_SHA'", "version":1}' "${MY_PIVOTAL_CICD}" + + + + ### Code to add the comments to the pivotal story + curl -v -X POST -H "X-TrackerToken: $TRACKER_API_TOKEN" -H "Accept: application/json" -H "Content-Type: application/json" --data '{ "text":"Squad-5 Pipelinedeployed the new code to AWS Prod-Server from artifactory using docker compose and completed the Sanity testing. Code is live to end-user \\n **Story ID**: '{story_nbr}' \\n **BRANCH**: '${my_merge_branch}' \\n **REPO**: '${MY_REPO}'\\n \\n \\n Story status is updated to **ACCEPTED** " }' "${MY_PIVOTAL_STORIES}/{story_nbr}/comments" + + curl -v -X PUT -H "X-TrackerToken: $TRACKER_API_TOKEN" -H "Accept: application/json" -H "Content-Type: application/json" --data '{"current_state":"accepted"}' "${MY_PIVOTAL_STORIES}/${story_nbr}" + + + ''' + } + } + failure { + script { + sh ''' + ### Code to update the Story CICD Pipeline status + export story_nbr=`git show ':/^Merge' --oneline| xargs| awk '{print $7}' | cut -d '/' -f2 | cut -d '-' -f1` + export NEW_LATEST_GIT_SHA=$(git rev-parse HEAD) + + curl -v -X POST -H "X-TrackerToken: $TRACKER_API_TOKEN" -H "Content-Type: application/json" -d '{"status":"failed", "url":"'$BUILD_URL'", "uuid":"9c1a65985558b645d869c2adf0f162fc", "story_ids":['${story_nbr}'], "latest_git_sha":"'$NEW_LATEST_GIT_SHA'", "version":1}' "${MY_PIVOTAL_CICD}" + ''' + } + } + } + tools { + maven 'Maven3.6.3' + jdk 'JDK' + } + environment { + SONAR_AUTH = credentials('sonar-login') + TRACKER_API_TOKEN = credentials('tracker-api-token') + MY_REPO="https://github.com/devopsbcsquad5/DevOps-Demo-WebApp" + MY_PIVOTAL_CICD="https://www.pivotaltracker.com/services/v5/projects/2490801/cicd" + MY_PIVOTAL_STORIES="https://www.pivotaltracker.com/services/v5/projects/2490801/stories" + } +} diff --git a/README.md b/README.md index 8e684e418d..dd4ade0c1e 100644 --- a/README.md +++ b/README.md @@ -4,3 +4,11 @@ This is a sample project used for learning the devops end to end concepts my intial commit 01/26 testing polling SCM + +testing JIRA polling + +NEw commit for Dp-4 + +NEw commit for Dp-4 second time + +Starting new commit - 177411384 diff --git a/TestServerCreation.yml b/TestServerCreation.yml new file mode 100644 index 0000000000..d6ad322f88 --- /dev/null +++ b/TestServerCreation.yml @@ -0,0 +1,23 @@ +--- #sonar qube creation +- hosts: "{{ myhostserver }}" + become: yes + tasks: + - name: "Transfer the Tomcat installation script" + copy: + src: tomcat.sh + dest: /root/tomcat.sh + tags: tomcatInstall + - name: "Transfer the postgresql installation script" + copy: + src: postgresql.sh + dest: /root/postgresql.sh + - name: "Install Tomcat" + shell: bash tomcat.sh > tomcatinstallLog.txt + tags: tomcatInstall + - name: "Install Postgresql" + shell: bash postgresql.sh > postgresqlinstallLog.txt + tags: postgresqlInstall + - name: "Install Java" + apt: + name: openjdk-8-jdk + state: present diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000000..ba376e0484 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,31 @@ +version: "3" + +services: + tomcat: + image: tomcat:8-jdk8-openjdk-slim + container_name: webserver + ports: + - 8080:8080 + networks: + - webappnet + restart: on-failure + volumes: + - /opt/tomcat/webapps:/usr/local/tomcat/webapps + - /opt/tomcat/logs:/usr/local/tomcat/logs + + db: + image: devopsbcsquad5/postgresdbsquad5 + container_name: postgresdb + ports: + - 5432:5432 + networks: + - webappnet + environment: + - POSTGRES_PASSWORD=password + - PGDATA=/var/lib/postgresql/data/pgdata + restart: on-failure + volumes: + - /opt/postgresql:/var/lib/postgresql/data + +networks: + webappnet: \ No newline at end of file diff --git a/dwnldArtifact.yml b/dwnldArtifact.yml new file mode 100644 index 0000000000..5ad6944c18 --- /dev/null +++ b/dwnldArtifact.yml @@ -0,0 +1,10 @@ +--- +- hosts: "{{ deployservers }}" + tasks: + - name: Download artifact test + become: true + get_url: + url: https://devopssquad5.jfrog.io/artifactory/squad5-libs-release-local/AVNCommunication-1.0.war + dest: /opt/tomcat/webapps/{{lcp}}Webapp.war + url_username: devopsbc.squad5.jfrog@gmail.com + url_password: AP6VPuxua2CQhM633iiB9Qnd8Ue \ No newline at end of file diff --git a/functionaltest/src/test/java/functionaltest/ftat.java b/functionaltest/src/test/java/functionaltest/ftat.java index 33478958cd..b356a9dda4 100644 --- a/functionaltest/src/test/java/functionaltest/ftat.java +++ b/functionaltest/src/test/java/functionaltest/ftat.java @@ -16,8 +16,8 @@ public class ftat { public HtmlUnitDriver driver; //public WebDriver driver; public WebDriverWait wait; - public String URL = "http://172.31.46.182:8080/QAWebapp/"; - public String URL1 = "http://172.31.46.182:8080/QAWebapp/avncreatepage.jsp"; + public String URL = "http://squadtestserver:8080/QAWebapp/"; + public String URL1 = "http://squadtestserver:8080/QAWebapp/avncreatepage.jsp"; //public String URL = "http://localhost:8080/AVNCommunication-1.0/avnlogin.jsp"; //public String URL1 = "http://localhost:8080/AVNCommunication-1.0/avncreatepage.jsp"; @@ -51,9 +51,9 @@ public void viewrepairticket() throws Exception { WebElement prepair = wait.until(ExpectedConditions .visibilityOfElementLocated(By.xpath("//p[text()='REPAIR']"))); prepair.isDisplayed(); - driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS); + driver.manage().timeouts().implicitlyWait(25, TimeUnit.SECONDS); driver.get(URL1); - driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS); + driver.manage().timeouts().implicitlyWait(25, TimeUnit.SECONDS); WebElement repair = wait.until( ExpectedConditions.visibilityOfElementLocated(By.xpath("//font[text()='Create Repair Ticket']"))); repair.isDisplayed(); diff --git a/postgresql.sh b/postgresql.sh new file mode 100644 index 0000000000..f8c3749ab2 --- /dev/null +++ b/postgresql.sh @@ -0,0 +1,68 @@ +#!/bin/bash -ex + +# This script is for use with the DevOps Challenge of installing PostgreSQL 9.6 on to a instance running Ubuntu. + +# Section 1 - Variable Creation + +# $rfolder is the install directory for PostgreSQL +rfolder='/postgres' +# $dfolder is the root directory for various types of read-only data files +dfolder='/postgres/data' +# $sysuser is the system user for running PostgreSQL +sysuser='postgres' +# $scripts directory +scripts="/home/$USER/scripts" +#scripts="scripts" +# $sqlscript is the sql script for creating the PSQL user and creating a database. +sqlscript="$scripts/initial-table.sql" +# $logfile is the log file for this installation. +logfile='psqlinstall-log' + +# Section 2 - Package Installation + +# Ensures the server is up to date before proceeding. +echo "Updating server..." +sudo apt-get update -y >> $logfile + +# This for-loop will pull all packages from the package array and install them using apt-get +echo "Installing PostgreSQL dependencies" +sudo apt-get install ${packages[@]} -y >> $logfile + + +# Section 3 - Create required directories +echo "Creating folders $dfolder..." +sudo mkdir -p $dfolder >> $logfile +sudo mkdir -p $scripts >> $logfile + +# Section 4 - Create system user + +#echo "Creating system user '$sysuser'" +#sudo adduser --system $sysuser >> $logfile + +# Section 5 - Installing PSQL + +echo "installing PostgreSQL" +sudo apt-get install -y postgresql postgresql-contrib +echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/10/main/pg_hba.conf +sed -i 's+localhost+*+gI' /etc/postgresql/10/main/postgresql.conf +sed -i 's+#listen_addresses+listen_addresses+gI' /etc/postgresql/10/main/postgresql.conf +#listen_addresses = 'localhost' +# Section 7 - Start PSQL + +echo "Wait for PostgreSQL to finish starting up..." +sleep 5 + + +# Section 8 - initial-table.sql script is ran + +# The initial-table.sql script is downloaded and ran to create the user, database, and populate the database. +echo "Downloading SQL script" +wget -P $scripts https://raw.githubusercontent.com/devopsbc01/Scripts/master/initial-table.sql + +echo "Running script" +#$rfolder/bin/psql -U postgres -f $sqlscript + +sudo -u postgres psql -f $sqlscript + +echo "Restarting postgres DB" +sudo /etc/init.d/postgresql restart diff --git a/src/test/java/servlet/cancelpage.java b/src/test/java/servlet/cancelpage.java index f38f8bce12..c3c2ec875a 100644 --- a/src/test/java/servlet/cancelpage.java +++ b/src/test/java/servlet/cancelpage.java @@ -17,7 +17,7 @@ public void doPost(HttpServletRequest req,HttpServletResponse res) try { Class.forName("org.postgresql.Driver"); - String jdbcUrl="jdbc:postgresql://172.31.46.182:5432/postgres"; + String jdbcUrl="jdbc:postgresql://squadtestserver:5432/postgres"; String username="postgres"; String password="password"; diff --git a/src/test/java/servlet/createpage.java b/src/test/java/servlet/createpage.java index 7269a16311..e1625a0043 100644 --- a/src/test/java/servlet/createpage.java +++ b/src/test/java/servlet/createpage.java @@ -17,7 +17,7 @@ public void doPost(HttpServletRequest req,HttpServletResponse res) try { Class.forName("org.postgresql.Driver"); - String jdbcUrl="jdbc:postgresql://172.31.46.182:5432/postgres"; + String jdbcUrl="jdbc:postgresql://squadtestserver:5432/postgres"; String username="postgres"; String password="password"; diff --git a/src/test/java/servlet/viewticket.java b/src/test/java/servlet/viewticket.java index 0ad7e27bb8..7709a6bdca 100644 --- a/src/test/java/servlet/viewticket.java +++ b/src/test/java/servlet/viewticket.java @@ -16,7 +16,7 @@ public void service(HttpServletRequest req,HttpServletResponse res) try { Class.forName("org.postgresql.Driver"); - String jdbcUrl="jdbc:postgresql://172.31.46.182:5432/postgres"; + String jdbcUrl="jdbc:postgresql://squadtestserver:5432/postgres"; String username="postgres"; String password="password"; diff --git a/tomcat.sh b/tomcat.sh new file mode 100644 index 0000000000..7b8f4fd7a6 --- /dev/null +++ b/tomcat.sh @@ -0,0 +1,26 @@ +#bash to install tomcat + +#---------------------- +echo "Updating server..." +sudo apt-get -y update +sudo apt-get -y upgrade +echo "Updating Java..." +sudo apt-get install -y default-jdk +echo "Installing tomcat8..." +sudo apt-get install -y tomcat8 +sudo apt-get install -y tomcat8-docs tomcat8-examples tomcat8-admin +#bash to admin-user in tomcat +#---------------------------- +sed -i 's++ +gI' /var/lib/tomcat8/conf/tomcat-users.xml +echo ' ' >> /var/lib/tomcat8/conf/tomcat-users.xml +echo ' ' >> /var/lib/tomcat8/conf/tomcat-users.xml +echo ' ' >> /var/lib/tomcat8/conf/tomcat-users.xml +echo ' ' >> /var/lib/tomcat8/conf/tomcat-users.xml +echo ' ' >> /var/lib/tomcat8/conf/tomcat-users.xml +echo ' ' >> /var/lib/tomcat8/conf/tomcat-users.xml +echo "" >> /var/lib/tomcat8/conf/tomcat-users.xml +#bash to restart tomcat +#---------------------- +echo "Restart tomcat8..." +sudo service tomcat8 restart +sleep 5