zrhoffman commented on a change in pull request #6520: URL: https://github.com/apache/trafficcontrol/pull/6520#discussion_r789932684
########## File path: traffic_router/ultimate-test-harness/http_test.go ########## @@ -0,0 +1,497 @@ +package main + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 ( + "encoding/json" + "flag" + "fmt" + "io/ioutil" + "log" + "math/rand" + "net" + "net/http" + "net/url" + "os" + "strconv" + "strings" + "testing" + "text/tabwriter" + "time" + + go_log "github.com/apache/trafficcontrol/lib/go-log" + "github.com/apache/trafficcontrol/lib/go-tc" + "github.com/apache/trafficcontrol/lib/go-util" + client "github.com/apache/trafficcontrol/traffic_ops/v4-client" + + "github.com/kelseyhightower/envconfig" +) + +const ( + UserAgent = "Traffic Router Load Tests" +) + +type TOConfig struct { + TOURL string `required:"true" envconfig:"TO_URL"` + TOUser string `required:"true" envconfig:"TO_USER"` + TOPassword string `required:"true" envconfig:"TO_PASSWORD"` + TOInsecure bool `default:"true" envconfig:"TO_INSECURE"` + TOTimeout int `default:"30" envconfig:"TO_TIMEOUT"` +} + +type TRDetails struct { + Hostname string + IPAddresses []string + ClientIP string + ClientIPAddressMap IPAddressMap + Port int + DSHost string + CDNName tc.CDNName +} + +type IPAddressMap struct { + Zones []string + Map map[string]tc.CoverageZoneLocation +} + +type Benchmark struct { + RequestsPerSecondThreshold int + BenchmarkTime int + ThreadCount int + ClientIP *string + PathCount int + MaxPathLength int + DSType tc.Type + TrafficRouters []TRDetails + CoverageZoneLocation string +} + +var ( + toConfig TOConfig + toSession *client.Session + count int +) + +func getTOConfig(t *testing.T) { + err := envconfig.Process("", &toConfig) + if err != nil { + t.Fatalf("reading configuration from the environment: %s", err.Error()) + } +} + +var ipv4Only *bool +var ipv6Only *bool +var cdnName *string +var deliveryServiceName *string +var trafficRouterName *string +var clientIPAddress *string +var useCoverageZone *bool +var coverageZoneLocation *string +var requestsPerSecondThreshold *int +var benchmarkTime *int +var threadCount *int +var pathCount *int +var maxPathLength *int + +func init() { + rand.Seed(time.Now().UnixNano()) + ipv4Only = flag.Bool("4", false, "test IPv4 addresses only") + ipv6Only = flag.Bool("6", false, "test IPv4 addresses only") + cdnName = flag.String("cdn", "", "the name of a CDN to search for Delivery Services") + deliveryServiceName = flag.String("ds", "", "the name (XMLID) of a Delivery Service to use for tests") + trafficRouterName = flag.String("hostname", "", "the hostname of a Traffic Router to use") + clientIPAddress = flag.String("ip_address", "", "spoof your client IP address to Traffic Router's geolocation") + useCoverageZone = flag.Bool("coverage_zone", false, "whether to use an IP address from the Traffic Router's Coverage Zone File") + coverageZoneLocation = flag.String("coverage_zone_location", "", "the Coverage Zone location to use (implies coverage_zone=true)") + requestsPerSecondThreshold = flag.Int("requests_threshold", 8000, "the minimum number of requests per second a Traffic Router must successfully respond to") + benchmarkTime = flag.Int("benchmark_time", 10, "the duration of each load test in seconds") + threadCount = flag.Int("thread_count", 12, "the number of threads to use for each test") + pathCount = flag.Int("path_count", 10000, "the number of paths to generate for use in requests to Delivery Services") + maxPathLength = flag.Int("max_path_length", 100, "the maximum length for each generated path") +} + +func getCoverageZoneURL(cdnName tc.CDNName) (string, error) { + snapshot, _, err := toSession.GetCRConfig(string(cdnName), client.RequestOptions{}) + if err != nil { + return "", fmt.Errorf("getting the Snapshot of CDN '%s': %s", cdnName, err.Error()) + } + czPollingURLInterface, ok := snapshot.Response.Config[tc.CoverageZonePollingURL] + czPollingURL := czPollingURLInterface.(string) + if !ok { + return "", fmt.Errorf("parameters %s was not found in the Snapshot of CDN '%s'", tc.CoverageZonePollingURL, cdnName) Review comment: Unpluralized in 6d45c06d8b -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
