started retesting failing tests

This commit is contained in:
Radu Ioan Fericean
2012-06-29 17:13:26 +03:00
parent 7adaa00f14
commit 81ace801d0
4 changed files with 28 additions and 19 deletions

View File

@@ -163,6 +163,7 @@ func loadRatingProfiles() {
continue
}
tenant, tor, direction, subject, fallbacksubject := record[0], record[1], record[2], record[3], record[4]
fmt.Sprintf("%s:%s:%s:%s:%s", direction, tenant, tor, subject)
at, err := time.Parse(time.RFC3339, record[6])
if err != nil {
log.Printf("Cannot parse activation time from %v", record[5])
@@ -189,8 +190,9 @@ func loadRatingProfiles() {
for _, p := range d.Prefixes { //destinations
// Search for a CallDescriptor with the same key
var cd *timespans.CallDescriptor
key := fmt.Sprintf("%s:%s:%s:%s:%s", direction, tenant, tor, subject, p)
for _, c := range ratingProfiles[p] {
if c.GetKey() == r.DestinationsTag {
if c.GetKey() == key {
cd = c
}
}

View File

@@ -1,4 +1,5 @@
Tenant,TOR,Direction,Subject,RatesFallbackSubject,RatesTimingTag,ActivationTime
CUSTOMER_1,0,OUT,rif:from:tm,danb,STANDARD,2012-01-01T00:00:00Z
CUSTOMER_1,0,OUT,rif:from:tm,danb,PREMIUM,2012-01-01T00:00:00Z
CUSTOMER_1,0,OUT,rif:from:tm,danb,STANDARD,2012-02-28T00:00:00Z
CUSTOMER_2,0,OUT,danb:87.139.12.167,danb,STANDARD,2012-01-01T00:00:00Z
CUSTOMER_1,0,OUT,danb,,PREMIUM,2012-01-01T00:00:00Z
1 Tenant TOR Direction Subject RatesFallbackSubject RatesTimingTag ActivationTime
2 CUSTOMER_1 0 OUT rif:from:tm danb STANDARD PREMIUM 2012-01-01T00:00:00Z
3 CUSTOMER_1 0 OUT rif:from:tm danb STANDARD 2012-02-28T00:00:00Z
4 CUSTOMER_2 0 OUT danb:87.139.12.167 danb STANDARD 2012-01-01T00:00:00Z
5 CUSTOMER_1 0 OUT danb PREMIUM 2012-01-01T00:00:00Z

View File

@@ -32,12 +32,18 @@ func init() {
}
func TestApRestoreRedis(t *testing.T) {
cd := &CallDescriptor{Tenant: "vdf",
Subject: "rif",
Destination: "0257"}
cd := &CallDescriptor{
Direction: "OUT",
TOR: "0",
Tenant: "CUSTOMER_1",
Subject: "rif:from:tm",
Destination: "49"}
cd.SearchStorageForPrefix()
if len(cd.ActivationPeriods) != 2 {
t.Error("Error restoring activation periods: ", cd.ActivationPeriods)
if len(cd.ActivationPeriods) != 4 {
for _, ap := range cd.ActivationPeriods {
t.Log(ap)
}
t.Error("Error restoring activation periods: ", len(cd.ActivationPeriods))
}
}
@@ -80,26 +86,26 @@ func TestApStoreRestoreBlank(t *testing.T) {
}
func TestFallbackDirect(t *testing.T) {
cd := &CallDescriptor{Tenant: "vdf", Subject: "rif", Destination: "0745"}
cd := &CallDescriptor{TOR: "0", Direction: "OUT", Tenant: "CUSTOMER_2", Subject: "danb:87.139.12.167", Destination: "41"}
cd.SearchStorageForPrefix()
if len(cd.ActivationPeriods) != 1 {
t.Error("Error restoring activation periods: ", cd.ActivationPeriods)
if len(cd.ActivationPeriods) != 3 {
t.Error("Error restoring activation periods: ", len(cd.ActivationPeriods))
}
}
func TestFallbackWithBackTrace(t *testing.T) {
cd := &CallDescriptor{Tenant: "vdf", Subject: "rif", Destination: "0745121"}
cd := &CallDescriptor{TOR: "0", Direction: "OUT", Tenant: "CUSTOMER_2", Subject: "danb:87.139.12.167", Destination: "4123"}
cd.SearchStorageForPrefix()
if len(cd.ActivationPeriods) != 1 {
t.Error("Error restoring activation periods: ", cd.ActivationPeriods)
if len(cd.ActivationPeriods) != 3 {
t.Error("Error restoring activation periods: ", len(cd.ActivationPeriods))
}
}
func TestFallbackDefault(t *testing.T) {
cd := &CallDescriptor{Tenant: "vdf", Subject: "rif", Destination: "00000"}
cd := &CallDescriptor{TOR: "0", Direction: "OUT", Tenant: "CUSTOMER_2", Subject: "danb:87.139.12.167", Destination: "0000"}
cd.SearchStorageForPrefix()
if len(cd.ActivationPeriods) != 1 {
t.Error("Error restoring activation periods: ", cd.ActivationPeriods)
if len(cd.ActivationPeriods) != 3 {
t.Error("Error restoring activation periods: ", len(cd.ActivationPeriods))
}
}
@@ -107,7 +113,7 @@ func TestFallbackNoInfiniteLoop(t *testing.T) {
cd := &CallDescriptor{Tenant: "vdf", Subject: "rif", Destination: "0721"}
cd.SearchStorageForPrefix()
if len(cd.ActivationPeriods) != 0 {
t.Error("Error restoring activation periods: ", cd.ActivationPeriods)
t.Error("Error restoring activation periods: ", len(cd.ActivationPeriods))
}
}

View File

@@ -96,7 +96,7 @@ Restores the activation periods for the specified prefix from storage.
*/
func (cd *CallDescriptor) SearchStorageForPrefix() (destPrefix string, err error) {
cd.ActivationPeriods = make([]*ActivationPeriod, 0)
base := fmt.Sprintf("%s:%s:%s:%s:", cd.Destination, cd.Tenant, cd.TOR, cd.Subject)
base := fmt.Sprintf("%s:%s:%s:%s:", cd.Direction, cd.Tenant, cd.TOR, cd.Subject)
destPrefix = cd.Destination
key := base + destPrefix
values, err := cd.getActivationPeriodsOrFallback(key, base, destPrefix, 1)
@@ -123,7 +123,7 @@ func (cd *CallDescriptor) getActivationPeriodsOrFallback(key, base, destPrefix s
recursionDepth++
return cd.getActivationPeriodsOrFallback(key, base, destPrefix, recursionDepth)
}
//get for a smaller prefix if the orignal one was not found
//get for a smaller prefix if the orignal one was not found
for i := len(cd.Destination); err != nil || fallbackKey != ""; {
if fallbackKey != "" {
base = fallbackKey + ":"