Skip to content
Snippets Groups Projects
Commit c985f9f2 authored by Morten Nyang Nordseth's avatar Morten Nyang Nordseth
Browse files

Initial commit

parents
Branches master
No related tags found
No related merge requests found
Pipeline #46426 passed
Showing with 1789 additions and 0 deletions
# Build files for deployment
target/
# Created by https://www.gitignore.io/api/linux,windows,intellij+all,visualstudiocode
# Edit at https://www.gitignore.io/?templates=linux,windows,intellij+all,visualstudiocode
### Intellij+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
# JetBrains templates
**___jb_tmp___
### Intellij+all Patch ###
# Ignores the whole .idea folder and all .iml files
# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360
.idea/
# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023
*.iml
modules.xml
.idea/misc.xml
*.ipr
# Sonarlint plugin
.idea/sonarlint
### Linux ###
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
### VisualStudioCode Patch ###
# Ignore all local history of files
.history
### Windows ###
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
# End of https://www.gitignore.io/api/linux,windows,intellij+all,visualstudiocode
# This file is a template, and might need editing before it works on your project.
# Full project: https://gitlab.com/pages/doxygen
image: alpine
pages:
script:
- apk update && apk add doxygen
- doxygen docs/Doxyfile
- mv docs/html/ public/
artifacts:
paths:
- public
only:
- master
FROM jetty:latest
COPY ./target/chat.war /var/lib/jetty/webapps/root.war
\ No newline at end of file
pipeline {
agent any
tools {
maven 'M3'
}
stages {
stage('Test') {
steps{
echo 'Test'
sh 'docker-compose -f docker-compose-test.yaml up -d'
withEnv(["DB_CHOICE=localhost"]) {
sh 'mvn clean test'
}
}
}
stage('Build') {
steps{
echo 'Build'
sh 'mvn clean package -Dmaven.test.skip=true'
sh 'docker build -t devops .'
}
}
stage('Deploy') {
steps{
echo 'Deploy'
sh 'docker-compose up -d'
}
}
}
}
\ No newline at end of file
README.md 0 → 100644
<h1>Chat applikasjon</h1>
Chat applikasjon med RESTful Java backend (JAX-RS).
## Innhold
- [Hvordan kjøre prosjektet lokalt](#hvordan-kjøre-prosjektet-lokalt)
- [JavaDocs](#javadocs)
- [Mappestruktur](#mappestruktur)
- [Endepunkter](#endepunkter)
- [Databasemodell](#databasemodell)
- [Docker og Maven](#docker-og-maven)
- [Informasjon om server](#informasjon-om-server)
- [Informasjon om klient](#informasjon-om-klient)
- [Informasjon om tester](#informasjon-om-tester)
- [Systemet som helhet](#systemet-som-helhet)
- [Porter](#porter)
## Hvordan kjøre prosjektet lokalt
For å kjøre prosjektet lokalt trenger man Maven på maskinen. Det kan lastes ned [her](https://maven.apache.org/download.cgi). Pakk ut Maven og les README som
følger med for å innstallere Maven.
For at meldingsapplikasjonen skal fungere trenger man en tilkobling til database for lokal kjøring. Drifterne setter opp databaser på VM.
I filen Databse.java må IP til VM legges til i varaiabelen "IP_TO_VM"
Når Maven er installert, og databasetilkobling er satt opp kan prosjektet kjøres med følgende kommando:
```text
mvn jetty:run
```
Her er det vikitg at man står i rot-katalogen når man kjører kommandoen.
Meldingsapplikasjonen er nå tilgjengelig på [http://localhost:8080](http://localhost:8080). Endringer som gjøres i
prosjektet lokalt blir automatisk oppdatert. For å stoppe kjøring av prosjektet trykk på Ctrl+C.
## JavaDocs
Ved hjelp av Gitlab-CI og Doxygen genereres JavaDocs automatisk hver gang nye endringer blir pushet til master. Deretter
blir det automatisk hostet på Gitlab Pages:
[JavaDocs](http://magnewor.pages.stud.idi.ntnu.no/devops/)
## Mappestruktur
```text
devops/
├── docs/
| └── Doxyfile
|
├── gatling/
| ├── chat/
| | └── ChatSimulation.scala
| |
| └── usernames.csv
|
├── groupChat/
| ├── GroupChatDAO.txt
| ├── GroupChatDAOTest.txt
| └── GroupChatResourceTest.txt
|
├── sql/
| └── myChat.sql
|
├── src/
| ├── main/
| | ├── java/
| | | ├── dao/
| | | | ├── Database.java
| | | | ├── GroupChatDAO.java
| | | | ├── MessageDAO.java
| | | | └── UserDAO.java
| | | |
| | | ├── data/
| | | | ├── GroupChat.java
| | | | ├── Message.java
| | | | └── User.java
| | | |
| | | ├── resources/
| | | | ├── CalculatorResource.java
| | | | ├── GroupChatResource.java
| | | | ├── MessageResource.java
| | | | └── UserResource.java
| | | |
| | | └── websockets/
| | | └── Websocket.java
| | |
| | └── webapp/
| | ├── css/
| | | ├── app.css
| | | ├── index.css
| | | ├── popupform.css
| | | └── settings.css
| | |
| | ├── js/
| | | ├── calculator.js
| | | ├── createElements.js
| | | ├── groupchat.js
| | | ├── index.js
| | | ├── message.js
| | | ├── responsive.js
| | | ├── settings.js
| | | ├── user.js
| | | └── websocket.js
| | |
| | ├── WEB-INF/
| | | └── web.xml
| | |
| | ├── app.html
| | ├── index.html
| | └── settings.html
| |
| └── test/
| └── java/
| ├── CalculatorResourceTest.java
| ├── MessageDAOTest.java
| ├── MessageResourceTest.java
| ├── UserDAOTest.java
| └── UserResourceTest.java
|
├── .gitignore
├── .gitlab-ci.yml
├── database.png
├── Dockerfile
├── Jenkinsfile
├── docker-compose-logging.yaml
├── docker-compose-test.yaml
├── docker-compose.yaml
├── glances.conf
├── installGatling
├── pom.xml
├── README.md
├── runGatling
├── runLogging
└── setupJenkins
```
## Endepunkter
Endepunkt er URI som ressurser blir tilgjengelig på. Hvert endepunkt har en funskjon der de henter, legger til, eller endrer på informasjonen som tilhører adressen.
Et typisk endepunkt som bruker en GET-forespørsel henter ut HTML-side eller annen data fra server.
| Endepunkt | Verb | Hva | Type |
| --------- | --- | --- | ---- |
| / | GET | Loginside | HTML |
| /app.html | GET | Applikasjonside | HTML |
| /settings.html | GET | Innstillingside | HTML |
| /user | GET | Hent alle brukere | Data |
| | POST | Legge til bruker | Data |
| /user/{userId} | PUT | Endre bruker | Data |
| /message/{userId1}/{userId2} | GET | Hent meldinger mellom to brukere | Data |
| /message | POST | Legge til ny melding | Data |
| /groupchat | POST | Legge til ny gruppechat | Data |
| /groupchat/{groupChatId} | GET | Hent ut et gruppechat objekt | Data |
| /groupchat/{groupChatId}/message | GET | Hent ut meldinger til en gruppechat | Data |
| | POST | Legge til ny melding | Data |
| /groupchat/user/{userId} | GET | Hent ut alle gruppechatter for en bruker | Data |
| /calculator | POST | Send inn regnestykke til kalkulatorbot | Data |
## Databasemodell
![Databasemodell](./database.png)
## Docker og Maven
Dette systemet bruker Maven. Maven er et verktøy som hjelper til å håndtere dependencies i systemet. Ved å bruke Maven
forsikrer man at alle bruker samme versjon av depencies, og at man lett kan endre de på kun et sted, dersom det
endres hva som trengs for å kjøre systemet. I tillegg brukes Maven både til å kompilere systemet og kjøre tester.
Dependencies deklareres i filen pom.xml. Filen web.xml brukes for å sette URLer i den ferdig kompilerte applikasjonen.
Docker er et verktøy som lar oss kjøre forskjellige programmer i egne konteinere for kjøring av systemet. Dette
er blant annet database, testdatabase, database klient og server som kan kjøre chat applikasjonen. Filene som brukes til dette er
Dockerfile og docker-compose. Dockerfile er en fil med oppskrift til hvordan en enkelt konteiner skal bygges. Filene
som starter med docker-compose er oppsett av flere konteinere i samme miljø. Her er også en av fordelene at man lett kan
bytte verktøy som brukes, eller versjoner av verktøyene. Ved hjelp av docker kan utviklerene enkelt levere kode og
dockerfiler til drifterene, som kun trenger å bruke dockerfilene for å kjøre og rulle ut systemet.
## Informasjon om server
Server består av fire mapper:
- dao
- data
- resources
- websocket
DAO står for Data Access Object, og brukes av systemet for å kommunisere med databasen. I dao mappa finner vi også
klassen Database, som er filen som sørger for tilkobling til databasen. Ved hjelp av dao klassene kan vi bruke java
objekter til å kommunisere med databasen.
I data mappa finner vi objektklassene som brukes i systemet. Vi har GroupChat, Message og User.
Resources er filene som brukes for kommunikasjon mellom klient og server. Her brukes rammeverket JAX-RS for å lage
webtjenester som er RESTful. I resource filene brukes det følgende annoteringer:
- @Path
- @GET
- @POST
- @PUT
- @Consumes
- @Produces
@Path bestemmer hvilke adresse ressursene skal være tilgjengelige på. @GET, @POST og @PUT setter hvilke HTTP verb metoden
svarer til. @Consumes og @Produces definerer hva metodene tar inn, og returnerer.
Websocket er nødvendig for å hente inn nye chatmeldinger etterhvert som de skrives. Alternativet til websockets er å
hele tiden sende forespørsler for å sjekke om det er noen nye meldinger tilgjengelig.
## Informasjon om klient
Klient består av tre forskjellige typer filer:
- HTML
- CSS
- JS
HTML filene er innholdet. CSS filene er utseende og utformingen. JavaScript er filene som bestemmer hvordan de
forskjellige elementene på siden reagerer på brukerinteraskjon, og brukes også til å endre innholdet på siden. Endringer
kan for eksempel være nye brukere som logger på, som må legges til i brukerlista.
## Informasjon om tester
Til testing brukes testrammeverket JUnit. I tillegg settes det opp en testdatabase med docker, slik at testene kan
kjøres opp mot denne. Når testene kjøres blir databasen slettet, og opprettet på nytt. Dette forsikrer at resultatet av
testene ikke er avhengig av innholdet på databasen, og at den andre databasen ikke fylles opp av testdata.
Testene kan kjøres lokalt med kommando:
```text
mvn clean test
```
Her er det vikitg at man står i rot-katalogen når man kjører kommandoen.
Dette krever at Maven er innstallert på maskinen. Alternativt kan testene også kjøres i IDE.
## Systemet som helhet
Klient-siden bruker endepunkter for å kommunisere med server. På server peker de forskjellige endepunktene på metoder i
resource klassene. Resource klassene bruker DAO klassene for å kommunisere med databasen. For å sende data til og motta
data fra databasen bruker DAO klassene objektklasser. For å varsle andre brukere om nye hendelser i sanntid, brukes
websockets.
## Porter
| Port | Hva |
| ------ | ------ |
| 80 | Chat applikasjon |
| 3306 | Test database |
| 3307 | Database til lokal kjøring |
| 3308 | Database til lokal testing |
| 8070 | Adminer (Databaseklient) |
| 8080 | Jenkins |
\ No newline at end of file
database.png

29.9 KiB

# Use root/example as user/password credentials
version: '3.1'
services:
local-db:
image: mysql
command: --default-authentication-plugin=mysql_native_password
restart: always
volumes:
- ./sql:/docker-entrypoint-initdb.d
environment:
MYSQL_ROOT_PASSWORD: example
ports:
- 3307:3306
local-test-db:
image: mysql
command: --default-authentication-plugin=mysql_native_password
restart: always
volumes:
- ./sql:/docker-entrypoint-initdb.d
environment:
MYSQL_ROOT_PASSWORD: example
ports:
- 3308:3306
adminer:
image: adminer
restart: always
ports:
- 8070:8080
\ No newline at end of file
version: '3.1'
services:
grafana:
image: grafana/grafana
restart: always
ports:
- 3000:3000
influxdb:
image: influxdb
restart: always
environment:
INFLUXDB_DB: glances
ports:
- 8086:8086
# Use root/example as user/password credentials
version: '3.1'
services:
test-db:
image: mysql
command: --default-authentication-plugin=mysql_native_password
restart: always
volumes:
- ./sql:/docker-entrypoint-initdb.d
environment:
MYSQL_ROOT_PASSWORD: example
ports:
- 3306:3306
\ No newline at end of file
# Use root/example as user/password credentials
version: '3.1'
services:
db:
image: mysql
command: --default-authentication-plugin=mysql_native_password
restart: always
volumes:
- ./sql:/docker-entrypoint-initdb.d
environment:
MYSQL_ROOT_PASSWORD: example
webserver:
environment:
DB_CHOICE: db
image: devops
restart: always
ports:
- 80:8080
depends_on:
- db
This diff is collapsed.
package chat
import scala.concurrent.duration._
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._
class ChatSimulation extends Simulation {
val httpProtocol = http
.baseURL("http://localhost")
.inferHtmlResources(BlackList(""".*\.css""", """.*\.js""", """.*\.ico"""), WhiteList())
.acceptHeader("*/*")
.acceptEncodingHeader("gzip, deflate")
.acceptLanguageHeader("no,en;q=0.9,en-US;q=0.8,nb-NO;q=0.7,nb;q=0.6")
.userAgentHeader("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.80 Safari/537.36")
val headers_0 = Map(
"Content-Type" -> "application/json; charset=utf-8;",
"Origin" -> "http://localhost"
)
val headers_3 = Map(
"Accept" -> "application/json",
"Content-Type" -> "application/json",
"Origin" -> "http://localhost"
)
val uri1 = "http://localhost/api"
private val userFeeder = csv("usernames.csv").random
val scn = scenario("ChatSimulation")
.feed(userFeeder)
.exec(http("Login")
.post("/api/user")
.headers(headers_0)
.body(StringBody(
"""{
| "username": "${username}",
| "password": "passordpassord"
|}""".stripMargin))
.resources(http("Fetch users")
.get("/api/user/"))
.check(
jsonPath("$[?(@.username=='${username}')].userId").findAll.saveAs("userId")
))
.pause(6)
.exec(http("Click on Ola")
.get("/api/message/${userId(0)}/1"))
.pause(16)
.exec(http("Send msg to Ola")
.post("/api/message")
.headers(headers_3)
.body(StringBody(
"""{
| "userId1": ${userId(0)},
| "userId2": 1,
| "messageContent":"Hei fra gatling"
|}""".stripMargin)))
.pause(15)
.exec(http("Click on kari")
.get("/api/message/${userId(0)}/2"))
.pause(2)
.exec(http("Send msg to Kari")
.post("/api/message")
.headers(headers_3)
.body(StringBody(
"""{
| "userId1": ${userId(0)},
| "userId2": 2,
| "messageContent":"Hei fra gatling"
|}""".stripMargin)))
setUp(scn.inject(atOnceUsers(100))).protocols(httpProtocol)
}
This diff is collapsed.
##############################################################################
# Globals Glances parameters
##############################################################################
[global]
# Does Glances should check if a newer version is available on PyPI ?
check_update=true
# History size (maximum number of values)
# Default is 28800: 1 day with 1 point every 3 seconds (default refresh time)
history_size=28800
##############################################################################
# User interface
##############################################################################
[outputs]
# Theme name for the Curses interface: black or white
curse_theme=black
# Limit the number of processes to display in the WebUI
max_processes_display=30
##############################################################################
# plugins
##############################################################################
[quicklook]
# Set to true to disable a plugin
# Note: you can also disable it from the command line (see --disable-plugin)
disable=false
# Define CPU, MEM and SWAP thresholds in %
cpu_careful=50
cpu_warning=70
cpu_critical=90
mem_careful=50
mem_warning=70
mem_critical=90
swap_careful=50
swap_warning=70
swap_critical=90
[cpu]
disable=False
# Default values if not defined: 50/70/90 (except for iowait)
user_careful=50
user_warning=70
user_critical=90
#user_log=False
system_careful=50
system_warning=70
system_critical=90
steal_careful=50
steal_warning=70
steal_critical=90
#steal_log=True
# I/O wait percentage should be lower than 1/# (Logical CPU cores)
# Leave commented to just use the default config (1/#-20% / 1/#-10% / 1/#)
#iowait_careful=30
#iowait_warning=40
#iowait_critical=50
# Context switch limit (core / second)
# Leave commented to just use the default config (critical is 50000*# (Logical CPU cores)
#ctx_switches_careful=10000
#ctx_switches_warning=12000
#ctx_switches_critical=14000
[percpu]
# Define CPU thresholds in %
# Default values if not defined: 50/70/90
user_careful=50
user_warning=70
user_critical=90
iowait_careful=50
iowait_warning=70
iowait_critical=90
system_careful=50
system_warning=70
system_critical=90
[gpu]
# Default processor values if not defined: 50/70/90
proc_careful=50
proc_warning=70
proc_critical=90
# Default memory values if not defined: 50/70/90
mem_careful=50
mem_warning=70
mem_critical=90
[mem]
# Define RAM thresholds in %
# Default values if not defined: 50/70/90
careful=50
#careful_action_repeat=echo {{percent}} >> /tmp/memory.alert
warning=70
critical=90
[memswap]
# Define SWAP thresholds in %
# Default values if not defined: 50/70/90
careful=50
warning=70
critical=90
[load]
# Define LOAD thresholds
# Value * number of cores
# Default values if not defined: 0.7/1.0/5.0 per number of cores
# Source: http://blog.scoutapp.com/articles/2009/07/31/understanding-load-averages
# http://www.linuxjournal.com/article/9001
careful=0.7
warning=1.0
critical=5.0
#log=False
[network]
# Default bitrate thresholds in % of the network interface speed
# Default values if not defined: 70/80/90
rx_careful=70
rx_warning=80
rx_critical=90
tx_careful=70
tx_warning=80
tx_critical=90
# Define the list of hidden network interfaces (comma-separated regexp)
#hide=docker.*,lo
# WLAN 0 alias
#wlan0_alias=Wireless IF
# It is possible to overwrite the bitrate thresholds per interface
# WLAN 0 Default limits (in bits per second aka bps) for interface bitrate
#wlan0_rx_careful=4000000
#wlan0_rx_warning=5000000
#wlan0_rx_critical=6000000
#wlan0_rx_log=True
#wlan0_tx_careful=700000
#wlan0_tx_warning=900000
#wlan0_tx_critical=1000000
#wlan0_tx_log=True
[wifi]
# Define the list of hidden wireless network interfaces (comma-separated regexp)
hide=lo,docker.*
# Define SIGNAL thresholds in db (lower is better...)
# Based on: http://serverfault.com/questions/501025/industry-standard-for-minimum-wifi-signal-strength
careful=-65
warning=-75
critical=-85
[diskio]
# Define the list of hidden disks (comma-separated regexp)
#hide=sda2,sda5,loop.*
hide=loop.*
# Alias for sda1
#sda1_alias=IntDisk
[fs]
# Define the list of hidden file system (comma-separated regexp)
hide=/boot.*,/snap.*
# Define filesystem space thresholds in %
# Default values if not defined: 50/70/90
# It is also possible to define per mount point value
# Example: /_careful=40
careful=50
warning=70
critical=90
# Allow additional file system types (comma-separated FS type)
#allow=zfs
[folders]
# Define a folder list to monitor
# The list is composed of items (list_#nb <= 10)
# An item is defined by:
# * path: absolute path
# * careful: optional careful threshold (in MB)
# * warning: optional warning threshold (in MB)
# * critical: optional critical threshold (in MB)
#folder_1_path=/tmp
#folder_1_careful=2500
#folder_1_warning=3000
#folder_1_critical=3500
#folder_2_path=/home/nicolargo/Videos
#folder_2_warning=17000
#folder_2_critical=20000
#folder_3_path=/nonexisting
#folder_4_path=/root
[sensors]
# Sensors core thresholds (in Celsius...)
# Default values if not defined: 60/70/80
temperature_core_careful=60
temperature_core_warning=70
temperature_core_critical=80
# Temperatures threshold in °C for hddtemp
# Default values if not defined: 45/52/60
temperature_hdd_careful=45
temperature_hdd_warning=52
temperature_hdd_critical=60
# Battery threshold in %
battery_careful=80
battery_warning=90
battery_critical=95
# Sensors alias
#temp1_alias=Motherboard 0
#temp2_alias=Motherboard 1
#core 0_alias=CPU Core 0
#core 1_alias=CPU Core 1
[processlist]
# Define CPU/MEM (per process) thresholds in %
# Default values if not defined: 50/70/90
cpu_careful=50
cpu_warning=70
cpu_critical=90
mem_careful=50
mem_warning=70
mem_critical=90
#
# Nice priorities range from -20 to 19.
# Configure nice levels using a comma separated list.
#
# Nice: Example 1, non-zero is warning (default behavior)
nice_warning=-20,-19,-18,-17,-16,-15,-14,-13,-12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19
#
# Nice: Example 2, low priority processes escalate from careful to critical
#nice_careful=1,2,3,4,5,6,7,8,9
#nice_warning=10,11,12,13,14
#nice_critical=15,16,17,18,19
[ports]
# Ports scanner plugin configuration
# Interval in second between two scans
refresh=30
# Set the default timeout (in second) for a scan (can be overwritten in the scan list)
timeout=3
# If port_default_gateway is True, add the default gateway on top of the scan list
port_default_gateway=True
#
# Define the scan list (1 < x < 255)
# port_x_host (name or IP) is mandatory
# port_x_port (TCP port number) is optional (if not set, use ICMP)
# port_x_description is optional (if not set, define to host:port)
# port_x_timeout is optional and overwrite the default timeout value
# port_x_rtt_warning is optional and defines the warning threshold in ms
#
#port_1_host=192.168.0.1
#port_1_port=80
#port_1_description=Home Box
#port_1_timeout=1
#port_2_host=www.free.fr
#port_2_description=My ISP
#port_3_host=www.google.com
#port_3_description=Internet ICMP
#port_3_rtt_warning=1000
#port_4_description=Internet Web
#port_4_host=www.google.com
#port_4_port=80
#port_4_rtt_warning=1000
#
# Define Web (URL) monitoring list (1 < x < 255)
# web_x_url is the URL to monitor (example: http://my.site.com/folder)
# web_x_description is optional (if not set, define to URL)
# web_x_timeout is optional and overwrite the default timeout value
# web_x_rtt_warning is optional and defines the warning respond time in ms (approximatively)
#
#web_1_url=https://blog.nicolargo.com
#web_1_description=My Blog
#web_1_rtt_warning=3000
#web_2_url=https://github.com
#web_3_url=http://www.google.fr
#web_3_description=Google Fr
#web_4_url=https://blog.nicolargo.com/nonexist
#web_4_description=Intranet
[docker]
# Thresholds for CPU and MEM (in %)
#cpu_careful=50
#cpu_warning=70
#cpu_critical=90
#mem_careful=20
#mem_warning=50
#mem_critical=70
#
# Per container thresholds
#containername_cpu_careful=10
#containername_cpu_warning=20
#containername_cpu_critical=30
#
# By default, Glances only display running containers
# Set the following key to True to display all containers
all=False
##############################################################################
# Client/server
##############################################################################
[serverlist]
# Define the static servers list
#server_1_name=localhost
#server_1_alias=My local PC
#server_1_port=61209
#server_2_name=localhost
#server_2_port=61235
#server_3_name=192.168.0.17
#server_3_alias=Another PC on my network
#server_3_port=61209
#server_4_name=pasbon
#server_4_port=61237
[passwords]
# Define the passwords list
# Syntax: host=password
# Where: host is the hostname
# password is the clear password
# Additionally (and optionally) a default password could be defined
#localhost=abc
#default=defaultpassword
##############################################################################
# Exports
##############################################################################
[graph]
# Configuration for the --export graph option
# Set the path where the graph (.svg files) will be created
# Can be overwrite by the --graph-path command line option
path=/tmp
# It is possible to generate the graphs automatically by setting the
# generate_every to a non zero value corresponding to the seconds between
# two generation. Set it to 0 to disable graph auto generation.
generate_every=60
# See followings configuration keys definitions in the Pygal lib documentation
# http://pygal.org/en/stable/documentation/index.html
width=800
height=600
style=DarkStyle
[influxdb]
# Configuration for the --export influxdb option
# https://influxdb.com/
host=localhost
port=8086
user=root
password=root
db=glances
# Prefix will be added for all measurement name
# Ex: prefix=foo
# => foo.cpu
# => foo.mem
# You can also use dynamic values
#prefix=`hostname`
prefix=localhost
# Tags will be added for all measurements
#tags=foo:bar,spam:eggs
# You can also use dynamic values
#tags=system:`uname -s`
[cassandra]
# Configuration for the --export cassandra option
# Also works for the ScyllaDB
# https://influxdb.com/ or http://www.scylladb.com/
host=localhost
port=9042
protocol_version=3
keyspace=glances
replication_factor=2
# If not define, table name is set to host key
table=localhost
[opentsdb]
# Configuration for the --export opentsdb option
# http://opentsdb.net/
host=localhost
port=4242
#prefix=glances
#tags=foo:bar,spam:eggs
[statsd]
# Configuration for the --export statsd option
# https://github.com/etsy/statsd
host=localhost
port=8125
#prefix=glances
[elasticsearch]
# Configuration for the --export elasticsearch option
# Data are available via the ES RESTful API. ex: URL/<index>/cpu/system
# https://www.elastic.co
host=localhost
port=9200
index=glances
[riemann]
# Configuration for the --export riemann option
# http://riemann.io
host=localhost
port=5555
[rabbitmq]
# Configuration for the --export rabbitmq option
host=localhost
port=5672
user=guest
password=guest
queue=glances_queue
[mqtt]
# Configuration for the --export mqtt option
host=localhost
port=8883
user=guest
password=guest
topic=glances
[couchdb]
# Configuration for the --export couchdb option
# https://www.couchdb.org
host=localhost
port=5984
db=glances
# user and password are optional (comment if not configured on the server side)
#user=root
#password=root
[kafka]
# Configuration for the --export kafka option
# http://kafka.apache.org/
host=localhost
port=9092
topic=glances
#compression=gzip
[zeromq]
# Configuration for the --export zeromq option
# http://www.zeromq.org
# Use * to bind on all interfaces
host=*
port=5678
# Glances envelopes the stats in a publish message with two frames:
# - First frame containing the following prefix (STRING)
# - Second frame with the Glances plugin name (STRING)
# - Third frame with the Glances plugin stats (JSON)
prefix=G
[prometheus]
# Configuration for the --export prometheus option
# https://prometheus.io
# Create a Prometheus exporter listening on localhost:9091 (default configuration)
# Metric are exporter using the following name:
# <prefix>_<plugin>_<stats> (all specials character are replaced by '_')
# Note: You should add this exporter to your Prometheus server configuration:
# scrape_configs:
# - job_name: 'glances_exporter'
# scrape_interval: 5s
# static_configs:
# - targets: ['localhost:9091']
host=localhost
port=9091
prefix=glances
# Labels will be added for all measurements
#labels=foo:bar,spam:eggs
# You can also use dynamic values
#labels=system:`uname -s`
[restful]
# Configuration for the --export RESTful option
# Example, export to http://localhost:6789/
host=localhost
port=6789
protocol=http
path=/
##############################################################################
# AMPS
# * enable: Enable (true) or disable (false) the AMP
# * regex: Regular expression to filter the process(es)
# * refresh: The AMP is executed every refresh seconds
# * one_line: (optional) Force (if true) the AMP to be displayed in one line
# * command: (optional) command to execute when the process is detected (thk to the regex)
# * countmin: (optional) minimal number of processes
# A warning will be displayed if number of process < count
# * countmax: (optional) maximum number of processes
# A warning will be displayed if number of process > count
# * <foo>: Others variables can be defined and used in the AMP script
##############################################################################
[amp_dropbox]
# Use the default AMP (no dedicated AMP Python script)
# Check if the Dropbox daemon is running
# Every 3 seconds, display the 'dropbox status' command line
enable=false
regex=.*dropbox.*
refresh=3
one_line=false
command=dropbox status
countmin=1
[amp_python]
# Use the default AMP (no dedicated AMP Python script)
# Monitor all the Python scripts
# Alert if more than 20 Python scripts are running
enable=false
regex=.*python.*
refresh=3
countmax=20
[amp_nginx]
# Use the NGinx AMP
# Nginx status page should be enable (https://easyengine.io/tutorials/nginx/status-page/)
enable=false
regex=\/usr\/sbin\/nginx
refresh=60
one_line=false
status_url=http://localhost/nginx_status
[amp_systemd]
# Use the Systemd AMP
enable=false
regex=\/lib\/systemd\/systemd
refresh=30
one_line=true
systemctl_cmd=/bin/systemctl --plain
[amp_systemv]
# Use the Systemv AMP
enable=false
regex=\/sbin\/init
refresh=30
one_line=true
service_cmd=/usr/bin/service --status-all
package dao;
import data.GroupChat;
import data.Message;
import data.User;
import java.sql.*;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.TimeZone;
import static dao.Database.close;
/**
* Data access object for GroupChat
*/
public class GroupChatDAO {
/**
* Add a new GroupChat
* @param groupChat GroupChat to be added
* @return GroupChat, empty GroupChat object if unsuccessful
*/
public GroupChat addGroupChat(GroupChat groupChat){
PreparedStatement preparedStatement = null;
Connection connection = null;
ResultSet resultSet = null;
try{
connection = Database.instance().getConnection();
preparedStatement = connection.prepareStatement("INSERT INTO groupChat (groupChatName) VALUES (?)", Statement.RETURN_GENERATED_KEYS);
preparedStatement.setString(1, groupChat.getGroupChatName());
int result = preparedStatement.executeUpdate();
if(result == 1){
resultSet = preparedStatement.getGeneratedKeys();
if(resultSet.next()){
int groupChatId = resultSet.getInt(1);
groupChat.setGroupChatId(groupChatId);
ArrayList<User> users = groupChat.getUserList();
preparedStatement = connection.prepareStatement("INSERT INTO user_groupChat (userId, groupChatId) VALUES (?, ?) ");
for(User user:users){
preparedStatement.setInt(1, user.getUserId());
preparedStatement.setInt(2, groupChatId);
preparedStatement.executeUpdate();
}
return groupChat;
}
}
}catch (SQLException e){
e.printStackTrace();
}finally{
close(connection, preparedStatement, resultSet);
}
return new GroupChat();
}
/**
* Get a GroupChat, with given groupChatId
* @param groupChatId groupChatId as int
* @return requested GroupChat if found, empty GroupChat object if not found
*/
public GroupChat getGroupChat(int groupChatId){
PreparedStatement preparedStatement = null;
Connection connection = null;
ResultSet resultSet = null;
GroupChat groupChat = new GroupChat();
try{
connection = Database.instance().getConnection();
preparedStatement = connection.prepareStatement("SELECT * FROM groupChat WHERE groupChatId = ?");
preparedStatement.setInt(1, groupChatId);
resultSet = preparedStatement.executeQuery();
while(resultSet.next()) {
groupChat.setGroupChatId(groupChatId);
groupChat.setGroupChatName(resultSet.getString("groupChatName"));
}
}catch(SQLException e){
e.printStackTrace();
}finally{
close(connection, preparedStatement, resultSet);
}
return groupChat;
}
/**
* Get all GroupChats for user with given userId
* @param userId int userId of the user
* @return ArrayList of GroupChats
*/
public ArrayList<GroupChat> getGroupChatByUserId(int userId){
ArrayList<GroupChat> groupChats = new ArrayList<>();
PreparedStatement preparedStatement = null;
Connection connection = null;
ResultSet resultSet = null;
try{
connection = Database.instance().getConnection();
preparedStatement = connection.prepareStatement("SELECT * FROM groupChat WHERE groupChatId IN (SELECT groupChatId FROM user_groupChat WHERE userId = ?)");
preparedStatement.setInt(1, userId);
resultSet = preparedStatement.executeQuery();
GroupChat groupChat;
while(resultSet.next()){
groupChat = new GroupChat();
groupChat.setGroupChatId(resultSet.getInt("groupChatId"));
groupChat.setGroupChatName(resultSet.getString("groupChatName"));
groupChats.add(groupChat);
}
return groupChats;
}catch (SQLException e){
e.printStackTrace();
}finally{
close(connection, preparedStatement, resultSet);
}
return groupChats;
}
/**
* Get all messages for a GroupChat
* @param groupChatId groupChatId as int
* @return ArrayList of Messages
*/
public ArrayList<Message> getGroupChatMessages(int groupChatId){
ArrayList<Message> messages = new ArrayList<>();
PreparedStatement preparedStatement = null;
Connection connection = null;
ResultSet resultSet = null;
try{
connection = Database.instance().getConnection();
preparedStatement = connection.prepareStatement("SELECT * FROM message WHERE groupChatId = ?");
preparedStatement.setInt(1, groupChatId);
resultSet = preparedStatement.executeQuery();
Message message;
while(resultSet.next()){
message = new Message();
message.setMessageId(resultSet.getInt("messageId"));
message.setUserId1(resultSet.getInt("userId1"));
Calendar cal = Calendar.getInstance();
cal.setTimeZone(TimeZone.getTimeZone("UTC"));
message.setTimestamp(resultSet.getTimestamp("timestamp",cal));
message.setMessageContent(resultSet.getString("messageContent"));
message.setGroupChatId(resultSet.getInt("groupChatId"));
messages.add(message);
}
}catch (SQLException e){
e.printStackTrace();
}finally {
close(connection, preparedStatement, resultSet);
}
return messages;
}
/**
* Adds a Message to a GroupChat
* @param groupChatId groupChatId as int
* @param message Message object to be added to GroupChat
* @return The message that was added
*/
public Message addMessage(int groupChatId, Message message){
PreparedStatement preparedStatement = null;
Connection connection = null;
try{
connection = Database.instance().getConnection();
preparedStatement = connection.prepareStatement("INSERT INTO message (userId1, timestamp, messageContent, groupChatId) VALUES (?, NOW(), ?, ?)");
preparedStatement.setInt(1, message.getUserId1());
preparedStatement.setString(2, message.getMessageContent());
preparedStatement.setInt(3, groupChatId);
preparedStatement.executeUpdate();
}catch (SQLException e){
e.printStackTrace();
}finally{
close(connection, preparedStatement, null);
}
return message;
}
/**
* Get all users in a GroupChat
* @param groupChatId groupChatId as int
* @return ArrayList of Users the GroupChat
*/
public ArrayList<User> getGroupChatUsers(int groupChatId){
ArrayList<User> users = new ArrayList<>();
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
Connection connection = null;
try{
connection = Database.instance().getConnection();
preparedStatement = connection.prepareStatement("SELECT * FROM user WHERE user.userId IN (SELECT userId FROM user_groupChat WHERE groupChatId = ?)");
preparedStatement.setInt(1, groupChatId);
resultSet = preparedStatement.executeQuery();
User user;
while(resultSet.next()){
user = new User();
user.setUserId(resultSet.getInt("userId"));
user.setUsername(resultSet.getString("username"));
users.add(user);
}
}catch(SQLException e){
e.printStackTrace();
}finally{
close(connection, preparedStatement, resultSet);
}
return users;
}
}
import dao.Database;
import dao.GroupChatDAO;
import data.GroupChat;
import data.Message;
import data.User;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
import org.glassfish.jersey.test.TestProperties;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import javax.ws.rs.core.Application;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
public class GroupChatDAOTest extends JerseyTest {
private Connection connection;
private Statement statement;
private GroupChatDAO groupChatDAO;
@Before
public void SetUp () {
try{
connection = Database.instance().getConnection();
groupChatDAO = new GroupChatDAO();
statement = connection.createStatement();
} catch (SQLException se) {
System.out.println("Could not connect to test-database");
se.printStackTrace();
}
//DROP TABLE queries
String dropTableUserGroupChat = "DROP TABLE IF EXISTS user_groupChat";
String dropTableGroupChat = "DROP TABLE IF EXISTS groupChat";
String dropTableMessage = "DROP TABLE IF EXISTS message";
String dropTableUser = "DROP TABLE IF EXISTS user";
//CREATE TABLE
String createTableUser =
"CREATE TABLE user (\n" +
" userId INT(11) NOT NULL AUTO_INCREMENT,\n" +
" username VARCHAR(64) NOT NULL UNIQUE,\n" +
" password TEXT,\n" +
" salt BLOB,\n" +
" PRIMARY KEY (userId)\n" +
")";
String createTableMessage =
"CREATE TABLE message (\n" +
" messageId INT(11) NOT NULL AUTO_INCREMENT,\n" +
" userId1 INT(11) NOT NULL,\n" +
" userId2 INT(11),\n" +
" timestamp TIMESTAMP NOT NULL,\n" +
" messageContent VARCHAR (500) NOT NULL,\n" +
" groupChatId INT(11),\n" +
" PRIMARY KEY (messageId),\n" +
" KEY userId1 (userId1),\n" +
" KEY userId2 (userId2),\n" +
" CONSTRAINT message_ibfk_3 FOREIGN KEY (userId1) REFERENCES user (userId) ON DELETE CASCADE ON UPDATE CASCADE,\n" +
" CONSTRAINT message_ibfk_4 FOREIGN KEY (userId2) REFERENCES user (userId) ON DELETE CASCADE ON UPDATE CASCADE,\n" +
" CONSTRAINT message_ibfk_5 foreign key (groupChatId) REFERENCES groupChat (groupChatId) ON DELETE CASCADE ON UPDATE CASCADE\n" +
")";
String createTableGroupChat =
"CREATE TABLE groupChat(\n" +
" groupChatId INT(11) NOT NULL AUTO_INCREMENT,\n" +
" groupChatName VARCHAR(64) NOT NULL,\n" +
" PRIMARY KEY (groupChatId)\n" +
")";
String createTableUserGroupChat =
"CREATE TABLE user_groupChat (\n" +
" userId INT(11) NOT NULL,\n" +
" groupChatId INT(11) NOT NULL,\n" +
" PRIMARY KEY (userId, groupChatId),\n" +
" CONSTRAINT user_groupChat_ibfk_3 FOREIGN KEY (userId) REFERENCES user (userId) ON DELETE CASCADE ON UPDATE CASCADE,\n" +
" CONSTRAINT user_groupChat_ibfk_4 FOREIGN KEY (groupChatId) REFERENCES groupChat (groupChatId) ON DELETE CASCADE ON UPDATE CASCADE\n" +
")";
//INSERT INTO statements
String insertUser = "INSERT INTO user (username) VALUES ('username')";
String insertUser2 = "INSERT INTO user (username) VALUES ('username2')";
String insertMessage = "INSERT INTO message (userId1, userId2, TIMESTAMP , messageContent) VALUES (1, 2, NOW(), 'test message')";
String insertMessage2 = "INSERT INTO message (userId1, userId2, TIMESTAMP, messageContent) VALUES (2, 1, NOW(), 'test response message')";
String insertGroupChat = "INSERT INTO groupChat (groupChatName) VALUES ('groupchat')";
String insertUserGroupChat = "INSERT INTO user_groupChat (userId, groupChatId) VALUES (1, 1)";
String insertGroupChatMessage = "INSERT INTO message (userId1, TIMESTAMP , messageContent, groupChatId) VALUES (1, NOW(), 'test groupchat message', 1)";
try {
// execute queries
statement.executeUpdate(dropTableMessage);
statement.executeUpdate(dropTableUserGroupChat);
statement.executeUpdate(dropTableGroupChat);
statement.executeUpdate(dropTableUser);
statement.executeUpdate(createTableUser);
statement.executeUpdate(createTableGroupChat);
statement.executeUpdate(createTableUserGroupChat);
statement.executeUpdate(createTableMessage);
// execute insert updates
statement.executeUpdate(insertUser);
statement.executeUpdate(insertUser2);
statement.executeUpdate(insertMessage);
statement.executeUpdate(insertMessage2);
statement.executeUpdate(insertGroupChat);
statement.executeUpdate(insertUserGroupChat);
statement.executeUpdate(insertGroupChatMessage);
} catch (SQLException se) {
System.out.println("Error: insert statements");
se.printStackTrace();
} finally {
try {
statement.close();
} catch (SQLException se) {
se.printStackTrace();
}
}
}
@After
public void tearDown () {
try {
groupChatDAO = null;
connection.close();
} catch (SQLException se) {
System.out.println("disconnecting failed");
se.printStackTrace();
}
}
@Override
public Application configure() {
enable(TestProperties.LOG_TRAFFIC);
enable(TestProperties.DUMP_ENTITY);
forceSet(TestProperties.CONTAINER_PORT, "0");
return new ResourceConfig(GroupChatDAO.class);
}
@Test
public void testAddGroupChat() {
GroupChat groupChat = new GroupChat();
groupChat.setGroupChatName("test groupchat");
groupChatDAO.addGroupChat(groupChat);
GroupChat groupChatFromDatabase = groupChatDAO.getGroupChat(2);
assertEquals(groupChat.getGroupChatName(), groupChatFromDatabase.getGroupChatName());
assertEquals(groupChat.getGroupChatId(), groupChatFromDatabase.getGroupChatId());
}
@Test
public void testGetGroupChat() {
final GroupChat expectedResult = new GroupChat(1, "groupchat");
final GroupChat result = groupChatDAO.getGroupChat(1);
assertEquals(expectedResult.getGroupChatId(), result.getGroupChatId());
assertEquals(expectedResult.getGroupChatName(), result.getGroupChatName());
}
@Test
public void testGetGroupChatByUserId() {
final List<GroupChat> result1 = groupChatDAO.getGroupChatByUserId(1);
final List<GroupChat> result2 = groupChatDAO.getGroupChatByUserId(2);
assertEquals("User 1 should have 1 Groupchat", 1, result1.size());
assertEquals("User 2 should have 0 Groupchats", 0, result2.size());
}
@Test
public void testGetGroupChatMessages() {
ArrayList<String> expectedResult = new ArrayList<>();
expectedResult.add("test groupchat message");
ArrayList<Message> result = groupChatDAO.getGroupChatMessages(1);
ArrayList<String> resultStrings = new ArrayList<>();
for (Message message : result) resultStrings.add(message.getMessageContent());
assertEquals(expectedResult, resultStrings);
}
@Test
public void testAddMessage() {
final int groupChatId = 1;
Message message = new Message();
message.setUserId1(1);
message.setTimestamp(new Timestamp(1220227200L * 1000));
message.setMessageContent("test add message groupchat");
message.setGroupChatId(groupChatId);
ArrayList<Message> beforeAddMessage = groupChatDAO.getGroupChatMessages(groupChatId);
groupChatDAO.addMessage(groupChatId, message);
ArrayList<Message> afterAddMessage = groupChatDAO.getGroupChatMessages(groupChatId);
assertNotEquals(beforeAddMessage.size(), afterAddMessage.size());
}
@Test
public void testGetGroupChatUsers() {
final int groupChatId = 1;
ArrayList<String> expected = new ArrayList<>();
expected.add("username");
final ArrayList<User> result = groupChatDAO.getGroupChatUsers(groupChatId);
ArrayList<String> resultUsernames = new ArrayList<>();
for (User user : result) resultUsernames.add(user.getUsername());
assertEquals(expected, resultUsernames);
}
}
import data.GroupChat;
import data.Message;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
import org.glassfish.jersey.test.TestProperties;
import org.junit.Test;
import resources.GroupChatResource;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
public class GroupChatResourceTest extends JerseyTest {
private final GroupChatResource groupChatResource = new GroupChatResource();
private int groupChatId = 1;
@Override
public Application configure() {
enable(TestProperties.LOG_TRAFFIC);
enable(TestProperties.DUMP_ENTITY);
return new ResourceConfig(GroupChatResource.class);
}
@Test
public void testGetGroupChat() {
Response output = target("groupchat/" + groupChatId).request().get();
assertEquals("Should return status 200", 200, output.getStatus());
assertEquals("application/json", output.getHeaderString("Content-type"));
assertNotNull(output.getEntity());
}
@Test
public void testGetGroupChatByUserId() {
int userId = 1;
Response output = target("groupchat/user/" + userId).request().get();
assertEquals("Should return status 200", 200, output.getStatus());
assertEquals("application/json", output.getHeaderString("Content-type"));
assertNotNull(output.getEntity());
}
@Test
public void testGetMessages() {
Response output = target("groupchat/" + groupChatId + "/message").request().get();
assertEquals("Should return status 200", 200, output.getStatus());
assertEquals("application/json", output.getHeaderString("Content-type"));
assertNotNull(output.getEntity());
}
@Test
public void testPostGroupChat() {
GroupChat groupChat = new GroupChat();
groupChat.setGroupChatName("testPostGroupChat");
Response output = target("/groupchat").request().post(Entity.entity(groupChat, MediaType.APPLICATION_JSON));
assertEquals("Should return status 200",200,output.getStatus());
assertEquals("application/json",output.getHeaderString("Content-type"));
assertEquals("testPostGroupChat", groupChatResource.postGroupChat(groupChat).getGroupChatName());
}
@Test
public void testPostMessage() {
Message groupChatMessage = new Message();
groupChatMessage.setUserId1(1);
groupChatMessage.setMessageContent("testPostMessage");
groupChatMessage.setGroupChatId(groupChatId);
Response output = target("groupchat/" + groupChatId + "/message").request().post(Entity.entity(groupChatMessage, MediaType.APPLICATION_JSON));
assertEquals("Should return status 200",200, output.getStatus());
assertEquals("application/json", output.getHeaderString("Content-type"));
assertEquals("testPostMessage", groupChatResource.postMessage(groupChatId, groupChatMessage).getMessageContent());
}
}
#!/bin/bash
wget https://repo1.maven.org/maven2/io/gatling/highcharts/gatling-charts-highcharts-bundle/2.3.1/gatling-charts-highcharts-bundle-2.3.1-bundle.zip
mv gatling-charts-highcharts-bundle-2.3.1-bundle.zip ~/Desktop
cd ~/Desktop
unzip gatling-charts-highcharts-bundle-2.3.1-bundle.zip
echo Gatling Stress Tool installed
pom.xml 0 → 100644
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>no.ntnu</groupId>
<artifactId>devops-workshop</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>chat</name>
<build>
<finalName>chat</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<inherited>true</inherited>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.4.19.v20190610</version>
</plugin>
</plugins>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>${jersey.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<!-- use the following artifactId if you don't need servlet 2.x compatibility -->
<!-- artifactId>jersey-container-servlet</artifactId -->
</dependency>
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
<exclusions>
<exclusion>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-binding</artifactId>
<exclusions>
<exclusion>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
</exclusion>
<exclusion>
<groupId>javax.json</groupId>
<artifactId>javax.json-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- TEST DEPENDENCIES -->
<dependency>
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
<artifactId>jersey-test-framework-provider-jetty</artifactId>
<version>2.26</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<!-- TEST DEPENDENCIES END -->
<dependency>
<groupId>c3p0</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.1.2</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.16</version>
</dependency>
<dependency>
<groupId>javax.websocket</groupId>
<artifactId>javax.websocket-api</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
</dependencies>
<properties>
<jersey.version>2.26</jersey.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
#!/bin/bash
cd gatling
cp -r chat ~/Desktop/gatling-charts-highcharts-bundle-2.3.1/user-files/simulations
cp usernames.csv ~/Desktop/gatling-charts-highcharts-bundle-2.3.1/user-files/data
cd ~/Desktop/gatling-charts-highcharts-bundle-2.3.1/bin
./gatling.sh
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment