From e957ae00f46f9161382b838c32f41454dba8ef6b Mon Sep 17 00:00:00 2001 From: arberkatellari Date: Fri, 15 Sep 2023 02:52:03 -0400 Subject: [PATCH] Improve functionality for Drone CI --- .drone.yml | 75 ++--- data/docker/integration/Dockerfile | 75 +++-- data/docker/integration/docker-entrypoint.sh | 73 +++-- data/docker/integration/main.yaml | 46 --- .../integration/scripts/mongo/setup_cgr_db.sh | 14 - .../mysql/alter_cdr_tables_rc5_rc6.sql | 4 +- .../scripts/mysql/create_cdrs_tables.sql | 2 +- .../scripts/mysql/create_db_with_users.sql | 5 +- .../scripts/mysql/create_ers_db.sql | 4 +- .../mysql/create_tariffplan_tables.sql | 41 +-- .../integration/scripts/mysql/setup_cgr_db.sh | 29 -- .../integration/scripts/mysql/setup_ers_db.sh | 25 -- .../scripts/postgres/create_cdrs_tables.sql | 2 +- .../scripts/postgres/create_db_with_users.sh | 10 - .../scripts/postgres/create_ers_db.sh | 5 - .../postgres/create_tariffplan_tables.sql | 44 +-- .../scripts/postgres/setup_cgr_db.sh | 30 -- drone_template.html | 293 ++++++++++++++++++ recipients | 2 +- 19 files changed, 436 insertions(+), 343 deletions(-) delete mode 100644 data/docker/integration/main.yaml delete mode 100755 data/docker/integration/scripts/mongo/setup_cgr_db.sh delete mode 100755 data/docker/integration/scripts/mysql/setup_cgr_db.sh delete mode 100755 data/docker/integration/scripts/mysql/setup_ers_db.sh delete mode 100755 data/docker/integration/scripts/postgres/create_db_with_users.sh delete mode 100755 data/docker/integration/scripts/postgres/create_ers_db.sh delete mode 100755 data/docker/integration/scripts/postgres/setup_cgr_db.sh create mode 100644 drone_template.html diff --git a/.drone.yml b/.drone.yml index 8cb331bfb..ad50dbc9c 100644 --- a/.drone.yml +++ b/.drone.yml @@ -27,19 +27,12 @@ steps: [{{ build.status }}] {{ repo.owner }}/{{ repo.name }} ({{ commit.branch }}) - body: > - Build number: # {{ build.number }} - Build link: {{ build.link }} - Build started: {{ build.started }} - Build ended: {{ build.finished }} - Commit author: {{ commit.author.name }} - Commit message: {{ commit.message }} - Commit branch: {{ commit.branch }} - Commit link: {{ commit.link }} + body: + file:///go/src/github.com/cgrates/cgrates/drone_template.html recipients_file: recipients - recipients_only: true when: - status: failure + status: + - failure --- kind: pipeline @@ -73,19 +66,12 @@ steps: [{{ build.status }}] {{ repo.owner }}/{{ repo.name }} ({{ commit.branch }}) - body: > - Build number: # {{ build.number }} - Build link: {{ build.link }} - Build started: {{ build.started }} - Build ended: {{ build.finished }} - Commit author: {{ commit.author.name }} - Commit message: {{ commit.message }} - Commit branch: {{ commit.branch }} - Commit link: {{ commit.link }} + body: + file:///go/src/github.com/cgrates/cgrates/drone_template.html recipients_file: recipients - recipients_only: true when: - status: failure + status: + - failure --- kind: pipeline @@ -119,19 +105,12 @@ steps: [{{ build.status }}] {{ repo.owner }}/{{ repo.name }} ({{ commit.branch }}) - body: > - Build number: # {{ build.number }} - Build link: {{ build.link }} - Build started: {{ build.started }} - Build ended: {{ build.finished }} - Commit author: {{ commit.author.name }} - Commit message: {{ commit.message }} - Commit branch: {{ commit.branch }} - Commit link: {{ commit.link }} + body: + file:///go/src/github.com/cgrates/cgrates/drone_template.html recipients_file: recipients - recipients_only: true when: - status: failure + status: + - failure --- kind: pipeline @@ -165,19 +144,12 @@ steps: [{{ build.status }}] {{ repo.owner }}/{{ repo.name }} ({{ commit.branch }}) - body: > - Build number: # {{ build.number }} - Build link: {{ build.link }} - Build started: {{ build.started }} - Build ended: {{ build.finished }} - Commit author: {{ commit.author.name }} - Commit message: {{ commit.message }} - Commit branch: {{ commit.branch }} - Commit link: {{ commit.link }} + body: + file:///go/src/github.com/cgrates/cgrates/drone_template.html recipients_file: recipients - recipients_only: true when: - status: failure + status: + - failure --- kind: pipeline @@ -211,16 +183,9 @@ steps: [{{ build.status }}] {{ repo.owner }}/{{ repo.name }} ({{ commit.branch }}) - body: > - Build number: # {{ build.number }} - Build link: {{ build.link }} - Build started: {{ build.started }} - Build ended: {{ build.finished }} - Commit author: {{ commit.author.name }} - Commit message: {{ commit.message }} - Commit branch: {{ commit.branch }} - Commit link: {{ commit.link }} + body: + file:///go/src/github.com/cgrates/cgrates/drone_template.html recipients_file: recipients - recipients_only: true when: - status: failure \ No newline at end of file + status: + - failure \ No newline at end of file diff --git a/data/docker/integration/Dockerfile b/data/docker/integration/Dockerfile index f915c73c1..9d8afd62a 100644 --- a/data/docker/integration/Dockerfile +++ b/data/docker/integration/Dockerfile @@ -1,66 +1,81 @@ -FROM ubuntu:jammy +FROM debian:bullseye-slim RUN groupadd -r mongodb && useradd -r -g mongodb mongodb RUN groupadd -r redis && useradd -r -g redis redis RUN groupadd -r kafka && useradd -r -g kafka kafka +RUN groupadd -r nats && useradd -r -g nats nats -RUN mkdir -p /usr/share/cgrates/conf /usr/share/man/man1 /var/spool/cgrates/ers/in /var/spool/cgrates/ers/out /var/spool/cgrates/cdre/csv /var/spool/cgrates/cdre/fwv /var/spool/cgrates/tpe /var/spool/cgrates/failed_posts /var/spool/cgrates/analyzers /run /data/configdb /data/db /kafka /logs +RUN mkdir -p /usr/share/cgrates/conf /usr/share/man/man1 /var/spool/cgrates/ers/in /var/spool/cgrates/ers/out /var/spool/cgrates/cdre/csv /var/spool/cgrates/cdre/fwv /var/spool/cgrates/tpe /var/spool/cgrates/failed_posts /var/spool/cgrates/analyzers /run /data/configdb /data/db /kafka /logs /opt/nats -ENV DEBIAN_FRONTEND=noninteractive +RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections -RUN apt-get update && apt-get install -y ansible - -# Install Erlang packages -RUN apt-get install -y erlang-base erlang-asn1 erlang-crypto erlang-eldap erlang-ftp erlang-inets erlang-mnesia erlang-os-mon erlang-parsetools erlang-public-key erlang-runtime-tools erlang-snmp erlang-ssl erlang-syntax-tools erlang-tftp erlang-tools erlang-xmerl - -RUN apt-get install -y apt-utils wget gnupg gnupg2 apt-transport-https curl redis-server git build-essential rsyslog procps gosu "mariadb-server" mariadb-backup socat default-jdk-headless neovim net-tools - -RUN curl -fsSL https://pgp.mongodb.com/server-7.0.asc | gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg --dearmor -RUN echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-7.0.list - -RUN sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' -RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - - RUN apt-get update -RUN apt-get install -y mongodb-org postgresql -# ADD THIS AFTER postgresql rabbitmq-server + +RUN apt-get install -y apt-utils wget gnupg gnupg2 apt-transport-https curl redis-server git gcc build-essential rsyslog procps gosu "mariadb-server" mariadb-backup socat default-jdk neovim net-tools + +RUN wget https://github.com/nats-io/nats-server/releases/download/v2.9.17/nats-server-v2.9.17-linux-amd64.tar.gz -O /tmp/nats-server-v2.9.17-linux-amd64.tar.gz && tar -xzvf /tmp/nats-server-v2.9.17-linux-amd64.tar.gz -C /opt/nats --strip-components=1 + +RUN ln -s /opt/nats/nats-server /usr/local/bin/nats-server + +RUN rm /tmp/nats-server-v2.9.17-linux-amd64.tar.gz + +RUN curl -fsSL https://pgp.mongodb.com/server-7.0.asc | gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg --dearmor +RUN echo "deb [ signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/debian bullseye/mongodb-org/7.0 main" | tee /etc/apt/sources.list.d/mongodb-org-7.0.list + +RUN curl -1sLf "https://keys.openpgp.org/vks/v1/by-fingerprint/0A9AF2115F4687BD29803A206B73A36E6026DFCA" | gpg --dearmor | tee /usr/share/keyrings/com.rabbitmq.team.gpg > /dev/null +RUN curl -1sLf "https://github.com/rabbitmq/signing-keys/releases/download/3.0/cloudsmith.rabbitmq-erlang.E495BB49CC4BBE5B.key" | gpg --dearmor | tee /usr/share/keyrings/rabbitmq.E495BB49CC4BBE5B.gpg > /dev/null +RUN curl -1sLf "https://github.com/rabbitmq/signing-keys/releases/download/3.0/cloudsmith.rabbitmq-server.9F4587F226208342.key" | gpg --dearmor | tee /usr/share/keyrings/rabbitmq.9F4587F226208342.gpg > /dev/null +RUN tee /etc/apt/sources.list.d/rabbitmq.list < /etc/mysql/conf.d/docker.cnf -# Clean up RUN apt-get clean && \ rm -rf /var/lib/apt/lists/* RUN touch /logs/mariadb.log /logs/mariadb_script.log /logs/rabbitmq.log RUN chmod 777 /logs/mariadb.log /logs/mariadb_script.log /logs/rabbitmq.log -COPY main.yaml /integration_tests.yaml - -COPY roles /roles - RUN wget -O go.tgz "https://storage.googleapis.com/golang/go1.21.0.linux-amd64.tar.gz" --progress=dot:giga RUN tar -C /usr/local -xzf go.tgz RUN rm go.tgz diff --git a/data/docker/integration/docker-entrypoint.sh b/data/docker/integration/docker-entrypoint.sh index 8efaa8b0b..ffccb04b0 100755 --- a/data/docker/integration/docker-entrypoint.sh +++ b/data/docker/integration/docker-entrypoint.sh @@ -1,7 +1,9 @@ #!/bin/bash set -ev -ansible-playbook /integration_tests.yaml -i localhost, -c local -e "ansible_user=root clone_repository=true" -vvv +export MYSQL_ROOT_PASSWORD="CGRateS.org" + +/go/src/github.com/cgrates/cgrates/build.sh # # Create symbolic links ln -s "/go/src/github.com/cgrates/cgrates/data" "/usr/share/cgrates" @@ -13,61 +15,58 @@ ln -s "/go/bin/cgr-tester" "/usr/bin/cgr-tester" # start basic subsystems # export KAFKA_HEAP_OPTS="-Xmx100M -Xms100M" -# /kafka/bin/zookeeper-server-start.sh -daemon /kafka/config/zookeeper.properties -# /kafka/bin/kafka-server-start.sh -daemon /kafka/config/server.properties - +/kafka/bin/zookeeper-server-start.sh -daemon /kafka/config/zookeeper.properties +/kafka/bin/kafka-server-start.sh -daemon /kafka/config/server.properties rsyslogd -f /etc/rsyslogd.conf version=$(ls /var/lib/postgresql) pg_ctlcluster $version main start & mongod --bind_ip 127.0.0.1 --logpath /logs/mongodb.log & redis-server /etc/redis/redis.conf & -MYSQL_ROOT_PASSWORD="CGRateS.org" /go/src/github.com/cgrates/cgrates/data/docker/integration/scripts/mariadb-ep.sh mysqld -# rabbitmq-server > /logs/rabbitmq.log 2>&1 & +/go/src/github.com/cgrates/cgrates/data/docker/integration/scripts/mariadb-ep.sh mysqld +rabbitmq-server > /logs/rabbitmq.log 2>&1 & -# START_TIMEOUT=600 +START_TIMEOUT=600 -# start_timeout_exceeded=false -# count=0 -# step=10 -# while netstat -lnt | awk '$4 ~ /:9092$/ {exit 1}'; do -# echo "waiting for kafka to be ready" -# sleep $step; -# count=$((count + step)) -# if [ $count -gt $START_TIMEOUT ]; then -# start_timeout_exceeded=true -# break -# fi -# done +start_timeout_exceeded=false +count=0 +step=10 +while netstat -lnt | awk '$4 ~ /:9092$/ {exit 1}'; do + echo "waiting for kafka to be ready" + sleep $step; + count=$((count + step)) + if [ $count -gt $START_TIMEOUT ]; then + start_timeout_exceeded=true + break + fi +done -# if $start_timeout_exceeded; then -# echo "Not able to auto-create topic (waited for $START_TIMEOUT sec)" -# exit 1 -# fi +if $start_timeout_exceeded; then + echo "Not able to auto-create topic (waited for $START_TIMEOUT sec)" + exit 1 +fi -# /kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic cgrates -# /kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic cgrates_cdrs +/kafka/bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic cgrates +/kafka/bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic cgrates_cdrs + + +gosu postgres psql -c "CREATE USER cgrates password 'CGRateS.org';" +gosu postgres createdb -e -O cgrates cgrates +gosu postgres createdb -e -O cgrates cgrates2 -# gosu postgres psql -c "CREATE USER cgrates password 'CGRateS.org';" > /dev/null 2>&1 -# gosu postgres createdb -e -O cgrates cgrates > /dev/null 2>&1 +PGPASSWORD="CGRateS.org" psql -U "cgrates" -h "localhost" -d cgrates -f /go/src/github.com/cgrates/cgrates/data/docker/integration/scripts/postgres/create_cdrs_tables.sql +PGPASSWORD="CGRateS.org" psql -U "cgrates" -h "localhost" -d cgrates -f /go/src/github.com/cgrates/cgrates/data/docker/integration/scripts/postgres/create_tariffplan_tables.sql - -# PGPASSWORD="CGRateS.org" psql -U "cgrates" -h "localhost" -d cgrates -f /cgrates/data/docker/integration/scripts/postgres/create_cdrs_tables.sql >/dev/null 2>&1 -# PGPASSWORD="CGRateS.org" psql -U "cgrates" -h "localhost" -d cgrates -f /cgrates/data/docker/integration/scripts/postgres/create_tariffplan_tables.sql >/dev/null 2>&1 - - -# mongo --quiet /cgrates/data/docker/integration/scripts/create_user.js >/dev/null 2>&1 -echo "Starting..." -sleep 60 # Pause for 1 min -echo "Resuming..." +mongosh --quiet /go/src/github.com/cgrates/cgrates/data/docker/integration/scripts/mongo/create_user.js mysql -u root -pCGRateS.org -h localhost < /go/src/github.com/cgrates/cgrates/data/docker/integration/scripts/mysql/create_db_with_users.sql +mysql -u root -pCGRateS.org -h localhost < /go/src/github.com/cgrates/cgrates/data/docker/integration/scripts/mysql/create_ers_db.sql mysql -u root -pCGRateS.org -h localhost -D cgrates < /go/src/github.com/cgrates/cgrates/data/docker/integration/scripts/mysql/create_cdrs_tables.sql mysql -u root -pCGRateS.org -h localhost -D cgrates < /go/src/github.com/cgrates/cgrates/data/docker/integration/scripts/mysql/create_tariffplan_tables.sql cp -r /go/src/github.com/cgrates/cgrates/data/. /usr/share/cgrates # Set versions -# cgr-migrator -exec=*set_versions -config_path=/usr/share/cgrates/conf/samples/tutmysql \ No newline at end of file +cgr-migrator -exec=*set_versions -config_path=/usr/share/cgrates/conf/samples/tutmysql \ No newline at end of file diff --git a/data/docker/integration/main.yaml b/data/docker/integration/main.yaml deleted file mode 100644 index dffaafca1..000000000 --- a/data/docker/integration/main.yaml +++ /dev/null @@ -1,46 +0,0 @@ ---- -- hosts: all - vars: - golang_gopath: "/go" - clone_repository: true - cgrates_dir: "{{ golang_gopath }}/src/github.com/cgrates/cgrates" - golang_install_dir: /usr/local/go - git_version: "v0.10" - cgrates_dependencies: - - git - - redis-server - - mariadb-server - - make - - gcc - - tasks: - - name: Install CGRateS dependencies - become: yes - ansible.builtin.package: - name: "{{ cgrates_dependencies }}" - state: present - update_cache: yes - cache_valid_time: 86400 - - - name: Create cgrates directory - ansible.builtin.file: - state: directory - mode: "u=rwx,go=rx" - owner: "{{ ansible_user }}" - dest: "{{ cgrates_dir }}" - when: clone_repository | bool - - - name: Git clone cgrates - ansible.builtin.git: - repo: https://github.com/cgrates/cgrates.git - dest: "{{ cgrates_dir }}" - update: yes - force: yes - version: "{{ git_version }}" - when: clone_repository | bool - - - name: Build cgrates - ansible.builtin.shell: - cmd: bash -lc "sh {{ cgrates_dir }}/build.sh" - args: - chdir: "{{ cgrates_dir }}" diff --git a/data/docker/integration/scripts/mongo/setup_cgr_db.sh b/data/docker/integration/scripts/mongo/setup_cgr_db.sh deleted file mode 100755 index 4cbc93516..000000000 --- a/data/docker/integration/scripts/mongo/setup_cgr_db.sh +++ /dev/null @@ -1,14 +0,0 @@ -#! /usr/bin/env sh - - -mongo --quiet create_user.js -cu=$? - -if [ $cu = 0 ]; then - echo "" - echo "\t+++ CGR-DB successfully set-up! +++" - echo "" - exit 0 -fi - - diff --git a/data/docker/integration/scripts/mysql/alter_cdr_tables_rc5_rc6.sql b/data/docker/integration/scripts/mysql/alter_cdr_tables_rc5_rc6.sql index e3ddad60b..8b5694795 100644 --- a/data/docker/integration/scripts/mysql/alter_cdr_tables_rc5_rc6.sql +++ b/data/docker/integration/scripts/mysql/alter_cdr_tables_rc5_rc6.sql @@ -4,7 +4,7 @@ ALTER TABLE `cdrs_primary` CHANGE COLUMN tbid `id` int(11) NOT NULL auto_increment first , CHANGE `cgrid` `cgrid` char(40) NOT NULL after `id` , ADD COLUMN `pdd` decimal(12,9) NOT NULL after `setup_time` , - CHANGE `answer_time` `answer_time` datetime NULL after `pdd` , + CHANGE `answer_time` `answer_time` datetime NOT NULL after `pdd` , ADD COLUMN `supplier` varchar(128) NOT NULL after `usage` , ADD COLUMN `disconnect_cause` varchar(64) NOT NULL after `supplier` , ADD COLUMN `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP after `disconnect_cause` , @@ -37,7 +37,7 @@ ALTER TABLE `rated_cdrs` CHANGE `cgrid` `cgrid` char(40) NOT NULL after `id` , CHANGE `category` `category` varchar(32) NOT NULL after `tenant` , ADD COLUMN `pdd` decimal(12,9) NOT NULL after `setup_time` , - CHANGE `answer_time` `answer_time` datetime NULL after `pdd` , + CHANGE `answer_time` `answer_time` datetime NOT NULL after `pdd` , ADD COLUMN `supplier` varchar(128) NOT NULL after `usage` , ADD COLUMN `disconnect_cause` varchar(64) NOT NULL after `supplier` , CHANGE `cost` `cost` decimal(20,4) NULL after `disconnect_cause` , diff --git a/data/docker/integration/scripts/mysql/create_cdrs_tables.sql b/data/docker/integration/scripts/mysql/create_cdrs_tables.sql index a563b1bac..6c2a917e6 100644 --- a/data/docker/integration/scripts/mysql/create_cdrs_tables.sql +++ b/data/docker/integration/scripts/mysql/create_cdrs_tables.sql @@ -18,7 +18,7 @@ CREATE TABLE cdrs ( subject varchar(128) NOT NULL, destination varchar(128) NOT NULL, setup_time datetime NOT NULL, - answer_time datetime NULL, + answer_time datetime NOT NULL, `usage` BIGINT NOT NULL, extra_fields text NOT NULL, cost_source varchar(64) NOT NULL, diff --git a/data/docker/integration/scripts/mysql/create_db_with_users.sql b/data/docker/integration/scripts/mysql/create_db_with_users.sql index 3a9e88304..055135f0c 100644 --- a/data/docker/integration/scripts/mysql/create_db_with_users.sql +++ b/data/docker/integration/scripts/mysql/create_db_with_users.sql @@ -5,6 +5,5 @@ DROP DATABASE IF EXISTS cgrates; CREATE DATABASE cgrates; -CREATE USER IF NOT EXISTS 'cgrates'@'localhost' IDENTIFIED BY 'CGRateS.org'; -GRANT ALL PRIVILEGES ON cgrates.* TO 'cgrates'@'localhost' WITH GRANT OPTION; -FLUSH PRIVILEGES; + +GRANT ALL on cgrates.* TO 'cgrates'@'127.0.0.1' IDENTIFIED BY 'CGRateS.org'; diff --git a/data/docker/integration/scripts/mysql/create_ers_db.sql b/data/docker/integration/scripts/mysql/create_ers_db.sql index 99a6bc15e..9dc003103 100644 --- a/data/docker/integration/scripts/mysql/create_ers_db.sql +++ b/data/docker/integration/scripts/mysql/create_ers_db.sql @@ -1,7 +1,7 @@ -- --- extra DB for ees and ers +-- extra DB for ers DROP DATABASE IF EXISTS cgrates2; CREATE DATABASE cgrates2; -GRANT ALL on cgrates2.* TO 'cgrates'@'localhost' IDENTIFIED BY 'CGRateS.org'; +GRANT ALL on cgrates2.* TO 'cgrates'@'127.0.0.1' IDENTIFIED BY 'CGRateS.org'; diff --git a/data/docker/integration/scripts/mysql/create_tariffplan_tables.sql b/data/docker/integration/scripts/mysql/create_tariffplan_tables.sql index c184be757..a203d7090 100644 --- a/data/docker/integration/scripts/mysql/create_tariffplan_tables.sql +++ b/data/docker/integration/scripts/mysql/create_tariffplan_tables.sql @@ -148,7 +148,7 @@ CREATE TABLE `tp_actions` ( `tag` varchar(64) NOT NULL, `action` varchar(24) NOT NULL, `extra_parameters` varchar(256) NOT NULL, - `filters` varchar(256) NOT NULL, + `filter` varchar(256) NOT NULL, `balance_tag` varchar(64) NOT NULL, `balance_type` varchar(24) NOT NULL, `categories` varchar(32) NOT NULL, @@ -340,12 +340,12 @@ CREATE TABLE tp_filters ( ); -- --- Table structure for table `tp_routes` +-- Table structure for table `tp_suppliers` -- -DROP TABLE IF EXISTS tp_routes; -CREATE TABLE tp_routes ( +DROP TABLE IF EXISTS tp_suppliers; +CREATE TABLE tp_suppliers ( `pk` int(11) NOT NULL AUTO_INCREMENT, `tpid` varchar(64) NOT NULL, `tenant` varchar(64) NOT NULL, @@ -354,23 +354,22 @@ CREATE TABLE tp_routes ( `activation_interval` varchar(64) NOT NULL, `sorting` varchar(32) NOT NULL, `sorting_parameters` varchar(64) NOT NULL, - `route_id` varchar(32) NOT NULL, - `route_filter_ids` varchar(64) NOT NULL, - `route_account_ids` varchar(64) NOT NULL, - `route_ratingplan_ids` varchar(64) NOT NULL, - `route_rate_profile_ids` varchar(64) NOT NULL, - `route_resource_ids` varchar(64) NOT NULL, - `route_stat_ids` varchar(64) NOT NULL, - `route_weight` decimal(8,2) NOT NULL, - `route_blocker` BOOLEAN NOT NULL, - `route_parameters` varchar(64) NOT NULL, + `supplier_id` varchar(32) NOT NULL, + `supplier_filter_ids` varchar(64) NOT NULL, + `supplier_account_ids` varchar(64) NOT NULL, + `supplier_ratingplan_ids` varchar(64) NOT NULL, + `supplier_resource_ids` varchar(64) NOT NULL, + `supplier_stat_ids` varchar(64) NOT NULL, + `supplier_weight` decimal(8,2) NOT NULL, + `supplier_blocker` BOOLEAN NOT NULL, + `supplier_parameters` varchar(64) NOT NULL, `weight` decimal(8,2) NOT NULL, `created_at` TIMESTAMP, PRIMARY KEY (`pk`), KEY `tpid` (`tpid`), - UNIQUE KEY `unique_tp_routes` (`tpid`,`tenant`, - `id`,`filter_ids`,`route_id`,`route_filter_ids`,`route_account_ids`, - `route_ratingplan_ids`,`route_resource_ids`,`route_stat_ids` ) + UNIQUE KEY `unique_tp_suppliers` (`tpid`,`tenant`, + `id`,`filter_ids`,`supplier_id`,`supplier_filter_ids`,`supplier_account_ids`, + `supplier_ratingplan_ids`,`supplier_resource_ids`,`supplier_stat_ids` ) ); -- @@ -461,15 +460,7 @@ CREATE TABLE tp_dispatcher_hosts ( `id` varchar(64) NOT NULL, `address` varchar(64) NOT NULL, `transport` varchar(64) NOT NULL, - `connect_attempts` int(11) NOT NULL, - `reconnects` int(11) NOT NULL, - `max_reconnect_interval` varchar(64) NOT NULL, - `connect_timeout` varchar(64) NOT NULL, - `reply_timeout` varchar(64) NOT NULL, `tls` BOOLEAN NOT NULL, - `client_key` varchar(64) NOT NULL, - `client_certificate` varchar(64) NOT NULL, - `ca_certificate` varchar(64) NOT NULL, `created_at` TIMESTAMP, PRIMARY KEY (`pk`), KEY `tpid` (`tpid`), diff --git a/data/docker/integration/scripts/mysql/setup_cgr_db.sh b/data/docker/integration/scripts/mysql/setup_cgr_db.sh deleted file mode 100755 index 8561b7e9d..000000000 --- a/data/docker/integration/scripts/mysql/setup_cgr_db.sh +++ /dev/null @@ -1,29 +0,0 @@ -#! /usr/bin/env sh - -if test $# -lt 2; then - echo "" - echo "setup_cgr_db.sh []" - echo "" - exit 0 -fi - -host=$3 -if [ -z "$3" ]; then - host="localhost" -fi - -DIR="$(dirname "$(readlink -f "$0")")" - -mysql -u $1 -p$2 -h $host < "$DIR"/create_db_with_users.sql -cu=$? -mysql -u $1 -p$2 -h $host -D cgrates < "$DIR"/create_cdrs_tables.sql -cdrt=$? -mysql -u $1 -p$2 -h $host -D cgrates < "$DIR"/create_tariffplan_tables.sql -tpt=$? - -if [ $cu = 0 ] && [ $cdrt = 0 ] && [ $tpt = 0 ]; then - echo "\n\t+++ CGR-DB successfully set-up! +++\n" - exit 0 -fi - - diff --git a/data/docker/integration/scripts/mysql/setup_ers_db.sh b/data/docker/integration/scripts/mysql/setup_ers_db.sh deleted file mode 100755 index 455315e3c..000000000 --- a/data/docker/integration/scripts/mysql/setup_ers_db.sh +++ /dev/null @@ -1,25 +0,0 @@ -#! /usr/bin/env sh - -if test $# -lt 2; then - echo "" - echo "setup_cgr_db.sh []" - echo "" - exit 0 -fi - -host=$3 -if [ -z "$3" ]; then - host="localhost" -fi - -DIR="$(dirname "$(readlink -f "$0")")" - -mysql -u $1 -p$2 -h $host < "$DIR"/create_ers_db.sql -cu=$? - -if [ $cu = 0 ]; then - echo "\n\t+++ CGR-DB successfully set-up! +++\n" - exit 0 -fi - - diff --git a/data/docker/integration/scripts/postgres/create_cdrs_tables.sql b/data/docker/integration/scripts/postgres/create_cdrs_tables.sql index 3ae7d5ccb..f7d203382 100644 --- a/data/docker/integration/scripts/postgres/create_cdrs_tables.sql +++ b/data/docker/integration/scripts/postgres/create_cdrs_tables.sql @@ -18,7 +18,7 @@ CREATE TABLE cdrs ( subject VARCHAR(128) NOT NULL, destination VARCHAR(128) NOT NULL, setup_time TIMESTAMP WITH TIME ZONE NOT NULL, - answer_time TIMESTAMP WITH TIME ZONE NULL, + answer_time TIMESTAMP WITH TIME ZONE NOT NULL, usage BIGINT NOT NULL, extra_fields jsonb NOT NULL, cost_source VARCHAR(64) NOT NULL, diff --git a/data/docker/integration/scripts/postgres/create_db_with_users.sh b/data/docker/integration/scripts/postgres/create_db_with_users.sh deleted file mode 100755 index b193b3f5f..000000000 --- a/data/docker/integration/scripts/postgres/create_db_with_users.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -# -# Sample db and users creation. Replace here with your own details -# - -sudo -u postgres dropdb -e cgrates -sudo -u postgres dropuser -e cgrates -sudo -u postgres psql -c "CREATE USER cgrates password 'CGRateS.org';" -sudo -u postgres createdb -e -O cgrates cgrates diff --git a/data/docker/integration/scripts/postgres/create_ers_db.sh b/data/docker/integration/scripts/postgres/create_ers_db.sh deleted file mode 100755 index 17b760cda..000000000 --- a/data/docker/integration/scripts/postgres/create_ers_db.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -# extra DB for ers -sudo -u postgres dropdb -e cgrates2 -sudo -u postgres createdb -e -O cgrates cgrates2 diff --git a/data/docker/integration/scripts/postgres/create_tariffplan_tables.sql b/data/docker/integration/scripts/postgres/create_tariffplan_tables.sql index 0d0bca9b3..29a9502df 100644 --- a/data/docker/integration/scripts/postgres/create_tariffplan_tables.sql +++ b/data/docker/integration/scripts/postgres/create_tariffplan_tables.sql @@ -143,7 +143,7 @@ CREATE TABLE tp_actions ( tag VARCHAR(64) NOT NULL, action VARCHAR(24) NOT NULL, extra_parameters VARCHAR(256) NOT NULL, - filters VARCHAR(256) NOT NULL, + filter VARCHAR(256) NOT NULL, balance_tag VARCHAR(64) NOT NULL, balance_type VARCHAR(24) NOT NULL, categories VARCHAR(32) NOT NULL, @@ -333,11 +333,11 @@ CREATE TABLE tp_filters ( CREATE INDEX tp_filters_unique ON tp_filters ("tpid","tenant", "id", "type", "element"); -- --- Table structure for table `tp_routes` +-- Table structure for table `tp_suppliers` -- -DROP TABLE IF EXISTS tp_routes; -CREATE TABLE tp_routes ( +DROP TABLE IF EXISTS tp_suppliers; +CREATE TABLE tp_suppliers ( "pk" SERIAL PRIMARY KEY, "tpid" varchar(64) NOT NULL, "tenant"varchar(64) NOT NULL, @@ -346,22 +346,22 @@ CREATE TABLE tp_routes ( "activation_interval" varchar(64) NOT NULL, "sorting" varchar(32) NOT NULL, "sorting_parameters" varchar(64) NOT NULL, - "route_id" varchar(32) NOT NULL, - "route_filter_ids" varchar(64) NOT NULL, - "route_account_ids" varchar(64) NOT NULL, - "route_ratingplan_ids" varchar(64) NOT NULL, - "route_resource_ids" varchar(64) NOT NULL, - "route_stat_ids" varchar(64) NOT NULL, - "route_weight" decimal(8,2) NOT NULL, - "route_blocker" BOOLEAN NOT NULL, - "route_parameters" varchar(64) NOT NULL, + "supplier_id" varchar(32) NOT NULL, + "supplier_filter_ids" varchar(64) NOT NULL, + "supplier_account_ids" varchar(64) NOT NULL, + "supplier_ratingplan_ids" varchar(64) NOT NULL, + "supplier_resource_ids" varchar(64) NOT NULL, + "supplier_stat_ids" varchar(64) NOT NULL, + "supplier_weight" decimal(8,2) NOT NULL, + "supplier_blocker" BOOLEAN NOT NULL, + "supplier_parameters" varchar(64) NOT NULL, "weight" decimal(8,2) NOT NULL, "created_at" TIMESTAMP WITH TIME ZONE ); -CREATE INDEX tp_routes_idx ON tp_routes (tpid); -CREATE INDEX tp_routes_unique ON tp_routes ("tpid", "tenant", "id", - "filter_ids","route_id","route_filter_ids","route_account_ids", - "route_ratingplan_ids","route_resource_ids","route_stat_ids"); +CREATE INDEX tp_suppliers_idx ON tp_suppliers (tpid); +CREATE INDEX tp_suppliers_unique ON tp_suppliers ("tpid", "tenant", "id", + "filter_ids","supplier_id","supplier_filter_ids","supplier_account_ids", + "supplier_ratingplan_ids","supplier_resource_ids","supplier_stat_ids"); -- -- Table structure for table `tp_attributes` @@ -448,23 +448,13 @@ CREATE INDEX tp_routes_unique ON tp_routes ("tpid", "tenant", "id", "id" varchar(64) NOT NULL, "address" varchar(64) NOT NULL, "transport" varchar(64) NOT NULL, - "connect_attempts" INTEGER NOT NULL, - "reconnects" INTEGER NOT NULL, - "max_reconnect_interval" varchar(64) NOT NULL, - "connect_timeout" varchar(64) NOT NULL, - "reply_timeout" varchar(64) NOT NULL, "tls" BOOLEAN NOT NULL, - "client_key" varchar(64) NOT NULL, - "client_certificate" varchar(64) NOT NULL, - "ca_certificate" varchar(64) NOT NULL, "created_at" TIMESTAMP WITH TIME ZONE ); CREATE INDEX tp_dispatchers_hosts_ids ON tp_dispatcher_hosts (tpid); CREATE INDEX tp_dispatcher_hosts_unique ON tp_dispatcher_hosts ("tpid", "tenant", "id", "address"); - - -- -- Table structure for table `versions` -- diff --git a/data/docker/integration/scripts/postgres/setup_cgr_db.sh b/data/docker/integration/scripts/postgres/setup_cgr_db.sh deleted file mode 100755 index 66d011763..000000000 --- a/data/docker/integration/scripts/postgres/setup_cgr_db.sh +++ /dev/null @@ -1,30 +0,0 @@ -#! /usr/bin/env sh - - -user=$1 -if [ -z "$1" ]; then - user="cgrates" -fi - -host=$2 -if [ -z "$2" ]; then - host="localhost" -fi - -DIR="$(dirname "$(readlink -f "$0")")" - -"$DIR"/create_db_with_users.sh - -export PGPASSWORD="CGRateS.org" - -psql -U $user -h $host -d cgrates -f "$DIR"/create_cdrs_tables.sql -cdrt=$? -psql -U $user -h $host -d cgrates -f "$DIR"/create_tariffplan_tables.sql -tpt=$? - -if [ $cdrt = 0 ] && [ $tpt = 0 ]; then - echo "\n\t+++ CGR-DB successfully set-up! +++\n" - exit 0 -fi - - diff --git a/drone_template.html b/drone_template.html new file mode 100644 index 000000000..d8a2fe434 --- /dev/null +++ b/drone_template.html @@ -0,0 +1,293 @@ + + + + + + + + + + + + + + + +
+
+ + + {{#success build.status}} + + {{else}} + + {{/success}} + + + + +
+ + Successful build #{{ build.number }} + + + + Failed build #{{ build.number }} + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ Repo: + + {{ repo.owner }}/{{ repo.name }} +
+ Author: + + {{ commit.author.name }} +
+ Branch: + + {{ commit.branch }} +
+ Commit link: + + {{ commit.link }} +
+ Build link: + + {{ build.link }} +
+ Time: + + {{ duration build.started build.finished }} +
+
+ + + + +
+ {{ commit.message }} +
+
+
+
+ + \ No newline at end of file diff --git a/recipients b/recipients index a8c609354..d6095c637 100644 --- a/recipients +++ b/recipients @@ -1 +1 @@ -arber.katellari@itsyscom.com \ No newline at end of file +dan.bogos@itsyscom.com \ No newline at end of file