Added integration tests for rjreader

This commit is contained in:
Trial97
2018-11-05 15:44:04 +02:00
committed by Dan Christian Bogos
parent f45c339bd7
commit 011eb27f4b
2 changed files with 65 additions and 0 deletions

View File

@@ -20,7 +20,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
package config
import (
"os"
"reflect"
"testing"
"time"
"github.com/cgrates/cgrates/utils"
)
@@ -28,6 +31,11 @@ import (
var mfCgrCfg *CGRConfig
func TestMfInitConfig(t *testing.T) {
for key, val := range map[string]string{"LOGGER": "*syslog", "LOG_LEVEL": "6", "TLS_VERIFY": "false", "ROUND_DEC": "5",
"DB_ENCODING": "*msgpack", "TP_EXPORT_DIR": "/var/spool/cgrates/tpe", "FAILED_POSTS_DIR": "/var/spool/cgrates/failed_posts",
"DF_TENANT": "cgrates.org", "TIMEZONE": "Local"} {
os.Setenv(key, val)
}
var err error
if mfCgrCfg, err = NewCGRConfigFromFolder("/usr/share/cgrates/conf/samples/multifiles"); err != nil {
t.Fatal("Got config error: ", err.Error())
@@ -88,3 +96,32 @@ func TestMfCdreExport1Instance(t *testing.T) {
t.Error("Unexpected headerField value: ", mfCgrCfg.CdreProfiles[prfl].ContentFields[2].Tag)
}
}
func TestEnvReaderITRead(t *testing.T) {
expected := GeneralCfg{
NodeID: "d80fac5",
Logger: "*syslog",
LogLevel: 6,
HttpSkipTlsVerify: false,
RoundingDecimals: 5,
DBDataEncoding: "msgpack",
TpExportPath: "/var/spool/cgrates/tpe",
PosterAttempts: 3,
FailedPostsDir: "/var/spool/cgrates/failed_posts",
DefaultReqType: utils.META_PSEUDOPREPAID,
DefaultCategory: "call",
DefaultTenant: "cgrates.org",
DefaultTimezone: "Local",
ConnectAttempts: 3,
Reconnects: -1,
ConnectTimeout: time.Duration(1 * time.Second),
ReplyTimeout: time.Duration(2 * time.Second),
ResponseCacheTTL: time.Duration(0),
InternalTtl: time.Duration(2 * time.Minute),
LockingTimeout: time.Duration(0),
DigestSeparator: ",",
DigestEqual: ":",
}
if !reflect.DeepEqual(expected, *mfCgrCfg.generalCfg) {
t.Errorf("Expected: %+v\n, recived: %+v", utils.ToJSON(expected), utils.ToJSON(*mfCgrCfg.generalCfg))
}
}

View File

@@ -0,0 +1,28 @@
{
// CGRateS Configuration file
// Used in multifile configuration tests
// Should be the second file loaded
"general": {
"node_id": "d80fac5", // identifier of this instance in the cluster, if empty it will be autogenerated
"logger":"*env:LOGGER", // controls the destination of logs <*syslog|*stdout>
"log_level": *env:LOG_LEVEL, // control the level of messages logged (0-emerg to 7-debug)
"http_skip_tls_verify": *env:TLS_VERIFY, // if enabled Http Client will accept any TLS certificate
"rounding_decimals": *env:ROUND_DEC, // system level precision for floats
"dbdata_encoding": "*env:DB_ENCODING", // encoding used to store object data in strings: <*msgpack|*json>
"tpexport_dir": "*env:TP_EXPORT_DIR", // path towards export folder for offline Tariff Plans
"poster_attempts": 3, // number of attempts before considering post request failed (eg: *call_url, CDR replication)
"failed_posts_dir": "*env:FAILED_POSTS_DIR", // directory path where we store failed requests
"default_tenant": "*env:DF_TENANT", // default tenant to consider when missing from requests
"default_timezone": "*env:TIMEZONE", // default timezone for timestamps where not specified <""|UTC|Local|$IANA_TZ_DB>
"connect_attempts": 3, // initial server connect attempts
"reconnects": -1, // number of retries in case of connection lost
"connect_timeout": "1s", // consider connection unsuccessful on timeout, 0 to disable the feature
"reply_timeout": "2s", // consider connection down for replies taking longer than this value
"response_cache_ttl": "0s", // the life span of a cached response
"internal_ttl": "2m", // maximum duration to wait for internal connections before giving up
"locking_timeout": "0", // timeout internal locks to avoid deadlocks
"digest_separator": ",",
"digest_equal": ":",
},
}