diff --git a/.drone.yml b/.drone.yml
index b40ba2331..66ec1979c 100644
--- a/.drone.yml
+++ b/.drone.yml
@@ -2,56 +2,217 @@ kind: pipeline
type: docker
name: unit
+
workspace:
path: /cgrates
steps:
- name: unit
pull: never
- image: cgrates-integration
+ image: cgrates-it-entrypoint
commands:
-# - docker-entrypoint.sh
+ - docker-entrypoint.sh
- ./test.sh
-# - name: notify
-# pull: never
-# image: trial97/drone-email
-# settings:
-# from: cgrates.test01@gmail.com
-# credentials:
-# from_secret: credentials
-# token:
-# from_secret: token
-# when:
-# status: [ changed, failure ]
+- name: notify
+ pull: never
+ image: drillster/drone-email
+ settings:
+ from: cgrates.test01@gmail.com
+ host: smtp.gmail.com
+ username:
+ from_secret: email_username
+ password:
+ from_secret: email_password
+ subject: >
+ [{{ 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 }}
+ recipients_file: recipients
+ recipients_only: true
+ when:
+ status: failure
+
+---
+kind: pipeline
+type: docker
+name: integration-internal
-# ---
-# kind: pipeline
-# type: docker
-# name: default
+workspace:
+ path: /cgrates
-# workspace:
-# path: /cgrates
+steps:
+- name: integration-internal
+ pull: never
+ image: cgrates-it-entrypoint
+ commands:
+ - docker-entrypoint.sh
+ - ./integration_test.sh -dbtype=*internal
+- name: notify
+ pull: never
+ image: drillster/drone-email
+ settings:
+ from: cgrates.test01@gmail.com
+ host: smtp.gmail.com
+ username:
+ from_secret: email_username
+ password:
+ from_secret: email_password
+ subject: >
+ [{{ 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 }}
+ recipients_file: recipients
+ recipients_only: true
+ when:
+ status: failure
-# steps:
-# - name: integration
-# pull: never
-# image: cgrates-integration
-# commands:
-# - docker-entrypoint.sh
-# - ./integration_test.sh
+---
+kind: pipeline
+type: docker
+name: integration-mysql
-# - name: notify
-# pull: never
-# image: trial97/drone-email
-# settings:
-# from: cgrates.test01@gmail.com
-# credentials:
-# from_secret: credentials
-# token:
-# from_secret: token
-# when:
-# status: [ changed, failure ]
-# depends_on:
-# - unit
+workspace:
+ path: /cgrates
+
+steps:
+- name: integration-mysql
+ pull: never
+ image: cgrates-it-entrypoint
+ commands:
+ - docker-entrypoint.sh
+ - ./integration_test.sh -dbtype=*mysql
+- name: notify
+ pull: never
+ image: drillster/drone-email
+ settings:
+ from: cgrates.test01@gmail.com
+ host: smtp.gmail.com
+ username:
+ from_secret: email_username
+ password:
+ from_secret: email_password
+ subject: >
+ [{{ 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 }}
+ recipients_file: recipients
+ recipients_only: true
+ when:
+ status: failure
+
+---
+kind: pipeline
+type: docker
+name: integration-mongo
+
+
+workspace:
+ path: /cgrates
+
+steps:
+- name: integration-mongo
+ pull: never
+ image: cgrates-it-entrypoint
+ commands:
+ - docker-entrypoint.sh
+ - ./integration_test.sh -dbtype=*mongo
+- name: notify
+ pull: never
+ image: drillster/drone-email
+ settings:
+ from: cgrates.test01@gmail.com
+ host: smtp.gmail.com
+ username:
+ from_secret: email_username
+ password:
+ from_secret: email_password
+ subject: >
+ [{{ 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 }}
+ recipients_file: recipients
+ recipients_only: true
+ when:
+ status: failure
+
+---
+kind: pipeline
+type: docker
+name: integration-postgres
+
+
+workspace:
+ path: /cgrates
+
+steps:
+- name: integration-postgres
+ pull: never
+ image: cgrates-it-entrypoint
+ commands:
+ - docker-entrypoint.sh
+ - ./integration_test.sh -dbtype=*postgres
+- name: notify
+ pull: never
+ image: drillster/drone-email
+ settings:
+ from: cgrates.test01@gmail.com
+ host: smtp.gmail.com
+ username:
+ from_secret: email_username
+ password:
+ from_secret: email_password
+ subject: >
+ [{{ 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 }}
+ recipients_file: recipients
+ recipients_only: true
+ when:
+ status: failure
diff --git a/data/ansible/drone/drone_setup.retry b/data/ansible/drone/drone_setup.retry
new file mode 100644
index 000000000..2fbb50c4a
--- /dev/null
+++ b/data/ansible/drone/drone_setup.retry
@@ -0,0 +1 @@
+localhost
diff --git a/data/ansible/drone/drone_setup.yaml b/data/ansible/drone/drone_setup.yaml
new file mode 100644
index 000000000..eaeadafb9
--- /dev/null
+++ b/data/ansible/drone/drone_setup.yaml
@@ -0,0 +1,60 @@
+- hosts: localhost
+ vars:
+ github_client_id: f378ce41a211899bb672
+ github_client_secret: 6557b7ff2b69ab4fcfed44172b98e89d30733341
+ drone_server_host: 5fd0-86-125-244-213.ngrok.io
+ tasks:
+ # We need docker first
+ # - name: Configure docker
+ # include: docker.yaml
+
+ # We will use this image in order to spin up the drone server
+ - name: Pull drone image
+ become: yes
+ shell: docker pull drone/drone:2
+
+ # We will use this image in order to run builds whenever an event occurs. (ie. pull request)
+ - name: Pull drone runner image
+ become: yes
+ shell: docker pull drone/drone-runner-docker:1
+
+ # We need to generate a secret in order to parse it to the drone server configuration
+ - name: generate RPCSecret
+ shell: "openssl rand -hex 16"
+ register: drone_secret
+
+ # Start drone server with proper configuration
+ - name: Start drone server
+ become: yes
+ shell: >
+ docker run \
+ --volume=/var/lib/drone:/data \
+ --env=DRONE_GITHUB_CLIENT_ID={{ github_client_id }} \
+ --env=DRONE_GITHUB_CLIENT_SECRET={{ github_client_secret }} \
+ --env=DRONE_RPC_SECRET={{ drone_secret.stdout }} \
+ --env=DRONE_SERVER_HOST={{ drone_server_host }} \
+ --env=DRONE_SERVER_PROTO=https \
+ --publish=80:80 \
+ --publish=443:443 \
+ --restart=always \
+ --detach=true \
+ --name=drone \
+ drone/drone:2
+
+ # Start drone runner with prper configuration
+ - name: Start drone runner
+ become: yes
+ shell: >
+ docker run --detach \
+ --volume=/var/run/docker.sock:/var/run/docker.sock \
+ --env=DRONE_RPC_PROTO=https \
+ --env=DRONE_RPC_HOST={{ drone_server_host }} \
+ --env=DRONE_RPC_SECRET={{ drone_secret.stdout }} \
+ --env=DRONE_RUNNER_CAPACITY=2 \
+ --env=DRONE_RUNNER_NAME=drone-runner \
+ --publish=3000:3000 \
+ --restart=always \
+ --name=drone-runner \
+ drone/drone-runner-docker:1
+
+
\ No newline at end of file
diff --git a/data/docker/integration/scripts/mongo/create_user.js b/data/docker/integration/scripts/mongo/create_user.js
new file mode 100644
index 000000000..169461df6
--- /dev/null
+++ b/data/docker/integration/scripts/mongo/create_user.js
@@ -0,0 +1,9 @@
+db = db.getSiblingDB('cgrates')
+db.createUser(
+ {
+ user: "cgrates",
+ pwd: "CGRateS.org",
+ roles: [ { role: "dbAdmin", db: "cgrates" } ]
+ }
+)
+
diff --git a/data/docker/integration/scripts/mongo/setup_cgr_db.sh b/data/docker/integration/scripts/mongo/setup_cgr_db.sh
new file mode 100755
index 000000000..4cbc93516
--- /dev/null
+++ b/data/docker/integration/scripts/mongo/setup_cgr_db.sh
@@ -0,0 +1,14 @@
+#! /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/postgres/create_cdrs_tables.sql b/data/docker/integration/scripts/postgres/create_cdrs_tables.sql
new file mode 100644
index 000000000..3ae7d5ccb
--- /dev/null
+++ b/data/docker/integration/scripts/postgres/create_cdrs_tables.sql
@@ -0,0 +1,59 @@
+--
+-- Table structure for table `cdrs`
+--
+
+DROP TABLE IF EXISTS cdrs;
+CREATE TABLE cdrs (
+ id SERIAL PRIMARY KEY,
+ cgrid VARCHAR(40) NOT NULL,
+ run_id VARCHAR(64) NOT NULL,
+ origin_host VARCHAR(64) NOT NULL,
+ source VARCHAR(64) NOT NULL,
+ origin_id VARCHAR(128) NOT NULL,
+ tor VARCHAR(16) NOT NULL,
+ request_type VARCHAR(24) NOT NULL,
+ tenant VARCHAR(64) NOT NULL,
+ category VARCHAR(64) NOT NULL,
+ account VARCHAR(128) NOT NULL,
+ 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,
+ usage BIGINT NOT NULL,
+ extra_fields jsonb NOT NULL,
+ cost_source VARCHAR(64) NOT NULL,
+ cost NUMERIC(20,4) DEFAULT NULL,
+ cost_details jsonb,
+ extra_info text,
+ created_at TIMESTAMP WITH TIME ZONE,
+ updated_at TIMESTAMP WITH TIME ZONE NULL,
+ deleted_at TIMESTAMP WITH TIME ZONE NULL,
+ UNIQUE (cgrid, run_id)
+);
+;
+DROP INDEX IF EXISTS deleted_at_cp_idx;
+CREATE INDEX deleted_at_cp_idx ON cdrs (deleted_at);
+
+
+DROP TABLE IF EXISTS session_costs;
+CREATE TABLE session_costs (
+ id SERIAL PRIMARY KEY,
+ cgrid VARCHAR(40) NOT NULL,
+ run_id VARCHAR(64) NOT NULL,
+ origin_host VARCHAR(64) NOT NULL,
+ origin_id VARCHAR(128) NOT NULL,
+ cost_source VARCHAR(64) NOT NULL,
+ usage BIGINT NOT NULL,
+ cost_details jsonb,
+ created_at TIMESTAMP WITH TIME ZONE,
+ deleted_at TIMESTAMP WITH TIME ZONE NULL,
+ UNIQUE (cgrid, run_id)
+);
+DROP INDEX IF EXISTS cgrid_sessionscost_idx;
+CREATE INDEX cgrid_sessionscost_idx ON session_costs (cgrid, run_id);
+DROP INDEX IF EXISTS origin_sessionscost_idx;
+CREATE INDEX origin_sessionscost_idx ON session_costs (origin_host, origin_id);
+DROP INDEX IF EXISTS run_origin_sessionscost_idx;
+CREATE INDEX run_origin_sessionscost_idx ON session_costs (run_id, origin_id);
+DROP INDEX IF EXISTS deleted_at_sessionscost_idx;
+CREATE INDEX deleted_at_sessionscost_idx ON session_costs (deleted_at);
diff --git a/data/docker/integration/scripts/postgres/create_db_with_users.sh b/data/docker/integration/scripts/postgres/create_db_with_users.sh
new file mode 100755
index 000000000..484290ec1
--- /dev/null
+++ b/data/docker/integration/scripts/postgres/create_db_with_users.sh
@@ -0,0 +1,9 @@
+
+#
+# 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
new file mode 100755
index 000000000..c697fa9d5
--- /dev/null
+++ b/data/docker/integration/scripts/postgres/create_ers_db.sh
@@ -0,0 +1,4 @@
+
+# extra DB for ees and 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
new file mode 100644
index 000000000..cbc175e47
--- /dev/null
+++ b/data/docker/integration/scripts/postgres/create_tariffplan_tables.sql
@@ -0,0 +1,477 @@
+--
+-- Table structure for table `tp_timings`
+--
+DROP TABLE IF EXISTS tp_timings;
+CREATE TABLE tp_timings (
+ id SERIAL PRIMARY KEY,
+ tpid VARCHAR(64) NOT NULL,
+ tag VARCHAR(64) NOT NULL,
+ years VARCHAR(255) NOT NULL,
+ months VARCHAR(255) NOT NULL,
+ month_days VARCHAR(255) NOT NULL,
+ week_days VARCHAR(255) NOT NULL,
+ time VARCHAR(32) NOT NULL,
+ created_at TIMESTAMP WITH TIME ZONE,
+ UNIQUE (tpid, tag)
+);
+CREATE INDEX tptimings_tpid_idx ON tp_timings (tpid);
+CREATE INDEX tptimings_idx ON tp_timings (tpid,tag);
+
+--
+-- Table structure for table `tp_destinations`
+--
+
+DROP TABLE IF EXISTS tp_destinations;
+CREATE TABLE tp_destinations (
+ id SERIAL PRIMARY KEY,
+ tpid VARCHAR(64) NOT NULL,
+ tag VARCHAR(64) NOT NULL,
+ prefix VARCHAR(24) NOT NULL,
+ created_at TIMESTAMP WITH TIME ZONE,
+ UNIQUE (tpid, tag, prefix)
+);
+CREATE INDEX tpdests_tpid_idx ON tp_destinations (tpid);
+CREATE INDEX tpdests_idx ON tp_destinations (tpid,tag);
+
+--
+-- Table structure for table `tp_rates`
+--
+
+DROP TABLE IF EXISTS tp_rates;
+CREATE TABLE tp_rates (
+ id SERIAL PRIMARY KEY,
+ tpid VARCHAR(64) NOT NULL,
+ tag VARCHAR(64) NOT NULL,
+ connect_fee NUMERIC(7,4) NOT NULL,
+ rate NUMERIC(10,4) NOT NULL,
+ rate_unit VARCHAR(16) NOT NULL,
+ rate_increment VARCHAR(16) NOT NULL,
+ group_interval_start VARCHAR(16) NOT NULL,
+ created_at TIMESTAMP WITH TIME ZONE,
+ UNIQUE (tpid, tag, group_interval_start)
+);
+CREATE INDEX tprates_tpid_idx ON tp_rates (tpid);
+CREATE INDEX tprates_idx ON tp_rates (tpid,tag);
+
+--
+-- Table structure for table `destination_rates`
+--
+
+DROP TABLE IF EXISTS tp_destination_rates;
+CREATE TABLE tp_destination_rates (
+ id SERIAL PRIMARY KEY,
+ tpid VARCHAR(64) NOT NULL,
+ tag VARCHAR(64) NOT NULL,
+ destinations_tag VARCHAR(64) NOT NULL,
+ rates_tag VARCHAR(64) NOT NULL,
+ rounding_method VARCHAR(255) NOT NULL,
+ rounding_decimals SMALLINT NOT NULL,
+ max_cost NUMERIC(7,4) NOT NULL,
+ max_cost_strategy VARCHAR(16) NOT NULL,
+ created_at TIMESTAMP WITH TIME ZONE,
+ UNIQUE (tpid, tag , destinations_tag)
+);
+CREATE INDEX tpdestrates_tpid_idx ON tp_destination_rates (tpid);
+CREATE INDEX tpdestrates_idx ON tp_destination_rates (tpid,tag);
+
+--
+-- Table structure for table `tp_rating_plans`
+--
+
+DROP TABLE IF EXISTS tp_rating_plans;
+CREATE TABLE tp_rating_plans (
+ id SERIAL PRIMARY KEY,
+ tpid VARCHAR(64) NOT NULL,
+ tag VARCHAR(64) NOT NULL,
+ destrates_tag VARCHAR(64) NOT NULL,
+ timing_tag VARCHAR(64) NOT NULL,
+ weight NUMERIC(8,2) NOT NULL,
+ created_at TIMESTAMP WITH TIME ZONE,
+ UNIQUE (tpid, tag, destrates_tag, timing_tag)
+);
+CREATE INDEX tpratingplans_tpid_idx ON tp_rating_plans (tpid);
+CREATE INDEX tpratingplans_idx ON tp_rating_plans (tpid,tag);
+
+
+--
+-- Table structure for table `tp_rate_profiles`
+--
+
+DROP TABLE IF EXISTS tp_rating_profiles;
+CREATE TABLE tp_rating_profiles (
+ id SERIAL PRIMARY KEY,
+ tpid VARCHAR(64) NOT NULL,
+ loadid VARCHAR(64) NOT NULL,
+ tenant VARCHAR(64) NOT NULL,
+ category VARCHAR(32) NOT NULL,
+ subject VARCHAR(64) NOT NULL,
+ activation_time VARCHAR(26) NOT NULL,
+ rating_plan_tag VARCHAR(64) NOT NULL,
+ fallback_subjects VARCHAR(64),
+ created_at TIMESTAMP WITH TIME ZONE,
+ UNIQUE (tpid, loadid, tenant, category, subject, activation_time)
+);
+CREATE INDEX tpratingprofiles_tpid_idx ON tp_rating_profiles (tpid);
+CREATE INDEX tpratingprofiles_idx ON tp_rating_profiles (tpid,loadid,tenant,category,subject);
+
+--
+-- Table structure for table `tp_shared_groups`
+--
+
+DROP TABLE IF EXISTS tp_shared_groups;
+CREATE TABLE tp_shared_groups (
+ id SERIAL PRIMARY KEY,
+ tpid VARCHAR(64) NOT NULL,
+ tag VARCHAR(64) NOT NULL,
+ account VARCHAR(64) NOT NULL,
+ strategy VARCHAR(24) NOT NULL,
+ rating_subject VARCHAR(24) NOT NULL,
+ created_at TIMESTAMP WITH TIME ZONE,
+ UNIQUE (tpid, tag, account , strategy , rating_subject)
+);
+CREATE INDEX tpsharedgroups_tpid_idx ON tp_shared_groups (tpid);
+CREATE INDEX tpsharedgroups_idx ON tp_shared_groups (tpid,tag);
+
+--
+-- Table structure for table `tp_actions`
+--
+
+DROP TABLE IF EXISTS tp_actions;
+CREATE TABLE tp_actions (
+ id SERIAL PRIMARY KEY,
+ tpid VARCHAR(64) NOT NULL,
+ tag VARCHAR(64) NOT NULL,
+ action VARCHAR(24) NOT NULL,
+ extra_parameters VARCHAR(256) NOT NULL,
+ filters VARCHAR(256) NOT NULL,
+ balance_tag VARCHAR(64) NOT NULL,
+ balance_type VARCHAR(24) NOT NULL,
+ categories VARCHAR(32) NOT NULL,
+ destination_tags VARCHAR(64) NOT NULL,
+ rating_subject VARCHAR(64) NOT NULL,
+ shared_groups VARCHAR(64) NOT NULL,
+ expiry_time VARCHAR(26) NOT NULL,
+ timing_tags VARCHAR(128) NOT NULL,
+ units VARCHAR(256) NOT NULL,
+ balance_weight VARCHAR(10) NOT NULL,
+ balance_blocker VARCHAR(5) NOT NULL,
+ balance_disabled VARCHAR(5) NOT NULL,
+ weight NUMERIC(8,2) NOT NULL,
+ created_at TIMESTAMP WITH TIME ZONE,
+ UNIQUE (tpid, tag, action, balance_tag, balance_type, expiry_time, timing_tags, destination_tags, shared_groups, balance_weight, weight)
+);
+CREATE INDEX tpactions_tpid_idx ON tp_actions (tpid);
+CREATE INDEX tpactions_idx ON tp_actions (tpid,tag);
+
+--
+-- Table structure for table `tp_action_timings`
+--
+
+DROP TABLE IF EXISTS tp_action_plans;
+CREATE TABLE tp_action_plans (
+ id SERIAL PRIMARY KEY,
+ tpid VARCHAR(64) NOT NULL,
+ tag VARCHAR(64) NOT NULL,
+ actions_tag VARCHAR(64) NOT NULL,
+ timing_tag VARCHAR(64) NOT NULL,
+ weight NUMERIC(8,2) NOT NULL,
+ created_at TIMESTAMP WITH TIME ZONE,
+ UNIQUE (tpid, tag, actions_tag, timing_tag)
+);
+CREATE INDEX tpactionplans_tpid_idx ON tp_action_plans (tpid);
+CREATE INDEX tpactionplans_idx ON tp_action_plans (tpid,tag);
+
+--
+-- Table structure for table tp_action_triggers
+--
+
+DROP TABLE IF EXISTS tp_action_triggers;
+CREATE TABLE tp_action_triggers (
+ id SERIAL PRIMARY KEY,
+ tpid VARCHAR(64) NOT NULL,
+ tag VARCHAR(64) NOT NULL,
+ unique_id VARCHAR(64) NOT NULL,
+ threshold_type VARCHAR(64) NOT NULL,
+ threshold_value NUMERIC(20,4) NOT NULL,
+ recurrent BOOLEAN NOT NULL,
+ min_sleep VARCHAR(16) NOT NULL,
+ expiry_time VARCHAR(26) NOT NULL,
+ activation_time VARCHAR(26) NOT NULL,
+ balance_tag VARCHAR(64) NOT NULL,
+ balance_type VARCHAR(24) NOT NULL,
+ balance_categories VARCHAR(32) NOT NULL,
+ balance_destination_tags VARCHAR(64) NOT NULL,
+ balance_rating_subject VARCHAR(64) NOT NULL,
+ balance_shared_groups VARCHAR(64) NOT NULL,
+ balance_expiry_time VARCHAR(26) NOT NULL,
+ balance_timing_tags VARCHAR(128) NOT NULL,
+ balance_weight VARCHAR(10) NOT NULL,
+ balance_blocker VARCHAR(5) NOT NULL,
+ balance_disabled VARCHAR(5) NOT NULL,
+ actions_tag VARCHAR(64) NOT NULL,
+ weight NUMERIC(8,2) NOT NULL,
+ created_at TIMESTAMP WITH TIME ZONE,
+ UNIQUE (tpid, tag, balance_tag, balance_type, threshold_type, threshold_value, balance_destination_tags, actions_tag)
+);
+CREATE INDEX tpactiontrigers_tpid_idx ON tp_action_triggers (tpid);
+CREATE INDEX tpactiontrigers_idx ON tp_action_triggers (tpid,tag);
+
+--
+-- Table structure for table tp_account_actions
+--
+
+DROP TABLE IF EXISTS tp_account_actions;
+CREATE TABLE tp_account_actions (
+ id SERIAL PRIMARY KEY,
+ tpid VARCHAR(64) NOT NULL,
+ loadid VARCHAR(64) NOT NULL,
+ tenant VARCHAR(64) NOT NULL,
+ account VARCHAR(64) NOT NULL,
+ action_plan_tag VARCHAR(64),
+ action_triggers_tag VARCHAR(64),
+ allow_negative BOOLEAN NOT NULL,
+ disabled BOOLEAN NOT NULL,
+ created_at TIMESTAMP WITH TIME ZONE,
+ UNIQUE (tpid, loadid, tenant, account)
+);
+CREATE INDEX tpaccountactions_tpid_idx ON tp_account_actions (tpid);
+CREATE INDEX tpaccountactions_idx ON tp_account_actions (tpid,loadid,tenant,account);
+
+
+--
+-- Table structure for table `tp_resources`
+--
+
+DROP TABLE IF EXISTS tp_resources;
+CREATE TABLE tp_resources (
+ "pk" SERIAL PRIMARY KEY,
+ "tpid" varchar(64) NOT NULL,
+ "tenant"varchar(64) NOT NULL,
+ "id" varchar(64) NOT NULL,
+ "filter_ids" varchar(64) NOT NULL,
+ "activation_interval" varchar(64) NOT NULL,
+ "usage_ttl" varchar(32) NOT NULL,
+ "limit" varchar(64) NOT NULL,
+ "allocation_message" varchar(64) NOT NULL,
+ "blocker" BOOLEAN NOT NULL,
+ "stored" BOOLEAN NOT NULL,
+ "weight" NUMERIC(8,2) NOT NULL,
+ "threshold_ids" varchar(64) NOT NULL,
+ "created_at" TIMESTAMP WITH TIME ZONE
+);
+CREATE INDEX tp_resources_idx ON tp_resources (tpid);
+CREATE INDEX tp_resources_unique ON tp_resources ("tpid", "tenant", "id", "filter_ids");
+
+
+--
+-- Table structure for table `tp_stats`
+--
+
+DROP TABLE IF EXISTS tp_stats;
+CREATE TABLE tp_stats (
+ "pk" SERIAL PRIMARY KEY,
+ "tpid" varchar(64) NOT NULL,
+ "tenant"varchar(64) NOT NULL,
+ "id" varchar(64) NOT NULL,
+ "filter_ids" varchar(64) NOT NULL,
+ "activation_interval" varchar(64) NOT NULL,
+ "queue_length" INTEGER NOT NULL,
+ "ttl" varchar(32) NOT NULL,
+ "min_items" INTEGER NOT NULL,
+ "metric_ids" VARCHAR(128) NOT NULL,
+ "metric_filter_ids" VARCHAR(128) NOT NULL,
+ "stored" BOOLEAN NOT NULL,
+ "blocker" BOOLEAN NOT NULL,
+ "weight" decimal(8,2) NOT NULL,
+ "threshold_ids" varchar(64) NOT NULL,
+ "created_at" TIMESTAMP WITH TIME ZONE
+);
+CREATE INDEX tp_stats_idx ON tp_stats (tpid);
+CREATE INDEX tp_stats_unique ON tp_stats ("tpid","tenant", "id", "filter_ids","metric_ids");
+
+--
+-- Table structure for table `tp_threshold_cfgs`
+--
+
+DROP TABLE IF EXISTS tp_thresholds;
+CREATE TABLE tp_thresholds (
+ "pk" SERIAL PRIMARY KEY,
+ "tpid" varchar(64) NOT NULL,
+ "tenant"varchar(64) NOT NULL,
+ "id" varchar(64) NOT NULL,
+ "filter_ids" varchar(64) NOT NULL,
+ "activation_interval" varchar(64) NOT NULL,
+ "max_hits" INTEGER NOT NULL,
+ "min_hits" INTEGER NOT NULL,
+ "min_sleep" varchar(16) NOT NULL,
+ "blocker" BOOLEAN NOT NULL,
+ "weight" decimal(8,2) NOT NULL,
+ "action_ids" varchar(64) NOT NULL,
+ "async" BOOLEAN NOT NULL,
+ "created_at" TIMESTAMP WITH TIME ZONE
+);
+CREATE INDEX tp_thresholds_idx ON tp_thresholds (tpid);
+CREATE INDEX tp_thresholds_unique ON tp_thresholds ("tpid","tenant", "id","filter_ids","action_ids");
+
+--
+-- Table structure for table `tp_filter`
+--
+
+DROP TABLE IF EXISTS tp_filters;
+CREATE TABLE tp_filters (
+ "pk" SERIAL PRIMARY KEY,
+ "tpid" varchar(64) NOT NULL,
+ "tenant" varchar(64) NOT NULL,
+ "id" varchar(64) NOT NULL,
+ "type" varchar(16) NOT NULL,
+ "element" varchar(64) NOT NULL,
+ "values" varchar(256) NOT NULL,
+ "activation_interval" varchar(64) NOT NULL,
+ "created_at" TIMESTAMP WITH TIME ZONE
+);
+ CREATE INDEX tp_filters_idx ON tp_filters (tpid);
+ CREATE INDEX tp_filters_unique ON tp_filters ("tpid","tenant", "id", "type", "element");
+
+--
+-- Table structure for table `tp_routes`
+--
+
+DROP TABLE IF EXISTS tp_routes;
+CREATE TABLE tp_routes (
+ "pk" SERIAL PRIMARY KEY,
+ "tpid" varchar(64) NOT NULL,
+ "tenant"varchar(64) NOT NULL,
+ "id" varchar(64) NOT NULL,
+ "filter_ids" varchar(64) NOT NULL,
+ "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,
+ "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");
+
+ --
+ -- Table structure for table `tp_attributes`
+ --
+
+ DROP TABLE IF EXISTS tp_attributes;
+ CREATE TABLE tp_attributes (
+ "pk" SERIAL PRIMARY KEY,
+ "tpid" varchar(64) NOT NULL,
+ "tenant"varchar(64) NOT NULL,
+ "id" varchar(64) NOT NULL,
+ "contexts" varchar(64) NOT NULL,
+ "filter_ids" varchar(64) NOT NULL,
+ "activation_interval" varchar(64) NOT NULL,
+ "attribute_filter_ids" varchar(64) NOT NULL,
+ "path" varchar(64) NOT NULL,
+ "type" varchar(64) NOT NULL,
+ "value" varchar(64) NOT NULL,
+ "blocker" BOOLEAN NOT NULL,
+ "weight" decimal(8,2) NOT NULL,
+ "created_at" TIMESTAMP WITH TIME ZONE
+ );
+ CREATE INDEX tp_attributes_ids ON tp_attributes (tpid);
+ CREATE INDEX tp_attributes_unique ON tp_attributes ("tpid", "tenant", "id",
+ "filter_ids","path","value");
+
+ --
+ -- Table structure for table `tp_chargers`
+ --
+
+ DROP TABLE IF EXISTS tp_chargers;
+ CREATE TABLE tp_chargers (
+ "pk" SERIAL PRIMARY KEY,
+ "tpid" varchar(64) NOT NULL,
+ "tenant"varchar(64) NOT NULL,
+ "id" varchar(64) NOT NULL,
+ "filter_ids" varchar(64) NOT NULL,
+ "activation_interval" varchar(64) NOT NULL,
+ "run_id" varchar(64) NOT NULL,
+ "attribute_ids" varchar(64) NOT NULL,
+ "weight" decimal(8,2) NOT NULL,
+ "created_at" TIMESTAMP WITH TIME ZONE
+ );
+ CREATE INDEX tp_chargers_ids ON tp_chargers (tpid);
+ CREATE INDEX tp_chargers_unique ON tp_chargers ("tpid", "tenant", "id",
+ "filter_ids","run_id","attribute_ids");
+
+ --
+ -- Table structure for table `tp_dispatchers`
+ --
+
+ DROP TABLE IF EXISTS tp_dispatcher_profiles;
+ CREATE TABLE tp_dispatcher_profiles (
+ "pk" SERIAL PRIMARY KEY,
+ "tpid" varchar(64) NOT NULL,
+ "tenant" varchar(64) NOT NULL,
+ "id" varchar(64) NOT NULL,
+ "subsystems" varchar(64) NOT NULL,
+ "filter_ids" varchar(64) NOT NULL,
+ "activation_interval" varchar(64) NOT NULL,
+ "strategy" varchar(64) NOT NULL,
+ "strategy_parameters" varchar(64) NOT NULL,
+ "conn_id" varchar(64) NOT NULL,
+ "conn_filter_ids" varchar(64) NOT NULL,
+ "conn_weight" decimal(8,2) NOT NULL,
+ "conn_blocker" BOOLEAN NOT NULL,
+ "conn_parameters" varchar(64) NOT NULL,
+ "weight" decimal(8,2) NOT NULL,
+ "created_at" TIMESTAMP WITH TIME ZONE
+ );
+ CREATE INDEX tp_dispatcher_profiles_ids ON tp_dispatcher_profiles (tpid);
+ CREATE INDEX tp_dispatcher_profiles_unique ON tp_dispatcher_profiles ("tpid", "tenant", "id",
+ "filter_ids","strategy","conn_id","conn_filter_ids");
+
+--
+-- Table structure for table `tp_dispatchers`
+--
+
+ DROP TABLE IF EXISTS tp_dispatcher_hosts;
+ CREATE TABLE tp_dispatcher_hosts (
+ "pk" SERIAL PRIMARY KEY,
+ "tpid" varchar(64) NOT NULL,
+ "tenant" varchar(64) NOT NULL,
+ "id" varchar(64) NOT NULL,
+ "address" varchar(64) NOT NULL,
+ "transport" varchar(64) NOT NULL,
+ "connect_attempts" INTEGER NOT NULL,
+ "reconnects" INTEGER 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`
+--
+
+DROP TABLE IF EXISTS versions;
+CREATE TABLE versions (
+ "id" SERIAL PRIMARY KEY,
+ "item" varchar(64) NOT NULL,
+ "version" INTEGER NOT NULL,
+ UNIQUE ("id","item")
+);
diff --git a/data/docker/integration/scripts/postgres/pg_cdr_migration.sql b/data/docker/integration/scripts/postgres/pg_cdr_migration.sql
new file mode 100644
index 000000000..5f40cb6d0
--- /dev/null
+++ b/data/docker/integration/scripts/postgres/pg_cdr_migration.sql
@@ -0,0 +1,42 @@
+/*
+This script will migrate CDRs from the old CGRateS tables to the new cdrs table
+but it only migrate CDRs where the duration is > 0.
+If you need CDRs also with duration is = 0 you can make the appropriate change in the line beginning WHERE cdrs_primary.usage
+
+Also the script will process 10,000 CDRs before committing to save system resources
+especially in systems where they are millions of CDRs to be migrated
+You can increase or lower the value of step in the line after BEGIN below.
+*/
+
+DO $$
+DECLARE
+ max_cdrs bigint;
+ start_id bigint;
+ end_id bigint;
+ step bigint;
+BEGIN
+ /* You must change the step var to commit every step rows inserted */
+ step := 10000;
+ start_id := 0;
+ end_id := start_id + step;
+ select max(id) INTO max_cdrs from rated_cdrs;
+ WHILE start_id <= max_cdrs
+ LOOP
+ --RAISE NOTICE '%', (to_char(start_id, '99999999') || '-' || to_char(end_id, '99999999'));
+ INSERT INTO
+ cdrs(cgrid,run_id,origin_host,source,origin_id,tor,request_type,tenant,category,account,subject,destination,setup_time,pdd,answer_time,usage,supplier,disconnect_cause,extra_fields,cost_source,cost,cost_details,extra_info, created_at, updated_at, deleted_at)
+ SELECT cdrs_primary.cgrid,rated_cdrs.runid as run_id,cdrs_primary.cdrhost as origin_host,cdrs_primary.cdrsource as source,cdrs_primary.accid as origin_id, cdrs_primary.tor,rated_cdrs.reqtype as request_type, rated_cdrs.tenant,rated_cdrs.category, rated_cdrs.account, rated_cdrs.subject, rated_cdrs.destination,rated_cdrs.setup_time,rated_cdrs.pdd,rated_cdrs.answer_time,rated_cdrs.usage,rated_cdrs.supplier,rated_cdrs.disconnect_cause,cdrs_extra.extra_fields,cost_details.cost_source,rated_cdrs.cost,cost_details.timespans as cost_details,rated_cdrs.extra_info,rated_cdrs.created_at,rated_cdrs.updated_at, rated_cdrs.deleted_at
+ FROM rated_cdrs
+ INNER JOIN cdrs_primary ON rated_cdrs.cgrid = cdrs_primary.cgrid
+ INNER JOIN cdrs_extra ON rated_cdrs.cgrid = cdrs_extra.cgrid
+ INNER JOIN cost_details ON rated_cdrs.cgrid = cost_details.cgrid
+ WHERE cdrs_primary.usage > '0'
+ AND not exists (select 1 from cdrs c where c.cgrid = cdrs_primary.cgrid)
+ AND rated_cdrs.id >= start_id
+ AND rated_cdrs.id < end_id
+ ;
+ start_id = start_id + step;
+ end_id = end_id + step;
+ END LOOP;
+END
+$$;
diff --git a/data/docker/integration/scripts/postgres/setup_cgr_db.sh b/data/docker/integration/scripts/postgres/setup_cgr_db.sh
new file mode 100755
index 000000000..66d011763
--- /dev/null
+++ b/data/docker/integration/scripts/postgres/setup_cgr_db.sh
@@ -0,0 +1,30 @@
+#! /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}}
+ |
+
+ Successful build #{{ build.number }}
+
+ |
+ {{else}}
+
+
+ Failed build #{{ build.number }}
+
+ |
+ {{/success}}
+
+
+
+
+
+ |
+ 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/engine/libengine_test.go b/engine/libengine_test.go
index 7746ee019..e40800994 100644
--- a/engine/libengine_test.go
+++ b/engine/libengine_test.go
@@ -85,21 +85,22 @@ func TestLibengineNewRPCConnection(t *testing.T) {
TLS: true,
ClientKey: "key1",
}
- expectedErr := "dial tcp [::1]:6012: connect: connection refused"
+ expectedErr1 := "dial tcp [::1]:6012: connect: connection refused"
+ expectedErr2 := "dial tcp 127.0.0.1:6012: connect: connection refused"
cM := NewConnManager(config.NewDefaultCGRConfig(), nil)
exp, err := rpcclient.NewRPCClient(utils.TCP, cfg.Address, cfg.TLS, cfg.ClientKey, cM.cfg.TLSCfg().ClientCerificate,
cM.cfg.TLSCfg().CaCertificate, cfg.ConnectAttempts, cfg.Reconnects, cfg.ConnectTimeout, cfg.ReplyTimeout,
cfg.Transport, nil, false, nil)
- if err.Error() != expectedErr {
- t.Errorf("Expected %v \n but received \n %v", expectedErr, err)
+ if err.Error() != expectedErr1 && err.Error() != expectedErr2 {
+ t.Errorf("Expected %v or %v \n but received \n %v", expectedErr1, expectedErr2, err)
}
conn, err := NewRPCConnection(cfg, cM.cfg.TLSCfg().ClientKey, cM.cfg.TLSCfg().ClientCerificate, cM.cfg.TLSCfg().CaCertificate,
cM.cfg.GeneralCfg().ConnectAttempts, cM.cfg.GeneralCfg().Reconnects, cM.cfg.GeneralCfg().ConnectTimeout, cM.cfg.GeneralCfg().ReplyTimeout,
nil, false, nil, "*localhost", "a4f3f", new(ltcache.Cache))
- if err.Error() != expectedErr {
- t.Errorf("Expected %v \n but received \n %v", expectedErr, err)
+ if err.Error() != expectedErr1 && err.Error() != expectedErr2 {
+ t.Errorf("Expected %v or %v \n but received \n %v", expectedErr1, expectedErr2, err)
}
if !reflect.DeepEqual(exp, conn) {
t.Error("Connections don't match")
diff --git a/recipients b/recipients
new file mode 100644
index 000000000..8a8ab6c60
--- /dev/null
+++ b/recipients
@@ -0,0 +1 @@
+nickolas.filip@itsyscom.com
diff --git a/recipients_backup b/recipients_backup
new file mode 100644
index 000000000..d41e9d311
--- /dev/null
+++ b/recipients_backup
@@ -0,0 +1,4 @@
+andrei.andronache@itsyscom.com
+ionut.boangiu@itsyscom.com
+adrian.porosnicu@itsyscom.com
+nickolas.filip@itsyscom.com