-
Notifications
You must be signed in to change notification settings - Fork 339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial version of the TO API test tool via the Golang TO Client #1604
Conversation
Refer to this link for build results (access rights to CI server needed): |
There is no description provided, so I have to ask, does this replace the golang client integration tests? https://github.com/apache/incubator-trafficcontrol/tree/master/traffic_ops/client_tests/tests/integration |
@dneuman64 Yes, I wanted to separate the TO API client tests from the TO Client itself, so that the TO Client gets exercised as true external clients would. This helps catch any potential functions that need to be exported for TO Golang clients. I do plan on removing the old integration ones once this matures. |
"fmt" | ||
"net/http" | ||
|
||
tc "github.com/apache/incubator-trafficcontrol/lib/go-tc" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't hurting anything, but it doesn't strictly need the alias, Go will automatically import go-tc
as tc
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
Refer to this link for build results (access rights to CI server needed): |
e7f8840
to
fcb92b2
Compare
Refer to this link for build results (access rights to CI server needed): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like the vendor directory could use some cleanup, too.. For instance, I don't see the /crypto
library used at all...
traffic_ops/client/cdn.go
Outdated
return cdns, err | ||
var ( | ||
API_v2_CDNs = "/api/1.2/cdns" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that should probably be a const
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, I'll fix
traffic_ops/client/cdn.go
Outdated
if err := json.NewDecoder(resp.Body).Decode(&alerts); err != nil { | ||
return tc.Alerts{}, reqInf, err | ||
} | ||
return alerts, reqInf, nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't need to check for err != nil
, just return alerts, reqInf, err
.
traffic_ops/client/cdn.go
Outdated
if err := json.NewDecoder(resp.Body).Decode(&alerts); err != nil { | ||
return tc.Alerts{}, reqInf, err | ||
} | ||
return alerts, reqInf, nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
traffic_ops/testing/api/TODO.md
Outdated
@@ -0,0 +1 @@ | |||
- Read the fixture .json file for TestCDNs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still needs the Apache license text...
traffic_ops/testing/api/cdn_test.go
Outdated
import ( | ||
"testing" | ||
|
||
log "github.com/apache/incubator-trafficcontrol/lib/go-log" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment as @rob05c had elsewhere -- import name is already log
, so doesn't need to be specified here
|
||
"github.com/kelseyhightower/envconfig" | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this be reused from traffic_ops_golang
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you are referring to using "vendor" code from other components, I have not been able to figure that out yet. But that dependency is only in this tool atm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can, by putting traffic_ops_golang/config.go
in its own package. So, move to traffic_ops_golang/config/config.go
, and things like this can import (toconfig "traffic_ops_golang/config")
(I'd name the package toconfig
directly if anything besides testing frameworks need it, but that seems unlikely.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should address this later...
@@ -0,0 +1,10 @@ | |||
language: go |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this dir needs to be added to .rat-excludes
at the top level of tc or rat
will complain...
Refer to this link for build results (access rights to CI server needed): |
Refer to this link for build results (access rights to CI server needed): |
Refer to this link for build results (access rights to CI server needed): |
30cc89e
to
cb51e8a
Compare
Refer to this link for build results (access rights to CI server needed): |
Refer to this link for build results (access rights to CI server needed): |
Refer to this link for build results (access rights to CI server needed): |
Refer to this link for build results (access rights to CI server needed): |
9c43815
to
f94875e
Compare
Refer to this link for build results (access rights to CI server needed): |
Refer to this link for build results (access rights to CI server needed): |
Refer to this link for build results (access rights to CI server needed): |
Refer to this link for build results (access rights to CI server needed): |
Refer to this link for build results (access rights to CI server needed): |
Refer to this link for build results (access rights to CI server needed): |
Refer to this link for build results (access rights to CI server needed): |
Refer to this link for build results (access rights to CI server needed): |
The Traffic Ops API test tool implements a basic Traffic Ops API test suite that utilizes the Golang TO Client. This tool should help with the following issues:
functionality to be in parity with the Traffic Ops API
High Level Features:
authorization.go
module created intraffic_ops/traffic_ops_golang
, which can also be used for the next Golang implementations for the TO Golang rewrite effort endponts/login
and/users
/cdns
CRUD implemented (as well as enhancements to the TO Client to support the CRUD operations)./test_cdn.json
to simplify maintenance. To load this file, the existinglib/go-tc
Golang structs were used to allow for more reuse of thego-tc
structs and continual use to ensure their accuracy.TODOs:
and default accordingly