No description
Find a file
smavros 4c0d74a4a8 Adds new function for testing endpoints WIP:
- NewTestEndpoint() should replace TestEndpoint() since it is
    returning an error in case that the code or the response is not
    matching the expected one. The assertion __must__ be executed in the
    body of the actual test (of the corresponding package) so the
    printed error message can include the right number of line and the
    file where the assertion failed.
    - The function is used now only in package scenario tests.
2019-07-31 11:30:23 +02:00
common Adds new function for testing endpoints WIP: 2019-07-31 11:30:23 +02:00
doc renaming visualization to dashboard 2019-07-18 13:11:05 +02:00
routes Adds new function for testing endpoints WIP: 2019-07-31 11:30:23 +02:00
.gitignore Added .gitignore 2019-04-02 14:51:32 +02:00
.gitlab-ci.yml renaming simulation to scenario 2019-07-18 14:35:20 +02:00
COPYING.md Initial commit 2019-03-03 15:40:38 +01:00
Dockerfile.ubuntu Docker: fix typo 2019-04-24 14:51:56 +02:00
go.mod use jsondiff in endpoint testing 2019-07-24 13:17:47 +02:00
go.sum use jsondiff in endpoint testing 2019-07-24 13:17:47 +02:00
README.md Add Pipeline badge and link to gorm in Readme 2019-04-24 15:42:01 +02:00
start.go renaming simulation to scenario 2019-07-18 14:35:20 +02:00

VILLASweb-backend-go

pipeline status

Description

This is a rewrite of the backend for the VILLASweb website in Go.

Frameworks

The backend is build upon gin-gonic and GORM.

Quick start

Docker

You can use the Dockerfile.ubuntu for development and testing. To build an tag the image call the following in the top level of the repository:

$ docker build -f Dockerfile.ubuntu -t villaswebbackendgo:ubuntu .

To run an interactive container based on the image call:

$ docker run --rm -it villaswebbackendgo:ubuntu

By using the --rm option of docker, the container will be removed upon exit. Omit this option if you want the container to persist on your system.

Within the container you need to start the PostgreSQL server by invoking the following command:

$ /etc/init.d/postgresql start

Now you are ready to compile an test the code.

Compiling

$ go mod tidy
$ go build

Testing

$ go mod tidy
$ cd common
$ go test -v -args -dbhost=/var/run/postgresql

PostgreSQL Database

The current repo is tested for PostgreSQL 11 and Go 1.11

Before running the application the user has to setup and configure PostgreSQL. Alternatively the provided Dockerfile can be used (see above).

To create a new database login to user postgres and start psql

$ su - postgres
$ psql

then

CREATE DATABASE villasdb ;

Some usefull commants for psql

\c somedb -- connect to a database 
\dt       -- list all tables of the database
\l        -- list all databases

The default host for postgres is \tmp and the ssl mode is disabled in development. The user can change those setting in common/database.go.

To manage the database one can use pgAdmin4. Instructions for rpm-based distributions can be found here. The user might have to start pgAdmin as root

$ sudo pythonX /user/lib/pythonX.Y/site-packages/pgadmin4-web/pgAdmin4.py

where X.Y is the python version. The pgAdmin UI can be accessed by the browser at 127.0.0.1:5050. In case that the user is getting FATAL: Ident authentication failed for user "username" the authentication for local users has to be changed from ident to trust in pg_hba.conf file

# IPv4 local connections:
host    all             all             127.0.0.1/32            trust
# IPv6 local connections:
host    all             all             ::1/128                 trust

To do that edit the configuration file as root

$ sudo vim /var/lib/pgsql/11/data/pg_hba.conf

2019, Institute for Automation of Complex Power Systems, EONERC

License

This project is released under the terms of the GPL version 3.

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

For other licensing options please consult Prof. Antonello Monti.

Contact

EONERC ACS Logo

Institute for Automation of Complex Power Systems (ACS)
EON Energy Research Center (EONERC)
RWTH University Aachen, Germany