From cf14ba385daf61972e6da718283e80d1f71d1703 Mon Sep 17 00:00:00 2001 From: David Neuman Date: Mon, 21 Nov 2016 09:49:42 -0700 Subject: [PATCH 1/9] update server.go and server fixture for new API --- traffic_ops/client/fixtures/server.go | 22 +++++++++++----------- traffic_ops/client/server.go | 6 +++--- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/traffic_ops/client/fixtures/server.go b/traffic_ops/client/fixtures/server.go index 07c541af57..4184ad1089 100644 --- a/traffic_ops/client/fixtures/server.go +++ b/traffic_ops/client/fixtures/server.go @@ -22,13 +22,13 @@ func Servers() *client.ServerResponse { return &client.ServerResponse{ Response: []client.Server{ { - ID: "001", + ID: 001, HostName: "edge-alb-01", DomainName: "albuquerque.nm.albuq.kabletown.com", CDNName: "CDN-1", Type: "EDGE", Profile: "EDGE1_CDN_520", - TCPPort: "80", + TCPPort: 80, Rack: "F-4/35", PhysLocation: "Albuquerque", Cachegroup: "albuquerque", @@ -49,19 +49,19 @@ func Servers() *client.ServerResponse { IloIPGateway: "10.10.10.10", IloIPNetmask: "255.255.255.192", InterfaceName: "bond0", - InterfaceMtu: "9000", + InterfaceMtu: 9000, RouterPortName: "TenGigE0/3/0/10\t|\tBundle-Ether1000\t|\tPHY|10G|AGG-MEMBER|dtype:IPCDN-EDGE|rhost:edge-alb-01|rport:eth1|lagg:1000", RouterHostName: "ar01.albuquerque.nm.albuq.kabletown.com", LastUpdated: "2015-03-27 17:00:30", }, { - ID: "002", + ID: 002, HostName: "edge-alb-02", DomainName: "albuquerque.nm.albuq.kabletown.com", CDNName: "CDN-1", Type: "EDGE", Profile: "EDGE1_XCR_520", - TCPPort: "80", + TCPPort: 80, Rack: "F-4/38", PhysLocation: "Albuquerque", Cachegroup: "us-nm-albuquerque", @@ -82,19 +82,19 @@ func Servers() *client.ServerResponse { IloIPGateway: "10.10.10.10", IloIPNetmask: "255.255.255.192", InterfaceName: "bond0", - InterfaceMtu: "9000", + InterfaceMtu: 9000, RouterPortName: "TenGigE0/3/0/10\t|\tBundle-Ether1000\t|\tPHY|10G|AGG-MEMBER|dtype:IPCDN-EDGE|rhost:edge-alb-02|rport:eth1|lagg:1000", RouterHostName: "ar02.albuquerque.nm.albuq.kabletown.com", LastUpdated: "2015-03-27 17:00:34", }, { - ID: "003", + ID: 003, HostName: "atlanta-mid-01", DomainName: "ga.atlanta.kabletown.net", CDNName: "CDN-1", Type: "MID", Profile: "MID1", - TCPPort: "80", + TCPPort: 80, Rack: "F-4/38", PhysLocation: "Denver", Cachegroup: "mid-northeast-group", @@ -115,7 +115,7 @@ func Servers() *client.ServerResponse { IloIPGateway: "1", IloIPNetmask: "", InterfaceName: "bond0", - InterfaceMtu: "9000", + InterfaceMtu: 9000, RouterPortName: "", RouterHostName: "", LastUpdated: "2015-03-27 17:00:34", @@ -129,7 +129,7 @@ func LogstashServers() *client.ServerResponse { return &client.ServerResponse{ Response: []client.Server{ { - ID: "004", + ID: 004, HostName: "logstash-01", DomainName: "albuquerque.nm.albuq.kabletown.com", CDNName: "CDN-2", @@ -138,7 +138,7 @@ func LogstashServers() *client.ServerResponse { IPAddress: "10.10.10.10", }, { - ID: "005", + ID: 005, HostName: "logstash-02", DomainName: "albuquerque.nm.albuq.kabletown.com", CDNName: "CDN-2", diff --git a/traffic_ops/client/server.go b/traffic_ops/client/server.go index 93ea9e5c61..8295bab6c4 100644 --- a/traffic_ops/client/server.go +++ b/traffic_ops/client/server.go @@ -32,13 +32,13 @@ type ServerResponse struct { type Server struct { DomainName string `json:"domainName"` HostName string `json:"hostName"` - ID string `json:"id"` + ID int `json:"id"` IloIPAddress string `json:"iloIpAddress"` IloIPGateway string `json:"iloIpGateway"` IloIPNetmask string `json:"iloIpNetmask"` IloPassword string `json:"iloPassword"` IloUsername string `json:"iloUsername"` - InterfaceMtu string `json:"interfaceMtu"` + InterfaceMtu int `json:"interfaceMtu"` InterfaceName string `json:"interfaceName"` IP6Address string `json:"ip6Address"` IP6Gateway string `json:"ip6Gateway"` @@ -59,7 +59,7 @@ type Server struct { RouterHostName string `json:"routerHostName"` RouterPortName string `json:"routerPortName"` Status string `json:"status"` - TCPPort string `json:"tcpPort"` + TCPPort int `json:"tcpPort"` Type string `json:"type"` XMPPID string `json:"xmppId"` XMPPPasswd string `json:"xmppPasswd"` From c444a40328c009f6eda520b71963d6dbe3150306 Mon Sep 17 00:00:00 2001 From: David Neuman Date: Mon, 21 Nov 2016 15:36:49 -0700 Subject: [PATCH 2/9] update Deliverservice and associated tests/fixtures for psql --- .../client/delivery_service_resources.go | 32 +++++++++---------- .../client/fixtures/delivery_service.go | 30 ++++++++--------- .../client/tests/delivery_service_test.go | 8 ++--- 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/traffic_ops/client/delivery_service_resources.go b/traffic_ops/client/delivery_service_resources.go index a65734c28e..f8a677cc80 100644 --- a/traffic_ops/client/delivery_service_resources.go +++ b/traffic_ops/client/delivery_service_resources.go @@ -35,39 +35,39 @@ type DeleteDeliveryServiceResponse struct { // DeliveryService ... type DeliveryService struct { - ID string `json:"id"` + ID int `json:"id"` XMLID string `json:"xmlId"` Active bool `json:"active"` - DSCP string `json:"dscp"` + DSCP int `json:"dscp"` Signed bool `json:"signed"` - QStringIgnore string `json:"qstringIgnore"` - GeoLimit string `json:"geoLimit"` - GeoProvider string `json:"geoProvider"` + QStringIgnore int `json:"qstringIgnore"` + GeoLimit int `json:"geoLimit"` + GeoProvider int `json:"geoProvider"` HTTPBypassFQDN string `json:"httpBypassFqdn"` DNSBypassIP string `json:"dnsBypassIp"` DNSBypassIP6 string `json:"dnsBypassIp6"` DNSBypassCname string `json:"dnsBypassCname"` - DNSBypassTTL string `json:"dnsBypassTtl"` + DNSBypassTTL int `json:"dnsBypassTtl"` OrgServerFQDN string `json:"orgServerFqdn"` Type string `json:"type"` ProfileName string `json:"profileName"` ProfileDesc string `json:"profileDescription"` CDNName string `json:"cdnName"` - CCRDNSTTL string `json:"ccrDnsTtl"` - GlobalMaxMBPS string `json:"globalMaxMbps"` - GlobalMaxTPS string `json:"globalMaxTps"` + CCRDNSTTL int `json:"ccrDnsTtl"` + GlobalMaxMBPS int `json:"globalMaxMbps"` + GlobalMaxTPS int `json:"globalMaxTps"` LongDesc string `json:"longDesc"` LongDesc1 string `json:"longDesc1"` LongDesc2 string `json:"longDesc2"` - MaxDNSAnswers string `json:"maxDnsAnswers"` + MaxDNSAnswers int `json:"maxDnsAnswers"` InfoURL string `json:"infoUrl"` - MissLat string `json:"missLat"` - MissLong string `json:"missLong"` + MissLat float64 `json:"missLat"` + MissLong float64 `json:"missLong"` CheckPath string `json:"checkPath"` LastUpdated string `json:"lastUpdated"` - Protocol string `json:"protocol"` + Protocol int `json:"protocol"` IPV6RoutingEnabled bool `json:"ipv6RoutingEnabled"` - RangeRequestHandling string `json:"rangeRequestHandling"` + RangeRequestHandling int `json:"rangeRequestHandling"` HeaderRewrite string `json:"headerRewrite"` EdgeHeaderRewrite string `json:"edgeHeaderRewrite"` MidHeaderRewrite string `json:"midHeaderRewrite"` @@ -75,9 +75,9 @@ type DeliveryService struct { RegexRemap string `json:"regexRemap"` CacheURL string `json:"cacheurl"` RemapText string `json:"remapText"` - MultiSiteOrigin string `json:"multiSiteOrigin"` + MultiSiteOrigin int `json:"multiSiteOrigin"` DisplayName string `json:"displayName"` - InitialDispersion string `json:"initialDispersion"` + InitialDispersion int `json:"initialDispersion"` MatchList []DeliveryServiceMatch `json:"matchList,omitempty"` } diff --git a/traffic_ops/client/fixtures/delivery_service.go b/traffic_ops/client/fixtures/delivery_service.go index 6c7bf74fc1..a0263ebbbe 100644 --- a/traffic_ops/client/fixtures/delivery_service.go +++ b/traffic_ops/client/fixtures/delivery_service.go @@ -22,30 +22,30 @@ func DeliveryServices() *client.GetDeliveryServiceResponse { return &client.GetDeliveryServiceResponse{ Response: []client.DeliveryService{ client.DeliveryService{ - ID: "001", + ID: 001, XMLID: "ds-test", Active: true, - DSCP: "40", + DSCP: 40, Signed: false, - QStringIgnore: "1", - GeoLimit: "0", - GeoProvider: "0", - DNSBypassTTL: "30", + QStringIgnore: 1, + GeoLimit: 0, + GeoProvider: 0, + DNSBypassTTL: 30, Type: "HTTP", ProfileName: "ds-123", CDNName: "test-cdn", - CCRDNSTTL: "3600", - GlobalMaxTPS: "0", - MaxDNSAnswers: "0", - MissLat: "44.654321", - MissLong: "-99.123456", - Protocol: "0", + CCRDNSTTL: 3600, + GlobalMaxTPS: 0, + MaxDNSAnswers: 0, + MissLat: 44.654321, + MissLong: -99.123456, + Protocol: 0, IPV6RoutingEnabled: true, - RangeRequestHandling: "0", + RangeRequestHandling: 0, TRResponseHeaders: "Access-Control-Allow-Origin: *", - MultiSiteOrigin: "0", + MultiSiteOrigin: 0, DisplayName: "Testing", - InitialDispersion: "1", + InitialDispersion: 1, }, }, } diff --git a/traffic_ops/client/tests/delivery_service_test.go b/traffic_ops/client/tests/delivery_service_test.go index d8691b51db..bf182e4c41 100644 --- a/traffic_ops/client/tests/delivery_service_test.go +++ b/traffic_ops/client/tests/delivery_service_test.go @@ -57,7 +57,7 @@ func TestDeliveryServices(t *testing.T) { testHelper.Success(t, "Should get back \"ds-test\" for \"XMLID\"") } - if s.MissLong != "-99.123456" { + if s.MissLong != -99.123456 { testHelper.Error(t, "Should get back \"-99.123456\" for \"MissLong\", got: %s", s.MissLong) } else { testHelper.Success(t, "Should get back \"-99.123456\" for \"MissLong\"") @@ -111,7 +111,7 @@ func TestDeliveryService(t *testing.T) { testHelper.Success(t, "Should get back \"ds-test\" for \"XMLID\"") } - if ds.MissLong != "-99.123456" { + if ds.MissLong != -99.123456 { testHelper.Error(t, "Should get back \"-99.123456\" for \"MissLong\", got: %s", ds.MissLong) } else { testHelper.Success(t, "Should get back \"-99.123456\" for \"MissLong\"") @@ -159,7 +159,7 @@ func TestCreateDeliveryService(t *testing.T) { } actual := ds.Response.ID - if actual != "001" { + if actual != 001 { testHelper.Error(t, "Should get back \"001\" for \"Response.ID\", got: %s", actual) } else { testHelper.Success(t, "Should get back \"0001\" for \"Response.ID\"") @@ -207,7 +207,7 @@ func TestUpdateDeliveryService(t *testing.T) { } actual := ds.Response.ID - if actual != "001" { + if actual != 001 { testHelper.Error(t, "Should get back \"001\" for \"Response.ID\", got: %s", actual) } else { testHelper.Success(t, "Should get back \"0001\" for \"Response.ID\"") From 028ac9621f33602bc9e8fca624599e03ffb262f1 Mon Sep 17 00:00:00 2001 From: David Neuman Date: Tue, 22 Nov 2016 10:08:12 -0700 Subject: [PATCH 3/9] update HwInfo.pm to always return an int for limit --- traffic_ops/app/lib/API/HwInfo.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/traffic_ops/app/lib/API/HwInfo.pm b/traffic_ops/app/lib/API/HwInfo.pm index 43495fcdd6..972f76a509 100644 --- a/traffic_ops/app/lib/API/HwInfo.pm +++ b/traffic_ops/app/lib/API/HwInfo.pm @@ -39,7 +39,7 @@ sub index { } ); } - + $limit += 0; #converts to int. $self->success( \@data, undef, undef, $limit, undef ); } From 09d6bdfe8c07591bc1dbcdf8a7ef3f8e7bbeb994 Mon Sep 17 00:00:00 2001 From: David Neuman Date: Tue, 22 Nov 2016 11:05:17 -0700 Subject: [PATCH 4/9] update hardware client for psql --- traffic_ops/client/fixtures/hardware.go | 2 +- traffic_ops/client/hardware.go | 10 +++++++--- traffic_ops/client/tests/hardware_test.go | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/traffic_ops/client/fixtures/hardware.go b/traffic_ops/client/fixtures/hardware.go index a7069a27a7..74c4a36b4e 100644 --- a/traffic_ops/client/fixtures/hardware.go +++ b/traffic_ops/client/fixtures/hardware.go @@ -22,7 +22,7 @@ func Hardware() *client.HardwareResponse { return &client.HardwareResponse{ Response: []client.Hardware{ client.Hardware{ - ID: "18", + ID: 18, HostName: "odol-atsmid-cen-09", LastUpdated: "2015-07-16 09:04:20", Value: "1.00", diff --git a/traffic_ops/client/hardware.go b/traffic_ops/client/hardware.go index 939ce127a6..1fef49875c 100644 --- a/traffic_ops/client/hardware.go +++ b/traffic_ops/client/hardware.go @@ -16,16 +16,17 @@ package client import "encoding/json" +import "fmt" // HardwareResponse ... type HardwareResponse struct { - Version string `json:"version"` + Limit int `json:"limit"` Response []Hardware `json:"response"` } // Hardware ... type Hardware struct { - ID string `json:"serverId"` + ID int `json:"serverId"` HostName string `json:"serverHostName"` LastUpdated string `json:"lastUpdated"` Value string `json:"val"` @@ -33,8 +34,11 @@ type Hardware struct { } // Hardware gets an array of Hardware -func (to *Session) Hardware() ([]Hardware, error) { +func (to *Session) Hardware(limit int) ([]Hardware, error) { url := "/api/1.2/hwinfo.json" + if limit > 0 { + url += fmt.Sprintf("?limit=%v", limit) + } resp, err := to.request("GET", url, nil) if err != nil { return nil, err diff --git a/traffic_ops/client/tests/hardware_test.go b/traffic_ops/client/tests/hardware_test.go index 140601a9fc..58a042c6a4 100644 --- a/traffic_ops/client/tests/hardware_test.go +++ b/traffic_ops/client/tests/hardware_test.go @@ -37,7 +37,7 @@ func TestHardware(t *testing.T) { testHelper.Context(t, "Given the need to test a successful Traffic Ops request for Hardware") - hardware, err := to.Hardware() + hardware, err := to.Hardware(0) if err != nil { testHelper.Error(t, "Should be able to make a request to Traffic Ops") } else { @@ -83,7 +83,7 @@ func TestHardwareUnauthorized(t *testing.T) { testHelper.Context(t, "Given the need to test a failed Traffic Ops request for Hardware") - _, err := to.Hardware() + _, err := to.Hardware(0) if err == nil { testHelper.Error(t, "Should not be able to make a request to Traffic Ops") } else { From f6f3f156f57a821f73668ee5be1ba7d3addf8985 Mon Sep 17 00:00:00 2001 From: David Neuman Date: Tue, 22 Nov 2016 11:50:43 -0700 Subject: [PATCH 5/9] added second entry to hardware --- traffic_ops/client/fixtures/hardware.go | 13 ++++++++++--- traffic_ops/client/tests/hardware_test.go | 23 ++++++++++++----------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/traffic_ops/client/fixtures/hardware.go b/traffic_ops/client/fixtures/hardware.go index 74c4a36b4e..eb5f4547bf 100644 --- a/traffic_ops/client/fixtures/hardware.go +++ b/traffic_ops/client/fixtures/hardware.go @@ -23,10 +23,17 @@ func Hardware() *client.HardwareResponse { Response: []client.Hardware{ client.Hardware{ ID: 18, - HostName: "odol-atsmid-cen-09", + HostName: "edge-den-01", LastUpdated: "2015-07-16 09:04:20", - Value: "1.00", - Description: "BACKPLANE FIRMWARE", + Value: "DIS1", + Description: "Phys Disk", + }, + client.Hardware{ + ID: 19, + HostName: "edge-den-02", + LastUpdated: "2015-07-16 09:04:20", + Value: "DIS2", + Description: "Physical Disk", }, }, } diff --git a/traffic_ops/client/tests/hardware_test.go b/traffic_ops/client/tests/hardware_test.go index 58a042c6a4..619b05cccb 100644 --- a/traffic_ops/client/tests/hardware_test.go +++ b/traffic_ops/client/tests/hardware_test.go @@ -17,6 +17,7 @@ package test import ( "net/http" + "strings" "testing" "github.com/apache/incubator-trafficcontrol/traffic_ops/client" @@ -44,27 +45,27 @@ func TestHardware(t *testing.T) { testHelper.Success(t, "Should be able to make a request to Traffic Ops") } - if len(hardware) != 1 { - testHelper.Error(t, "Should get back \"1\" Hardware, got: %d", len(hardware)) + if len(hardware) != 2 { + testHelper.Error(t, "Should get back \"2\" Hardware, got: %d", len(hardware)) } else { - testHelper.Success(t, "Should get back \"1\" Hardware") + testHelper.Success(t, "Should get back \"2\" Hardware") } for _, h := range hardware { - if h.HostName != "odol-atsmid-cen-09" { - testHelper.Error(t, "Should get back \"odol-atsmid-cen-09\" for \"Hostname\", got: %s", h.HostName) + if !strings.Contains(h.HostName, "edge-den") { + testHelper.Error(t, "Should get back \"edge-den\" in \"Hostname\", got: %s", h.HostName) } else { - testHelper.Success(t, "Should get back \"odol-atsmid-cen-09\" for \"Hostname\"") + testHelper.Success(t, "Should get back \"edge-den\" in \"Hostname\"") } - if h.Value != "1.00" { - testHelper.Error(t, "Should get back \"1.00\" for \"Value\", got: %s", h.Value) + if !strings.Contains(h.Value, "DIS") { + testHelper.Error(t, "Should get back \"DIS1\" or \"DIS2\" for \"Value\", got: %s", h.Value) } else { - testHelper.Success(t, "Should get back \"1.00\" for \"Value\"") + testHelper.Success(t, "Should get back \"DIS1\" or \"DIS2\" for \"Value\"") } - if h.Description != "BACKPLANE FIRMWARE" { - testHelper.Error(t, "Should get back \"BACKPLANE FIRMWARE\" for \"Description\", got: %s", h.Description) + if !strings.Contains(h.Description, "Phys") { + testHelper.Error(t, "Should get back \"Phys Disk\" or \"Physical Disk\" for \"Description\", got: %s", h.Description) } else { testHelper.Success(t, "Should get back \"BACKPLANE FIRMWARE\" for \"Description\"") } From cbd5e092ed988b63799f5ffa37f38f2ef4699596 Mon Sep 17 00:00:00 2001 From: David Neuman Date: Tue, 22 Nov 2016 15:30:44 -0700 Subject: [PATCH 6/9] Remove version for response structs --- traffic_ops/client/cachegroup.go | 1 - traffic_ops/client/cdn.go | 3 +-- traffic_ops/client/delivery_service_resources.go | 1 - traffic_ops/client/parameter.go | 1 - traffic_ops/client/profile.go | 1 - traffic_ops/client/server.go | 1 - traffic_ops/client/stats_summary.go | 1 - traffic_ops/client/traffic_monitor_config.go | 1 - traffic_ops/client/traffic_ops.go | 3 +-- traffic_ops/client/traffic_router_config.go | 1 - traffic_ops/client/type.go | 1 - traffic_ops/client/user.go | 1 - 12 files changed, 2 insertions(+), 14 deletions(-) diff --git a/traffic_ops/client/cachegroup.go b/traffic_ops/client/cachegroup.go index 44aadd9925..1c65c56317 100644 --- a/traffic_ops/client/cachegroup.go +++ b/traffic_ops/client/cachegroup.go @@ -19,7 +19,6 @@ import "encoding/json" // CacheGroupResponse ... type CacheGroupResponse struct { - Version string `json:"version"` Response []CacheGroup `json:"response"` } diff --git a/traffic_ops/client/cdn.go b/traffic_ops/client/cdn.go index 665382e11d..3657fc5cc3 100644 --- a/traffic_ops/client/cdn.go +++ b/traffic_ops/client/cdn.go @@ -22,8 +22,7 @@ import ( // CDNResponse ... type CDNResponse struct { - Version string `json:"version"` - Response []CDN `json:"response"` + Response []CDN `json:"response"` } // CDN ... diff --git a/traffic_ops/client/delivery_service_resources.go b/traffic_ops/client/delivery_service_resources.go index f8a677cc80..aa7aaad01f 100644 --- a/traffic_ops/client/delivery_service_resources.go +++ b/traffic_ops/client/delivery_service_resources.go @@ -18,7 +18,6 @@ package client // GetDeliveryServiceResponse ... type GetDeliveryServiceResponse struct { - Version string `json:"version"` Response []DeliveryService `json:"response"` } diff --git a/traffic_ops/client/parameter.go b/traffic_ops/client/parameter.go index 937e450fea..34a805e9a1 100644 --- a/traffic_ops/client/parameter.go +++ b/traffic_ops/client/parameter.go @@ -22,7 +22,6 @@ import ( // ParamResponse ... type ParamResponse struct { - Version string `json:"version"` Response []Parameter `json:"response"` } diff --git a/traffic_ops/client/profile.go b/traffic_ops/client/profile.go index b417886722..a770780cc7 100644 --- a/traffic_ops/client/profile.go +++ b/traffic_ops/client/profile.go @@ -19,7 +19,6 @@ import "encoding/json" // ProfileResponse ... type ProfileResponse struct { - Version string `json:"version"` Response []Profile `json:"response"` } diff --git a/traffic_ops/client/server.go b/traffic_ops/client/server.go index 8295bab6c4..8dd0c1c43c 100644 --- a/traffic_ops/client/server.go +++ b/traffic_ops/client/server.go @@ -24,7 +24,6 @@ import ( // ServerResponse ... type ServerResponse struct { - Version string `json:"version"` Response []Server `json:"response"` } diff --git a/traffic_ops/client/stats_summary.go b/traffic_ops/client/stats_summary.go index 2045c2320e..7ea0ea1594 100644 --- a/traffic_ops/client/stats_summary.go +++ b/traffic_ops/client/stats_summary.go @@ -20,7 +20,6 @@ import ( // StatsSummaryResponse ... type StatsSummaryResponse struct { - Version string `json:"version"` Response []StatsSummary `json:"response"` } diff --git a/traffic_ops/client/traffic_monitor_config.go b/traffic_ops/client/traffic_monitor_config.go index 50ec7cd2ed..cf1208babf 100644 --- a/traffic_ops/client/traffic_monitor_config.go +++ b/traffic_ops/client/traffic_monitor_config.go @@ -24,7 +24,6 @@ import ( // TMConfigResponse ... type TMConfigResponse struct { - Version string `json:"version"` Response TrafficMonitorConfig `json:"response"` } diff --git a/traffic_ops/client/traffic_ops.go b/traffic_ops/client/traffic_ops.go index c5abfa9d45..9c2273d8cf 100644 --- a/traffic_ops/client/traffic_ops.go +++ b/traffic_ops/client/traffic_ops.go @@ -52,8 +52,7 @@ func (e *HTTPError) Error() string { // Result {"response":[{"level":"success","text":"Successfully logged in."}],"version":"1.1"} type Result struct { - Alerts []Alert - Version string `json:"version"` + Alerts []Alert } // Alert ... diff --git a/traffic_ops/client/traffic_router_config.go b/traffic_ops/client/traffic_router_config.go index aecd72d76f..96064b9085 100644 --- a/traffic_ops/client/traffic_router_config.go +++ b/traffic_ops/client/traffic_router_config.go @@ -22,7 +22,6 @@ import ( // TRConfigResponse ... type TRConfigResponse struct { - Version string `json:"version"` Response TrafficRouterConfig `json:"response"` } diff --git a/traffic_ops/client/type.go b/traffic_ops/client/type.go index 9bfe19fef8..088982ba04 100644 --- a/traffic_ops/client/type.go +++ b/traffic_ops/client/type.go @@ -22,7 +22,6 @@ import ( // TypeResponse ... type TypeResponse struct { - Version string `json:"version"` Response []Type `json:"response"` } diff --git a/traffic_ops/client/user.go b/traffic_ops/client/user.go index b2f1bb6c1a..3e2a1d70bb 100644 --- a/traffic_ops/client/user.go +++ b/traffic_ops/client/user.go @@ -19,7 +19,6 @@ import "encoding/json" // UserResponse ... type UserResponse struct { - Version string `json:"version"` Response []User `json:"response"` } From dae0f12be5fef4bee250ab125230e4f0995215d5 Mon Sep 17 00:00:00 2001 From: David Neuman Date: Tue, 22 Nov 2016 15:48:37 -0700 Subject: [PATCH 7/9] update user client for psql --- traffic_ops/client/fixtures/user.go | 2 +- traffic_ops/client/tests/user_test.go | 2 +- traffic_ops/client/user.go | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/traffic_ops/client/fixtures/user.go b/traffic_ops/client/fixtures/user.go index 39bf7753fa..b70a3e822f 100644 --- a/traffic_ops/client/fixtures/user.go +++ b/traffic_ops/client/fixtures/user.go @@ -24,7 +24,7 @@ func Users() *client.UserResponse { client.User{ Username: "bsmith", PublicSSHKey: "some-ssh-key", - Role: "3", + Role: 3, RoleName: "operations", Email: "bobsmith@email.com", FullName: "Bob Smith", diff --git a/traffic_ops/client/tests/user_test.go b/traffic_ops/client/tests/user_test.go index d68477016f..bcddcce0cb 100644 --- a/traffic_ops/client/tests/user_test.go +++ b/traffic_ops/client/tests/user_test.go @@ -57,7 +57,7 @@ func TestUsers(t *testing.T) { testHelper.Success(t, "Should get back \"some-ssh-key\" for \"PublicSSHKey\"") } - if u.Role != "3" { + if u.Role != 3 { testHelper.Error(t, "Should get back \"3\" for \"Role\", got %s", u.Role) } else { testHelper.Success(t, "Should get back \"3\" for \"Role\"") diff --git a/traffic_ops/client/user.go b/traffic_ops/client/user.go index 3e2a1d70bb..1b2cf2fc6d 100644 --- a/traffic_ops/client/user.go +++ b/traffic_ops/client/user.go @@ -26,10 +26,10 @@ type UserResponse struct { type User struct { Username string `json:"username,omitempty"` PublicSSHKey string `json:"publicSshKey,omitempty"` - Role string `json:"role,omitempty"` + Role int `json:"role,omitempty"` RoleName string `json:"rolename,omitempty"` - UID string `json:"uid,omitempty"` - GID string `json:"gid,omitempty"` + UID int `json:"uid,omitempty"` + GID int `json:"gid,omitempty"` Company string `json:"company,omitempty"` Email string `json:"email,omitempty"` FullName string `json:"fullName,omitempty"` From 0358622996b0cf482c29866560ef1cdf1e83612a Mon Sep 17 00:00:00 2001 From: David Neuman Date: Mon, 28 Nov 2016 10:07:52 -0700 Subject: [PATCH 8/9] change MultiSiteOrigin to bool --- traffic_ops/client/delivery_service_resources.go | 2 +- traffic_ops/client/fixtures/delivery_service.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/traffic_ops/client/delivery_service_resources.go b/traffic_ops/client/delivery_service_resources.go index aa7aaad01f..53e4c8e79e 100644 --- a/traffic_ops/client/delivery_service_resources.go +++ b/traffic_ops/client/delivery_service_resources.go @@ -74,7 +74,7 @@ type DeliveryService struct { RegexRemap string `json:"regexRemap"` CacheURL string `json:"cacheurl"` RemapText string `json:"remapText"` - MultiSiteOrigin int `json:"multiSiteOrigin"` + MultiSiteOrigin bool `json:"multiSiteOrigin"` DisplayName string `json:"displayName"` InitialDispersion int `json:"initialDispersion"` MatchList []DeliveryServiceMatch `json:"matchList,omitempty"` diff --git a/traffic_ops/client/fixtures/delivery_service.go b/traffic_ops/client/fixtures/delivery_service.go index a0263ebbbe..f9996dde30 100644 --- a/traffic_ops/client/fixtures/delivery_service.go +++ b/traffic_ops/client/fixtures/delivery_service.go @@ -43,7 +43,7 @@ func DeliveryServices() *client.GetDeliveryServiceResponse { IPV6RoutingEnabled: true, RangeRequestHandling: 0, TRResponseHeaders: "Access-Control-Allow-Origin: *", - MultiSiteOrigin: 0, + MultiSiteOrigin: false, DisplayName: "Testing", InitialDispersion: 1, }, From 2d2aac92ee8924b9e98352c56079f01953119ad5 Mon Sep 17 00:00:00 2001 From: David Neuman Date: Mon, 28 Nov 2016 14:14:15 -0700 Subject: [PATCH 9/9] update cachegroup to support real floats returned from API --- traffic_ops/client/cachegroup.go | 4 ++-- traffic_ops/client/fixtures/cachegroup.go | 4 ++-- traffic_ops/client/tests/cachegroup_test.go | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/traffic_ops/client/cachegroup.go b/traffic_ops/client/cachegroup.go index 1c65c56317..bb21b724e3 100644 --- a/traffic_ops/client/cachegroup.go +++ b/traffic_ops/client/cachegroup.go @@ -26,8 +26,8 @@ type CacheGroupResponse struct { type CacheGroup struct { Name string `json:"name"` ShortName string `json:"shortName"` - Latitude float64 `json:"latitude,string"` - Longitude float64 `json:"longitude,string"` + Latitude float64 `json:"latitude"` + Longitude float64 `json:"longitude"` ParentName string `json:"parentCachegroupName,omitempty"` Type string `json:"typeName,omitempty"` LastUpdated string `json:"lastUpdated,omitempty"` diff --git a/traffic_ops/client/fixtures/cachegroup.go b/traffic_ops/client/fixtures/cachegroup.go index e6bcfd6576..ea0fd696b5 100644 --- a/traffic_ops/client/fixtures/cachegroup.go +++ b/traffic_ops/client/fixtures/cachegroup.go @@ -25,8 +25,8 @@ func Cachegroups() *client.CacheGroupResponse { Name: "edge-philadelphia", ShortName: "phila", Type: "EDGE_LOC", - Longitude: 5, - Latitude: 55, + Longitude: -5.66, + Latitude: 55.67, ParentName: "mid-northeast", LastUpdated: "2014-03-28 15:23:50", }, diff --git a/traffic_ops/client/tests/cachegroup_test.go b/traffic_ops/client/tests/cachegroup_test.go index aa343a4e9a..13c0372b33 100644 --- a/traffic_ops/client/tests/cachegroup_test.go +++ b/traffic_ops/client/tests/cachegroup_test.go @@ -57,16 +57,16 @@ func TestCacheGroup(t *testing.T) { testHelper.Success(t, "Should get back \"edge-philadelphia\" for \"Name\"") } - if cacheGroup.Longitude != 5 { - testHelper.Error(t, "Should get back \"5\" for \"Longitude\", got: %v", cacheGroup.Longitude) + if cacheGroup.Longitude != -5.66 { + testHelper.Error(t, "Should get back \"-5.66\" for \"Longitude\", got: %v", cacheGroup.Longitude) } else { - testHelper.Success(t, "Should get back \"5\" for \"Longitude\"") + testHelper.Success(t, "Should get back \"-5.66\" for \"Longitude\"") } - if cacheGroup.Latitude != 55 { - testHelper.Error(t, "Should get back \"55\" for \"Latitude\", got: %v", cacheGroup.Latitude) + if cacheGroup.Latitude != 55.67 { + testHelper.Error(t, "Should get back \"55.67\" for \"Latitude\", got: %v", cacheGroup.Latitude) } else { - testHelper.Success(t, "Should get back \"55\" for \"Latitude\"") + testHelper.Success(t, "Should get back \"55.67\" for \"Latitude\"") } if cacheGroup.ParentName != "mid-northeast" {