Skip to content

Commit d4b893e

Browse files
authored
Merge pull request #495 from devicehive/development
Development
2 parents bddfe89 + 710e903 commit d4b893e

151 files changed

Lines changed: 1997 additions & 1123 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Jenkinsfile

Lines changed: 48 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
properties([
2-
buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '7', numToKeepStr: '7'))
2+
buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '32', daysToKeepStr: '', numToKeepStr: '100'))
33
])
44

55
def test_branches = ["development", "master"]
66
def publish_branches = ["development", "master"]
77
def deploy_branches = ["development"]
8+
def test_rpc = true
89

910
stage('Build jars') {
1011
node('docker') {
@@ -51,28 +52,30 @@ stage('Build and publish Docker images in CI repository') {
5152
if (test_branches.contains(env.BRANCH_NAME)) {
5253
stage('Run integration tests'){
5354
parallel rpc: {
54-
stage('Run integration tests with rpc'){
55-
node('tests-runner'){
56-
try {
57-
clone_devicehive_docker()
58-
dir('devicehive-docker/rdbms-image'){
59-
writeFile file: '.env', text: """COMPOSE_PROJECT_NAME=ci
60-
COMPOSE_FILE=docker-compose.yml:ci-images.yml
61-
DH_TAG=${BRANCH_NAME}
62-
JWT_SECRET=devicehive
63-
DH_FE_SPRING_PROFILES_ACTIVE=rpc-client
64-
DH_BE_SPRING_PROFILES_ACTIVE=rpc-server
65-
"""
66-
67-
start_devicehive()
55+
if (test_rpc) {
56+
stage('Run integration tests with rpc'){
57+
node('tests-runner'){
58+
try {
59+
clone_devicehive_docker()
60+
dir('devicehive-docker/rdbms-image'){
61+
writeFile file: '.env', text: """COMPOSE_PROJECT_NAME=rpc
62+
COMPOSE_FILE=docker-compose.yml:ci-images.yml:dh_proxy_custom_certificate.yml:dh_plugin.yml:dh_plugin-ci-image.yml
63+
DH_TAG=${BRANCH_NAME}
64+
JWT_SECRET=devicehive
65+
DH_FE_SPRING_PROFILES_ACTIVE=rpc-client
66+
DH_BE_SPRING_PROFILES_ACTIVE=rpc-server
67+
"""
68+
69+
start_devicehive()
70+
}
71+
wait_for_devicehive_is_up()
72+
run_devicehive_tests()
73+
} finally {
74+
archive_container_logs('rpc')
75+
zip archive: true, dir: 'devicehive-tests', glob: 'mochawesome-report/**', zipFile: 'mochawesome-report-rpc.zip'
76+
shutdown_devicehive()
77+
cleanWs()
6878
}
69-
wait_for_devicehive_is_up()
70-
run_devicehive_tests()
71-
} finally {
72-
archive_container_logs('rpc')
73-
zip archive: true, dir: 'devicehive-tests', glob: 'mochawesome-report/**', zipFile: 'mochawesome-report.zip'
74-
shutdown_devicehive()
75-
cleanWs()
7679
}
7780
}
7881
}
@@ -83,8 +86,8 @@ if (test_branches.contains(env.BRANCH_NAME)) {
8386
try {
8487
clone_devicehive_docker()
8588
dir('devicehive-docker/rdbms-image'){
86-
writeFile file: '.env', text: """COMPOSE_PROJECT_NAME=ci
87-
COMPOSE_FILE=docker-compose.yml:ci-images.yml
89+
writeFile file: '.env', text: """COMPOSE_PROJECT_NAME=wsproxy
90+
COMPOSE_FILE=docker-compose.yml:ci-images.yml:dh_proxy_custom_certificate.yml:dh_plugin.yml:dh_plugin-ci-image.yml
8891
DH_TAG=${BRANCH_NAME}
8992
JWT_SECRET=devicehive
9093
"""
@@ -94,8 +97,8 @@ if (test_branches.contains(env.BRANCH_NAME)) {
9497
wait_for_devicehive_is_up()
9598
run_devicehive_tests()
9699
} finally {
97-
archive_container_logs('ws-proxy')
98-
zip archive: true, dir: 'devicehive-tests', glob: 'mochawesome-report/**', zipFile: 'mochawesome-report.zip'
100+
archive_container_logs('wsproxy')
101+
zip archive: true, dir: 'devicehive-tests', glob: 'mochawesome-report/**', zipFile: 'mochawesome-report-wsproxy.zip'
99102
shutdown_devicehive()
100103
cleanWs()
101104
}
@@ -135,6 +138,7 @@ if (deploy_branches.contains(env.BRANCH_NAME)) {
135138
node('dev-server') {
136139
dir('/home/centos/devicehive-docker/rdbms-image'){
137140
sh '''
141+
echo "$(date): Deploying build #${BUILD_NUMBER} from ${BRANCH_NAME} branch..." > ./jenkins-cd.timestamp
138142
sed -i -e "s/DH_TAG=.*/DH_TAG=${BRANCH_NAME}/g" .env
139143
sudo docker-compose pull
140144
sudo docker-compose up -d
@@ -149,6 +153,10 @@ def clone_devicehive_docker(){
149153
dir('devicehive-docker'){
150154
echo("Clone Docker Compose files")
151155
git branch: 'development', url: 'https://github.com/devicehive/devicehive-docker.git', depth: 1
156+
sh '''
157+
mkdir ../ssl || :
158+
tar -xakf rdbms-image/tests/localhost_cert.tar.gz -C ../ssl
159+
'''
152160
}
153161
}
154162

@@ -189,7 +197,8 @@ def run_devicehive_tests() {
189197
jq ".server.ip = \\"127.0.0.1\\"" | \\
190198
jq ".server.port = \\"80\\"" | \\
191199
jq ".server.restUrl = \\"http://127.0.0.1/api/rest\\"" | \\
192-
jq ".server.authRestUrl = \\"http://127.0.0.1/auth/rest\\"" > config.json
200+
jq ".server.authRestUrl = \\"http://127.0.0.1/auth/rest\\"" | \\
201+
jq ".server.pluginRestUrl = \\"http://127.0.0.1/plugin/rest\\"" > config.json
193202
'''
194203

195204
timeout(time:10, unit: 'MINUTES') {
@@ -200,20 +209,21 @@ def run_devicehive_tests() {
200209
}
201210

202211
def archive_container_logs(flavour) {
203-
def logsdir = "${flavour}-container-logs"
212+
def logsdir = "container-logs"
204213
sh """
205214
mkdir ${logsdir} || :
206-
sudo docker logs ci_dh_auth_1 > ${logsdir}/auth.log 2>&1
207-
sudo docker logs ci_dh_backend_1 > ${logsdir}/backend.log 2>&1
208-
sudo docker logs ci_dh_frontend_1 > ${logsdir}/frontend.log 2>&1
209-
sudo docker logs ci_dh_proxy_1 > ${logsdir}/proxy.log 2>&1
210-
sudo docker logs ci_hazelcast_1 > ${logsdir}/hazelcast.log 2>&1
211-
sudo docker logs ci_kafka_1 > ${logsdir}/kafka.log 2>&1
212-
sudo docker logs ci_wsproxy_1 > ${logsdir}/wsproxy.log 2>&1
213-
sudo docker logs ci_postgres_1 > ${logsdir}/postgres.log 2>&1
214-
sudo docker logs ci_zookeeper_1 > ${logsdir}/zookeeper.log 2>&1
215+
sudo docker logs ${flavour}_dh_auth_1 > ${logsdir}/${flavour}_auth.log 2>&1
216+
sudo docker logs ${flavour}_dh_backend_1 > ${logsdir}/${flavour}_backend.log 2>&1
217+
sudo docker logs ${flavour}_dh_frontend_1 > ${logsdir}/${flavour}_frontend.log 2>&1
218+
sudo docker logs ${flavour}_dh_plugin_1 > ${logsdir}/${flavour}_plugin.log 2>&1
219+
sudo docker logs ${flavour}_dh_proxy_1 > ${logsdir}/${flavour}_proxy.log 2>&1
220+
sudo docker logs ${flavour}_hazelcast_1 > ${logsdir}/${flavour}_hazelcast.log 2>&1
221+
sudo docker logs ${flavour}_kafka_1 > ${logsdir}/${flavour}_kafka.log 2>&1
222+
sudo docker logs ${flavour}_wsproxy_1 > ${logsdir}/${flavour}_wsproxy.log 2>&1
223+
sudo docker logs ${flavour}_postgres_1 > ${logsdir}/${flavour}_postgres.log 2>&1
224+
sudo docker logs ${flavour}_zookeeper_1 > ${logsdir}/${flavour}_zookeeper.log 2>&1
215225
"""
216-
def logs = "${logsdir}/auth.log, ${logsdir}/backend.log, ${logsdir}/frontend.log, ${logsdir}/proxy.log, ${logsdir}/hazelcast.log, ${logsdir}/kafka.log, ${logsdir}/wsproxy.log, ${logsdir}/postgres.log, ${logsdir}/zookeeper.log"
226+
def logs = "${logsdir}/${flavour}_auth.log, ${logsdir}/${flavour}_backend.log, ${logsdir}/${flavour}_frontend.log, ${logsdir}/${flavour}_plugin.log, ${logsdir}/${flavour}_proxy.log, ${logsdir}/${flavour}_hazelcast.log, ${logsdir}/${flavour}_kafka.log, ${logsdir}/${flavour}_wsproxy.log, ${logsdir}/${flavour}_postgres.log, ${logsdir}/${flavour}_zookeeper.log"
217227
archiveArtifacts artifacts: logs, fingerprint: true
218228
}
219229

README.md

Lines changed: 66 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@ It provides the communication layer, control software and multi-platform
1111
libraries to bootstrap development of smart energy, home automation, remote
1212
sensing, telemetry, remote control and monitoring software and much more.
1313

14-
Connect embedded Linux using Python or C++ libraries and JSON protocol or
15-
connect AVR, Microchip devices using lightweight C libraries and BINARY protocol.
16-
Develop client applications using HTML5/JavaScript, iOS and Android libraries.
17-
For solutions involving gateways, there is also gateway middleware that allows
18-
to interface with devices connected to it. Leave communications to DeviceHive
19-
and focus on actual product and innovation.
14+
Connect embedded Linux using Python, Node.js or Java libraries and JSON format.
15+
Write and read your data via REST, Websockets or MQTT, explore visualization on [Grafana](https://grafana.com/plugins/devicehive-devicehive-datasource/installation) charts.
16+
17+
Develop client applications using HTML5/JavaScript and Android libraries.
18+
Leave communications to DeviceHive and focus on actual product and innovation.
2019

2120
DeviceHive license
2221
------------------
@@ -32,35 +31,42 @@ highly encouraged to do so!
3231

3332
Docker Container
3433
=========================================
35-
We have published a DeviceHive docker container so you can utilize docker's virtualization features with DeviceHive.
36-
Check out [DeviceHive on Docker Hub](https://hub.docker.com/r/devicehive/devicehive/) with the instructions on
37-
how to use it. You can check dockerfile implementation as well as the script for setting up a new instance running
38-
under nginx on [DeviceHive Docker](https://github.com/devicehive/devicehive-docker)
34+
DeviceHive could be deployed manually, via Docker Compose or to Kubernetes cluster.
35+
Our suggestion is to start from [Docker Compose](https://docs.docker.com/compose/) - the easiest way to start your
36+
mastering DeviceHive capabilities. Instructions could be found [here](https://github.com/devicehive/devicehive-docker/tree/master/rdbms-image).
37+
In case you're more familiar with [Kubernetes](https://kubernetes.io/), please follow this
38+
[link](https://github.com/devicehive/devicehive-docker/tree/master/k8s) for detailed instructions.
3939

4040
DeviceHive Java installation instructions
4141
=========================================
4242

43+
Though docker-compose installation is the most developer-friendly way of running DeviceHive locally, sometimes it's required
44+
to build and start project manually. Below you can find detailed instructions on that.
45+
4346
Prerequisites
4447
-------------
4548
In order to use DeviceHive framework you must have the following components installed and configured:
4649
* [PostgreSQL 9.1](http://www.postgresql.org/download/) or above.
4750
* [Apache Kafka 0.10.0.0](http://kafka.apache.org/downloads.html) or above.
48-
* [Oracle JDK 8](http://www.oracle.com/technetwork/java/javase/downloads/index.html) or [OpenJDK 8](http://openjdk.java.net/)
49-
* [Maven](http://maven.apache.org/download.cgi)
50-
* [DeviceHiveJava source files](https://github.com/devicehive/devicehive-java-server). This is the main part of the [DeviceHive] framework
51+
* [DeviceHive Websocket Proxy](https://github.com/devicehive/devicehive-ws-proxy) running (relies on Kafka,
52+
so should be started only when Kafka is up and running).
53+
* [Hazelcast IMDG](https://hazelcast.com/use-cases/imdg/).
54+
* [Oracle JDK 8](http://www.oracle.com/technetwork/java/javase/downloads/index.html) or [OpenJDK 8](http://openjdk.java.net/).
55+
* [Maven](http://maven.apache.org/download.cgi).
56+
* [DeviceHiveJava source files](https://github.com/devicehive/devicehive-java-server). This is the main part of the [DeviceHive] framework.
5157

5258

5359
Build packages
5460
--------------
55-
* Download source code from [GitHub](https://github.com/devicehive/devicehive-java-server) using "Download ZIP" button.
61+
Download source code from [GitHub](https://github.com/devicehive/devicehive-java-server) using "Download ZIP" button.
5662
It should always point to recent stable or beta release, but you always can get any other tag or branch.
5763
It also can be done using one of [Git version control client](http://git-scm.com/downloads/guis) or git command line tool.
5864
If you prefer git, clone project using command
5965

6066
`git clone https://github.com/devicehive/devicehive-java-server.git`
6167

6268
After that you can switch to the tag or branch you need. The list of all available releases can be found at
63-
https://github.com/devicehive/devicehive-java-server/releases
69+
https://github.com/devicehive/devicehive-java-server/releases.
6470
Execute following command from ${devicehive-java-server-directory}.
6571

6672
`mvn clean package`
@@ -75,7 +81,7 @@ You need to update zookeeper.connect (zookeeper's contact point) and bootstrap.s
7581

7682
Running Hazelcast
7783
-----------------------
78-
To start download Hazelcast IMDG 3.8.1 from official site (`https://hazelcast.org/download/`), extract to local drive and create in Hazelcast bin folder file hzstart.sh with folling contents:
84+
To start, download Hazelcast IMDG 3.8.1 from official site (`https://hazelcast.org/download/`), extract to local drive and create in Hazelcast bin folder file hzstart.sh with following contents:
7985

8086
```bash
8187
export JAVA_OPTS="$JAVA_OPTS -cp /path/to/jar/from/devicehive-hazelcast/devicehive-common-<version>-shade.jar:/path/to/HAZELCAST_HOME/lib/hazelcast-all-3.8.1.jar"
@@ -122,11 +128,7 @@ in hazelcast.xml localted in bin folder of hazelcast. Also replace all the map a
122128
```
123129

124130

125-
Run hzstart.sh. At this ensure that correct value of property hazelcast.cluster.members is installed in
126-
127-
`/path/to/devicehive-java-server/devicehive-backend/src/main/resources/application.properties`
128-
129-
You can also pass this property in JAVA_OPTS when running devicehive-backend.
131+
Run hzstart.sh.
130132

131133
Starting database
132134
---------------------
@@ -137,13 +139,38 @@ the username is `postgres` and the password is `12345`. You can change this in t
137139
database.
138140
* Database schema will be initialized on application startup.
139141

142+
Checking properties
143+
---------------------
144+
145+
Each microservice has its own `src/main/resources/application.properties` file which contains all application-level
146+
configurations (db credentials, hazelcast address, kafka props etc.). Please check them before building application in
147+
order to avoid problems at runtime.
148+
149+
You can also override these values by passing them to JVM while running `java -Dapplication.property.name=application.property.name -jar`.
150+
For example:
151+
```
152+
java -Dhazelcast.cluster.members=0.0.0.1:5701 -jar ${devicehive-jar}.jar
153+
java -Dbootstrap.servers=0.0.0.1:9092 -jar ${devicehive-jar}.jar
154+
java -Dproxy.connect=0.0.0.1:3000 -jar ${devicehive-jar}.jar
155+
```
156+
157+
DB connection properties are managed inside `devicehive-rdbms-dao/src/main/resources/application-persistence.properties`.
158+
To override them do the same:
159+
```
160+
java -Dspring.datasource.url=jdbc:postgresql://0.0.0.1:5432/devicehive -jar ${devicehive-jar}.jar
161+
java -Dspring.datasource.username=test -Dspring.datasource.password=test -jar ${devicehive-jar}.jar
162+
```
163+
140164
Running application
141165
---------------------
142-
* To start application, you have to start backend, frontend and auth microservices. To do this, first run following command:
166+
DeviceHive ecosystem contains of 3 mandatory and 1 optional services, namely Backend, Frontend, Auth and Plugin
167+
management (optional) micro services.
168+
169+
* To start application, first run following command:
143170

144171
`java -jar ${devicehive-java-server-directory}/devicehive-backend/target/devicehive-backend-<version>-boot.jar`
145172

146-
Wait for the application to start, then run:
173+
This will start Backend. Wait for the application to start, then run:
147174

148175
`java -jar ${devicehive-java-server-directory}/devicehive-frontend/target/devicehive-frontend-<version>-boot.jar`
149176

@@ -152,13 +179,26 @@ and
152179
`java -jar ${devicehive-java-server-directory}/devicehive-auth/target/devicehive-auth-<version>-boot.jar`
153180

154181
This will start embedded undertow application server on default port 8080 and deploy DeviceHive application.
155-
You can visit http://localhost:8080/dh/swagger from your web browser to start learning the frontend's APIs.
156-
Also you can visit http://localhost:8090/dh/swagger from your web browser to start learning the auth's APIs.
182+
You can visit `http://localhost:8080/dh/swagger` from your web browser to start learning the frontend's APIs.
183+
Also you can visit `http://localhost:8090/dh/swagger` from your web browser to start learning the auth's APIs.
157184

158185
For devicehive-frontend and devicehive-backend logging level can be changed by adding the following properties to the command above:
159186

160187
`-Droot.log.level=value1 -Dcom.devicehive.log.level=value2`
161188

162189
The values can be: TRACE, DEBUG, INFO, WARN, ERROR. If the properties are absent the default values will be used.
163190
For devicehive-frontend and devicehive-auth default values for value1 and value2 are WARN and INFO correspondingly.
164-
For devicehive-backend the default value for both is INFO.
191+
For devicehive-backend the default value for both is INFO.
192+
193+
Plugin management service
194+
---------------------
195+
196+
There's one optional service inside DeviceHive ecosystem - Plugin Management service. It allows to register and to update
197+
DeviceHive plugins (that allow customers to implement their own business logic without diving into DeviceHive source code)
198+
via RESTful API.
199+
200+
To start it simply run following command:
201+
202+
`java -jar ${devicehive-java-server-directory}/devicehive-plugin/target/devicehive-plugin-<version>-boot.jar`
203+
204+
Service will be started on 8110 port by default, so you can visit its swagger at `http://localhost:8110/dh/swagger`

devicehive-auth/pom.xml

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>devicehive-server</artifactId>
77
<groupId>com.devicehive</groupId>
8-
<version>3.4.3</version>
8+
<version>3.4.4</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111
<packaging>jar</packaging>
@@ -20,7 +20,7 @@
2020
<dependencies>
2121
<dependency>
2222
<groupId>com.devicehive</groupId>
23-
<artifactId>devicehive-common-auth</artifactId>
23+
<artifactId>devicehive-common-service</artifactId>
2424
<version>${project.parent.version}</version>
2525
</dependency>
2626
<dependency>
@@ -143,5 +143,31 @@
143143
</dependency>
144144
</dependencies>
145145
</profile>
146+
<profile>
147+
<id>shim-kafka</id>
148+
<activation>
149+
<activeByDefault>true</activeByDefault>
150+
</activation>
151+
<dependencies>
152+
<dependency>
153+
<groupId>com.devicehive</groupId>
154+
<artifactId>devicehive-shim-kafka-impl</artifactId>
155+
<version>${project.parent.version}</version>
156+
</dependency>
157+
</dependencies>
158+
</profile>
159+
<profile>
160+
<id>proxy-ws-kafka</id>
161+
<activation>
162+
<activeByDefault>true</activeByDefault>
163+
</activation>
164+
<dependencies>
165+
<dependency>
166+
<groupId>com.devicehive</groupId>
167+
<artifactId>devicehive-proxy-ws-kafka-impl</artifactId>
168+
<version>${project.version}</version>
169+
</dependency>
170+
</dependencies>
171+
</profile>
146172
</profiles>
147173
</project>

0 commit comments

Comments
 (0)