This is an automated email from the ASF dual-hosted git repository.
ocket8888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
The following commit(s) were added to refs/heads/master by this push:
new b66ba03 Fix API tests missing required location params (#4893)
b66ba03 is described below
commit b66ba03c254fee981bcb31bafc510485bee1ba51
Author: Robert O Butts <[email protected]>
AuthorDate: Fri Jul 17 17:03:43 2020 -0600
Fix API tests missing required location params (#4893)
---
traffic_ops/testing/api/v1/atsconfig_meta_test.go | 4 ++-
traffic_ops/testing/api/v1/atsconfig_test.go | 43 +++++++++++++++++++++++
traffic_ops/testing/api/v1/tc-fixtures.json | 14 ++++++++
3 files changed, 60 insertions(+), 1 deletion(-)
diff --git a/traffic_ops/testing/api/v1/atsconfig_meta_test.go
b/traffic_ops/testing/api/v1/atsconfig_meta_test.go
index 0372173..a75306f 100644
--- a/traffic_ops/testing/api/v1/atsconfig_meta_test.go
+++ b/traffic_ops/testing/api/v1/atsconfig_meta_test.go
@@ -16,7 +16,6 @@ package v1
*/
import (
- "strings"
"testing"
"github.com/apache/trafficcontrol/lib/go-tc"
@@ -35,6 +34,9 @@ func GetTestATSConfigMeta(t *testing.T) {
if len(testData.Servers) < 1 {
t.Fatal("cannot GET Server: no test data")
}
+
+ MakeConfigLocationParams(t)
+
testServer := testData.Servers[0]
serverList, _, err := TOSession.GetServerByHostName(testServer.HostName)
diff --git a/traffic_ops/testing/api/v1/atsconfig_test.go
b/traffic_ops/testing/api/v1/atsconfig_test.go
index 98b96e9..f793392 100644
--- a/traffic_ops/testing/api/v1/atsconfig_test.go
+++ b/traffic_ops/testing/api/v1/atsconfig_test.go
@@ -16,7 +16,10 @@ package v1
*/
import (
+ "strings"
"testing"
+
+ "github.com/apache/trafficcontrol/lib/go-tc"
)
func TestATSConfigs(t *testing.T) {
@@ -42,6 +45,8 @@ func GetTestATSConfigs(t *testing.T) {
}
server := serverList[0]
+ MakeConfigLocationParams(t)
+
_, _, err = TOSession.GetATSServerConfigList(server.ID)
if err != nil {
t.Fatalf("Getting server '" + server.HostName + "' config list:
" + err.Error() + "\n")
@@ -183,3 +188,41 @@ func DeleteTestDeliveryServiceServersCreated(t *testing.T)
{
t.Errorf("Found ds-to-server assignment {DSID: %d, Server: %d}
after deletion", *dss.DeliveryService, *dss.Server)
}
}
+
+func MakeConfigLocationParams(t *testing.T) {
+ for _, sv := range testData.Servers {
+ profileName := sv.Profile
+ profiles, _, err := TOSession.GetProfileByName(profileName)
+ if err != nil {
+ t.Fatalf("cannot GET Profile by name: %v - %v",
profileName, err)
+ } else if len(profiles) != 1 {
+ t.Fatal("missing server profile")
+ }
+ locationFiles := []string{
+ "cache.config",
+ "hosting.config",
+ "ip_allow.config",
+ "parent.config",
+ "plugin.config",
+ "records.config",
+ "remap.config",
+ "storage.config",
+ "volume.config",
+ }
+ for _, locationFileName := range locationFiles {
+ params, _, err :=
TOSession.GetParameterByNameAndConfigFile("location", locationFileName)
+ if err != nil {
+ t.Fatalf("getting location cache.config param:
%v", err)
+ } else if len(params) == 0 {
+ t.Fatal("missing location cache.config param")
+ }
+ _, _, err =
TOSession.CreateProfileParameter(tc.ProfileParameter{
+ ProfileID: profiles[0].ID,
+ ParameterID: params[0].ID,
+ })
+ if err != nil && !strings.Contains(err.Error(),
"already exists") {
+ t.Fatalf("creating location cache.config
profile parameter: %v", err)
+ }
+ }
+ }
+}
diff --git a/traffic_ops/testing/api/v1/tc-fixtures.json
b/traffic_ops/testing/api/v1/tc-fixtures.json
index be9210d..20af859 100644
--- a/traffic_ops/testing/api/v1/tc-fixtures.json
+++ b/traffic_ops/testing/api/v1/tc-fixtures.json
@@ -924,6 +924,20 @@
"name": "use_tenancy",
"secure": false,
"value": "1"
+ },
+ {
+ "configFile": "cache.config",
+ "lastUpdated": "2018-01-19T19:01:21.501151+00:00",
+ "name": "location",
+ "secure": false,
+ "value": "/opt/trafficserver/etc/trafficserver"
+ },
+ {
+ "configFile": "hosting.config",
+ "lastUpdated": "2018-01-19T19:01:21.501151+00:00",
+ "name": "location",
+ "secure": false,
+ "value": "/opt/trafficserver/etc/trafficserver"
}
],
"physLocations": [