You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by da...@apache.org on 2018/11/06 22:22:52 UTC
[trafficcontrol] 01/04: Fixed #2949
This is an automated email from the ASF dual-hosted git repository.
dangogh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
commit 201390c0673c946d78bd06a75aa6381b10e70ca6
Author: ocket8888 <oc...@gmail.com>
AuthorDate: Tue Oct 30 08:04:48 2018 -0600
Fixed #2949
---
traffic_ops/testing/compare/compare.go | 58 ++++++++++++++++++++++++++++++++--
1 file changed, 56 insertions(+), 2 deletions(-)
diff --git a/traffic_ops/testing/compare/compare.go b/traffic_ops/testing/compare/compare.go
index 8598f3a..1f38871 100644
--- a/traffic_ops/testing/compare/compare.go
+++ b/traffic_ops/testing/compare/compare.go
@@ -35,7 +35,9 @@ import (
"golang.org/x/net/publicsuffix"
)
-const __version__ = "1.0.0"
+const __version__ = "1.1.0"
+const SHORT_HEADER = "# DO NOT EDIT"
+const LONG_HEADER = "# TRAFFIC OPS NOTE:"
// Environment variables used:
// TO_URL -- URL for reference Traffic Ops
@@ -138,7 +140,59 @@ func testRoute(tos []*Connect, route string) {
wg.Wait()
close(ch)
- if res[0].Res == res[1].Res {
+ // Check for Traffic Ops headers and remove them before comparison
+ refResult := res[0].Res
+ testResult := res[1].Res
+ if strings.Contains(route, "configfiles") {
+ refLines := strings.Split(refResult, "\n")
+ testLines := strings.Split(testResult, "\n")
+
+ // If the two files have different numbers of lines, they definitely differ
+ if len(refLines) != len(testLines) {
+ log.Print("Diffs from ", route, " written to")
+ p, err := res[0].TO.writeResults(route, refResult)
+ if err != nil {
+ log.Fatal("Error writing results for ", route)
+ }
+ log.Print(" ", p)
+ p, err = res[1].TO.writeResults(route, testResult)
+ if err != nil {
+ log.Fatal("Error writing results for ", route)
+ }
+ log.Print(" and ", p)
+ }
+
+ refResult = ""
+ testResult = ""
+
+ for i, refLine := range refLines {
+ if len(refLine) < len(SHORT_HEADER) {
+ refResult += refLine
+ } else if refLine[:len(SHORT_HEADER)] != SHORT_HEADER {
+ if len(refLine) >= len(LONG_HEADER) {
+ if refLine[:len(LONG_HEADER)] != LONG_HEADER {
+ refResult += refLine
+ }
+ } else {
+ refResult += refLine
+ }
+ }
+
+ if len(testLines[i]) < len(SHORT_HEADER) {
+ testResult += testLines[i]
+ } else if testLines[i][:len(SHORT_HEADER)] != SHORT_HEADER {
+ if len(testLines[i]) >= len(LONG_HEADER) {
+ if testLines[i][:len(LONG_HEADER)] != LONG_HEADER {
+ testResult += testLines[i]
+ }
+ } else {
+ testResult += testLines[i]
+ }
+ }
+ }
+ }
+
+ if refResult == testResult {
log.Printf("Identical results (%d bytes) from %s", len(res[0].Res), route)
} else {
log.Print("Diffs from ", route, " written to")