mitchell852 commented on a change in pull request #3559: TO: Hdr rw config test URL: https://github.com/apache/trafficcontrol/pull/3559#discussion_r283546048
########## File path: traffic_ops/testing/api/v14/hdr_rw_dot_config_test.go ########## @@ -0,0 +1,115 @@ +package v14 + +/* + 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 ( + "fmt" + "strconv" + "strings" + "testing" + + "github.com/apache/trafficcontrol/lib/go-log" + "github.com/apache/trafficcontrol/lib/go-tc" +) + +const EdgeHdrRwPrefix = "hdr_rw" +const MidHdrRwPrefix = "hdr_rw_mid" + +func TestHdrRwDotConfig(t *testing.T) { + WithObjs(t, []TCObj{CDNs, Types, Tenants, Parameters, Profiles, Statuses, Divisions, Regions, PhysLocations, CacheGroups, Servers, DeliveryServices}, func() { + GetTestHdrRwDotConfig(t) + GetTestHdrRwMidDotConfig(t) + }) +} + +func getFirstDnsOrHttpDeliveryService(t *testing.T) *tc.DeliveryServiceNullable { + dses, _, err := TOSession.GetDeliveryServicesNullable() + if err != nil { + t.Errorf("Cannot test hdr_rw_dot_config with no http or dns deliveryservices: %s", err) + return nil + } + + for _, ds := range dses { + switch *ds.Type { + case tc.DSTypeDNS: + case tc.DSTypeDNSLive: + case tc.DSTypeDNSLiveNational: + case tc.DSTypeHTTP: + case tc.DSTypeHTTPLive: + case tc.DSTypeHTTPLiveNational: + case tc.DSTypeHTTPNoCache: + default: + continue + } + + return &ds + } + + t.Errorf("Cannot test hdr_rw_dot_config with no http or dns deliveryservices: %s", err) + return nil + +} + +func getExpectedLines(rwRules string) int { Review comment: this method will work for this: getExpectedLines("rw1__RETURN__rw2__RETURN__edge__RETURN__header__RETURN__re-rewrite [L]") => returns 6 but won't work for this: getExpectedLines("rw1" + "\n" + "re-rewrite [L]") => returns 2 when it should be 3 ^^ think that's something you can fix so this method can be used for `__RETURN` and `\n` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
