You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by de...@apache.org on 2018/04/13 15:12:50 UTC

[incubator-trafficcontrol] branch master updated (29fbb4e -> 76840d4)

This is an automated email from the ASF dual-hosted git repository.

dewrich pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-trafficcontrol.git.


    from 29fbb4e  in global 5xx handler, if there are custom alerts, show them
     new 3f18c14  Added golang API CRUD tests for servers
     new fd78b41  Updated golang API servers tests
     new 76840d4  golang API servers test code cleanup

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 traffic_ops/testing/api/v13/servers_test.go | 174 ++++++++++++++++++++++++++++
 1 file changed, 174 insertions(+)
 create mode 100644 traffic_ops/testing/api/v13/servers_test.go

-- 
To stop receiving notification emails like this one, please contact
dewrich@apache.org.

[incubator-trafficcontrol] 01/03: Added golang API CRUD tests for servers

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dewrich pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-trafficcontrol.git

commit 3f18c14ea34fef198cff8850628203a0c8c40832
Author: Jesse Rivas <je...@comcast.com>
AuthorDate: Thu Apr 12 15:13:13 2018 -0600

    Added golang API CRUD tests for servers
---
 traffic_ops/testing/api/v13/servers_test.go | 176 ++++++++++++++++++++++++++++
 1 file changed, 176 insertions(+)

diff --git a/traffic_ops/testing/api/v13/servers_test.go b/traffic_ops/testing/api/v13/servers_test.go
new file mode 100644
index 0000000..083f1b4
--- /dev/null
+++ b/traffic_ops/testing/api/v13/servers_test.go
@@ -0,0 +1,176 @@
+package v13
+
+/*
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+*/
+
+import (
+	"testing"
+	"github.com/apache/incubator-trafficcontrol/lib/go-log"
+	"github.com/apache/incubator-trafficcontrol/lib/go-tc"
+)
+
+func TestServers(t *testing.T) {
+
+	CreateTestCDNs(t)
+	CreateTestTypes(t)
+	CreateTestProfiles(t)
+	CreateTestStatuses(t)
+	CreateTestDivisions(t)
+	CreateTestRegions(t)
+	CreateTestPhysLocations(t)
+	CreateTestCacheGroups(t)
+	CreateTestServers(t)
+
+	UpdateTestServers(t)
+	GetTestServers(t)
+
+	DeleteTestServers(t)
+	DeleteTestCacheGroups(t)
+	DeleteTestPhysLocations(t)
+	DeleteTestRegions(t)
+	DeleteTestDivisions(t)
+	DeleteTestStatuses(t)
+	DeleteTestProfiles(t)
+	DeleteTestTypes(t)
+	DeleteTestCDNs(t)
+
+}
+
+func CreateTestServers(t *testing.T) {
+
+	// GET EDGE1 profile
+	resp, _, err := TOSession.GetProfileByName("EDGE1")
+	if err != nil {
+		t.Errorf("cannot GET Profiles - %v\n", err)
+	}
+	respProfile := resp[0]
+
+	// GET EDGE type
+	resp2, _, err := TOSession.GetTypeByName("EDGE")
+	if err != nil {
+		t.Errorf("cannot GET Division by name: EDGE - %v\n", err)
+	}
+	respType := resp2[0]
+
+	// GET ONLINE status
+	resp3, _, err := TOSession.GetStatusByName("ONLINE")
+	if err != nil {
+		t.Errorf("cannot GET Status by name: ONLINE - %v\n", err)
+	}
+	respStatus := resp3[0]
+
+	// GET Denver physlocation
+	resp4, _, err := TOSession.GetPhysLocationByName("Denver")
+	if err != nil {
+		t.Errorf("cannot GET PhysLocation by name: Denver - %v\n", err)
+	}
+	respPhysLocation := resp4[0]
+
+	// GET cachegroup1 cachegroup
+	resp5, _, err := TOSession.GetCacheGroupByName("cachegroup1")
+	if err != nil {
+		t.Errorf("cannot GET CacheGroup by name: cachegroup1 - %v\n", err)
+	}
+	respCacheGroup := resp5[0]
+
+	// loop through servers, assign FKs and create
+	for _, server := range testData.Servers {
+		server.CDNID = respProfile.CDNID
+		server.ProfileID = respProfile.ID
+		server.TypeID = respType.ID
+		server.StatusID = respStatus.ID
+		server.PhysLocationID = respPhysLocation.ID
+		server.CachegroupID = respCacheGroup.ID
+
+		resp, _, err := TOSession.CreateServer(server)
+		log.Debugln("Response: ", server.HostName, " ", resp)
+		if err != nil {
+			t.Errorf("could not CREATE servers: %v\n", err)
+		}
+	}
+
+}
+
+func GetTestServers(t *testing.T) {
+
+	for _, server := range testData.Servers {
+		resp, _, err := TOSession.GetServerByHostName(server.HostName)
+		if err != nil {
+			t.Errorf("cannot GET Server by name: %v - %v\n", err, resp)
+		}
+	}
+}
+
+func UpdateTestServers(t *testing.T) {
+
+	firstServer := testData.Servers[0]
+	// Retrieve the Server by hostname so we can get the id for the Update
+	resp, _, err := TOSession.GetServerByHostName(firstServer.HostName)
+	if err != nil {
+		t.Errorf("cannot GET Server by hostname: %v - %v\n", firstServer.HostName, err)
+	}
+	remoteServer := resp[0]
+	updatedServerInterface := "bond1"
+	updatedServerRack := "RR 119.03"
+
+	// update rack and interfaceName values on server
+	remoteServer.InterfaceName = updatedServerInterface
+	remoteServer.Rack = updatedServerRack
+	var alert tc.Alerts
+	alert, _, err = TOSession.UpdateServerByID(remoteServer.ID, remoteServer)
+	if err != nil {
+		t.Errorf("cannot UPDATE Server by hostname: %v - %v\n", err, alert)
+	}
+
+	// Retrieve the Profile to check Profile name got updated
+	resp, _, err = TOSession.GetServerByID(remoteServer.ID)
+	if err != nil {
+		t.Errorf("cannot GET Server by ID: %v - %v\n", remoteServer.HostName, err)
+	}
+
+	respServer := resp[0]
+	if respServer.InterfaceName != updatedServerInterface || respServer.Rack != updatedServerRack {
+		t.Errorf("results do not match actual: %s, expected: %s\n", respServer.InterfaceName, updatedServerInterface)
+		t.Errorf("results do not match actual: %s, expected: %s\n", respServer.Rack, updatedServerRack)
+	}
+
+}
+
+func DeleteTestServers(t *testing.T) {
+
+	for _, server := range testData.Servers {
+		resp, _, err := TOSession.GetServerByHostName(server.HostName)
+		if err != nil {
+			t.Errorf("cannot GET Server by hostname: %v - %v\n", server.HostName, err)
+		}
+		if len(resp) > 0 {
+			respServer := resp[0]
+
+			delResp, _, err := TOSession.DeleteServerByID(respServer.ID)
+			if err != nil {
+				t.Errorf("cannot DELETE Server by hostname: %v - %v\n", err, delResp)
+			}
+
+			// Retrieve the Server to see if it got deleted
+			serv, _, err := TOSession.GetServerByHostName(server.HostName)
+			if err != nil {
+				t.Errorf("error deleting Server hostname: %s\n", err.Error())
+			}
+			if len(serv) > 0 {
+				t.Errorf("expected Server hostname: %s to be deleted\n", server.HostName)
+			}
+		}
+	}
+}
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
dewrich@apache.org.

