mirror of
https://github.com/mainflux/mainflux.git
synced 2025-05-01 13:48:56 +08:00
NOISSUE - Makefile test target, CREATE TABLE and dev guide enhancements (#359)
* Fixes #337 Signed-off-by: Jovan Kostovski <chombium@gmail.com> * added create table if not exists Signed-off-by: Jovan Kostovski <chombium@gmail.com> * added test target in sync with Semaphore CI Signed-off-by: Jovan Kostovski <chombium@gmail.com> * added warning about the possible data loss Signed-off-by: Jovan Kostovski <chombium@gmail.com>
This commit is contained in:
parent
effade00aa
commit
8a86593dc3
3
Makefile
3
Makefile
@ -23,6 +23,9 @@ clean:
|
|||||||
install:
|
install:
|
||||||
cp ${BUILD_DIR}/* $(GOBIN)
|
cp ${BUILD_DIR}/* $(GOBIN)
|
||||||
|
|
||||||
|
test:
|
||||||
|
GOCACHE=off go test -v -race -tags test $(shell go list ./... | grep -v 'vendor\|cmd')
|
||||||
|
|
||||||
proto:
|
proto:
|
||||||
protoc --go_out=plugins=grpc:. *.proto
|
protoc --go_out=plugins=grpc:. *.proto
|
||||||
|
|
||||||
|
@ -64,6 +64,9 @@ make docker_http
|
|||||||
|
|
||||||
> N.B. Mainflux creates `FROM scratch` docker containers which as compact and small in size.
|
> N.B. Mainflux creates `FROM scratch` docker containers which as compact and small in size.
|
||||||
|
|
||||||
|
> N.B. The `things-db` and `users-db` containers are built from a vanilla PostgreSQL Docker image downloaded from Docker Hub which does not persist the data when these containers are rebuilt. Thus, __rebuilding of all Docker containers with `make dockers` or rebuilding the `things-db` and `users-db` containers separately with `make docker_things-db` and `make docker_users-db` respectively, will cause data loss. All your users, things, channels and connections between them will be lost!__ As we use this setup only for development, we don't guarantee any permanent data persistence. If you need to retain the data between the container rebuilds you can attach volume to the `things-db` and `users-db` containers. Check the official docs on how to use volumes [here](https
|
||||||
|
://docs.docker.com/storage/volumes/) and [here](https://docs.docker.com/compose/compose-file/#volumes).
|
||||||
|
|
||||||
### MQTT Microservice
|
### MQTT Microservice
|
||||||
MQTT Microservice in Mainflux is special, as it is currently the only microservice written in NodeJS. It is not compiled,
|
MQTT Microservice in Mainflux is special, as it is currently the only microservice written in NodeJS. It is not compiled,
|
||||||
but node modules need to be downloaded in order to start the service:
|
but node modules need to be downloaded in order to start the service:
|
||||||
@ -113,6 +116,13 @@ Cross-compilation for ARM with Mainflux make:
|
|||||||
GOOS=linux GOARCH=arm GOARM=7 make
|
GOOS=linux GOARCH=arm GOARM=7 make
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Running tests
|
||||||
|
To run all of the test you can execute:
|
||||||
|
```
|
||||||
|
make test
|
||||||
|
```
|
||||||
|
Dockertest is used for the test, so to run the tests you will need the Docker deamon/service running.
|
||||||
|
|
||||||
## Installing
|
## Installing
|
||||||
Installing Go binaries is simple: just move them from `build` to `$GOBIN` (do not fortget to add `$GOBIN` to your `$PATH`).
|
Installing Go binaries is simple: just move them from `build` to `$GOBIN` (do not fortget to add `$GOBIN` to your `$PATH`).
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ func migrateDB(db *sql.DB) error {
|
|||||||
{
|
{
|
||||||
Id: "things_1",
|
Id: "things_1",
|
||||||
Up: []string{
|
Up: []string{
|
||||||
`CREATE TABLE things (
|
`CREATE TABLE IF NOT EXISTS things (
|
||||||
id BIGSERIAL,
|
id BIGSERIAL,
|
||||||
owner VARCHAR(254),
|
owner VARCHAR(254),
|
||||||
type VARCHAR(10) NOT NULL,
|
type VARCHAR(10) NOT NULL,
|
||||||
@ -48,13 +48,13 @@ func migrateDB(db *sql.DB) error {
|
|||||||
metadata TEXT,
|
metadata TEXT,
|
||||||
PRIMARY KEY (id, owner)
|
PRIMARY KEY (id, owner)
|
||||||
)`,
|
)`,
|
||||||
`CREATE TABLE channels (
|
`CREATE TABLE IF NOT EXISTS channels (
|
||||||
id BIGSERIAL,
|
id BIGSERIAL,
|
||||||
owner VARCHAR(254),
|
owner VARCHAR(254),
|
||||||
name TEXT,
|
name TEXT,
|
||||||
PRIMARY KEY (id, owner)
|
PRIMARY KEY (id, owner)
|
||||||
)`,
|
)`,
|
||||||
`CREATE TABLE connections (
|
`CREATE TABLE IF NOT EXISTS connections (
|
||||||
channel_id BIGINT,
|
channel_id BIGINT,
|
||||||
channel_owner VARCHAR(254),
|
channel_owner VARCHAR(254),
|
||||||
thing_id BIGINT,
|
thing_id BIGINT,
|
||||||
|
@ -39,7 +39,7 @@ func migrateDB(db *sql.DB) error {
|
|||||||
{
|
{
|
||||||
Id: "users_1",
|
Id: "users_1",
|
||||||
Up: []string{
|
Up: []string{
|
||||||
`CREATE TABLE users (
|
`CREATE TABLE IF NOT EXISTS users (
|
||||||
email VARCHAR(254) PRIMARY KEY,
|
email VARCHAR(254) PRIMARY KEY,
|
||||||
password CHAR(60) NOT NULL
|
password CHAR(60) NOT NULL
|
||||||
)`,
|
)`,
|
||||||
|
@ -54,4 +54,4 @@ MF_THINGS_URL=[Things service URL] MF_NATS_URL=[NATS instance URL] MF_WS_ADAPTER
|
|||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
For more information about service capabilities and its usage, please check out
|
For more information about service capabilities and its usage, please check out
|
||||||
the [API documentation](swagger.yaml).
|
the [WebSocket paragraph](https://mainflux.readthedocs.io/en/latest/getting-started/#websocket) in the Getting Started guide.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user