You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by mi...@apache.org on 2018/07/11 01:19:54 UTC
[trafficcontrol] 07/13: successfully built the API Tests for
StaticDNSEntries
This is an automated email from the ASF dual-hosted git repository.
mitchell852 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
commit 712fbe2983f6125441618376053574bc6d134a0b
Author: Dewayne Richardson <de...@apache.org>
AuthorDate: Thu May 31 08:03:18 2018 -0600
successfully built the API Tests for StaticDNSEntries
---
traffic_ops/testing/api/v13/profiles_test.go | 3 ---
traffic_ops/testing/api/v13/staticdnsentries_test.go | 10 +++-------
.../traffic_ops_golang/staticdnsentry/staticdnsentry.go | 11 ++++++++---
3 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/traffic_ops/testing/api/v13/profiles_test.go b/traffic_ops/testing/api/v13/profiles_test.go
index 42dc0c8..0610325 100644
--- a/traffic_ops/testing/api/v13/profiles_test.go
+++ b/traffic_ops/testing/api/v13/profiles_test.go
@@ -16,7 +16,6 @@
package v13
import (
- "fmt"
"testing"
"github.com/apache/trafficcontrol/lib/go-log"
@@ -46,8 +45,6 @@ func CreateTestProfiles(t *testing.T) {
for _, pr := range testData.Profiles {
cdns, _, err := TOSession.GetCDNByName(pr.CDNName)
respCDN := cdns[0]
- cdnName := respCDN.Name
- fmt.Printf("profileName: %s, cdnName %s\n", pr.Name, cdnName)
pr.CDNID = respCDN.ID
resp, _, err := TOSession.CreateProfile(pr)
diff --git a/traffic_ops/testing/api/v13/staticdnsentries_test.go b/traffic_ops/testing/api/v13/staticdnsentries_test.go
index 1cbe9ed..b74336d 100644
--- a/traffic_ops/testing/api/v13/staticdnsentries_test.go
+++ b/traffic_ops/testing/api/v13/staticdnsentries_test.go
@@ -16,7 +16,6 @@ package v13
*/
import (
- "fmt"
"testing"
"github.com/apache/incubator-trafficcontrol/lib/go-log"
@@ -38,9 +37,8 @@ func TestStaticDNSEntries(t *testing.T) {
CreateTestStaticDNSEntries(t)
GetTestStaticDNSEntries(t)
UpdateTestStaticDNSEntries(t)
- DeleteTestStaticDNSEntries(t)
- DeleteTestTypes(t)
DeleteTestDeliveryServices(t)
+ DeleteTestStaticDNSEntries(t)
DeleteTestServers(t)
DeleteTestCacheGroups(t)
DeleteTestPhysLocations(t)
@@ -99,14 +97,12 @@ func UpdateTestStaticDNSEntries(t *testing.T) {
t.Errorf("cannot GET StaticDNSEntries by name: '%s', %v\n", firstStaticDNSEntry.Host, err)
}
remoteStaticDNSEntry := resp[0]
- fmt.Printf("remoteStaticDNSEntry ---> %v\n", remoteStaticDNSEntry)
- fmt.Printf("remoteStaticDNSEntry.ID ---> %v\n", remoteStaticDNSEntry.ID)
- expectedAddress := "address99"
+ expectedAddress := "address2"
remoteStaticDNSEntry.Address = expectedAddress
var alert tc.Alerts
alert, _, err = TOSession.UpdateStaticDNSEntryByID(remoteStaticDNSEntry.ID, remoteStaticDNSEntry)
if err != nil {
- t.Errorf("cannot UPDATE StaticDNSEntries by id: %v - %v\n", err, alert)
+ t.Errorf("cannot UPDATE StaticDNSEntries using url: %v - %v\n", err, alert)
}
// Retrieve the StaticDNSEntries to check StaticDNSEntries name got updated
diff --git a/traffic_ops/traffic_ops_golang/staticdnsentry/staticdnsentry.go b/traffic_ops/traffic_ops_golang/staticdnsentry/staticdnsentry.go
index 0c2ac98..c64bc4c 100644
--- a/traffic_ops/traffic_ops_golang/staticdnsentry/staticdnsentry.go
+++ b/traffic_ops/traffic_ops_golang/staticdnsentry/staticdnsentry.go
@@ -171,6 +171,7 @@ ttl) VALUES (
//if so, it will return an errorType of DataConflict and the type should be appended to the
//generic error message returned
func (staticDNSEntry *TOStaticDNSEntry) Update(db *sqlx.DB, user auth.CurrentUser) (error, tc.ApiErrorType) {
+ fmt.Printf("staticDNSEntry.DeliveryService ---> %v\n", *staticDNSEntry.DeliveryService)
rollbackTransaction := true
tx, err := db.Beginx()
defer func() {
@@ -233,11 +234,12 @@ func (staticDNSEntry *TOStaticDNSEntry) Update(db *sqlx.DB, user auth.CurrentUse
func updateQuery() string {
query := `UPDATE
staticdnsentry SET
+id=:id,
address=:address,
-deliveryservice=:deliveryservice,
-cachegroup=:cachegroup,
+deliveryservice=:deliveryservice_id,
+cachegroup=:cachegroup_id,
host=:host,
-type=:type,
+type=:type_id,
ttl=:ttl
WHERE id=:id RETURNING last_updated`
return query
@@ -293,9 +295,12 @@ func selectQuery() string {
ds.xml_id as dsname,
sde.host,
sde.id as id,
+sde.deliveryservice as deliveryservice_id,
sde.ttl,
sde.address,
+tp.id as type_id,
tp.name as type,
+cg.id as cachegroup_id,
cg.name as cachegroup
FROM staticdnsentry as sde
JOIN type as tp on sde.type = tp.id