[incubator-trafficcontrol] 03/03: golang API servers test code cleanup

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dewrich pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-trafficcontrol.git

commit 76840d4c02fb159e031e072ec4693969b675dda8
Author: Jesse Rivas <je...@comcast.com>
AuthorDate: Fri Apr 13 09:11:55 2018 -0600

    golang API servers test code cleanup
---
 traffic_ops/testing/api/v13/servers_test.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/traffic_ops/testing/api/v13/servers_test.go b/traffic_ops/testing/api/v13/servers_test.go
index ea7e484..207cfb7 100644
--- a/traffic_ops/testing/api/v13/servers_test.go
+++ b/traffic_ops/testing/api/v13/servers_test.go
@@ -16,9 +16,9 @@ package v13
 */
 
 import (
-	"testing"
 	"github.com/apache/incubator-trafficcontrol/lib/go-log"
 	"github.com/apache/incubator-trafficcontrol/lib/go-tc"
+	"testing"
 )
 
 func TestServers(t *testing.T) {

-- 
To stop receiving notification emails like this one, please contact
dewrich@apache.org.

[incubator-trafficcontrol] 02/03: Updated golang API servers tests

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dewrich pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-trafficcontrol.git

commit fd78b41650c4d062d12ccd033dc4a41e883a768c
Author: Jesse Rivas <je...@comcast.com>
AuthorDate: Thu Apr 12 15:27:19 2018 -0600

    Updated golang API servers tests
---
 traffic_ops/testing/api/v13/servers_test.go | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/traffic_ops/testing/api/v13/servers_test.go b/traffic_ops/testing/api/v13/servers_test.go
index 083f1b4..ea7e484 100644
--- a/traffic_ops/testing/api/v13/servers_test.go
+++ b/traffic_ops/testing/api/v13/servers_test.go
@@ -32,10 +32,8 @@ func TestServers(t *testing.T) {
 	CreateTestPhysLocations(t)
 	CreateTestCacheGroups(t)
 	CreateTestServers(t)
-
 	UpdateTestServers(t)
 	GetTestServers(t)
-
 	DeleteTestServers(t)
 	DeleteTestCacheGroups(t)
 	DeleteTestPhysLocations(t)
@@ -116,7 +114,7 @@ func GetTestServers(t *testing.T) {
 func UpdateTestServers(t *testing.T) {
 
 	firstServer := testData.Servers[0]
-	// Retrieve the Server by hostname so we can get the id for the Update
+	// Retrieve the server by hostname so we can get the id for the Update
 	resp, _, err := TOSession.GetServerByHostName(firstServer.HostName)
 	if err != nil {
 		t.Errorf("cannot GET Server by hostname: %v - %v\n", firstServer.HostName, err)
@@ -134,7 +132,7 @@ func UpdateTestServers(t *testing.T) {
 		t.Errorf("cannot UPDATE Server by hostname: %v - %v\n", err, alert)
 	}
 
-	// Retrieve the Profile to check Profile name got updated
+	// Retrieve the server to check rack and interfaceName values were updated
 	resp, _, err = TOSession.GetServerByID(remoteServer.ID)
 	if err != nil {
 		t.Errorf("cannot GET Server by ID: %v - %v\n", remoteServer.HostName, err)
@@ -160,7 +158,7 @@ func DeleteTestServers(t *testing.T) {
 
 			delResp, _, err := TOSession.DeleteServerByID(respServer.ID)
 			if err != nil {
-				t.Errorf("cannot DELETE Server by hostname: %v - %v\n", err, delResp)
+				t.Errorf("cannot DELETE Server by ID: %v - %v\n", err, delResp)
 			}
 
 			// Retrieve the Server to see if it got deleted
@@ -173,4 +171,4 @@ func DeleteTestServers(t *testing.T) {
 			}
 		}
 	}
-}
\ No newline at end of file
+}

-- 
To stop receiving notification emails like this one, please contact
dewrich@apache.org.