Skip to content
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

Create API v2 tests #4374

Merged
merged 17 commits into from
Feb 25, 2020
Merged

Create API v2 tests #4374

merged 17 commits into from
Feb 25, 2020

Conversation

shamrickus
Copy link
Member

@shamrickus shamrickus commented Feb 5, 2020

What does this PR (Pull Request) do?

  • This PR is not related to any Issue

Which Traffic Control components are affected by this PR?

  • Traffic Ops

What is the best way to verify this PR?

Run the go api tests for v2, validate v1 tests still pass

The following criteria are ALL met by this PR

  • This PR includes tests OR I have explained why tests are unnecessary
  • This PR includes documentation OR I have explained why documentation is unnecessary
  • This PR includes an update to CHANGELOG.md OR such an update is not necessary
  • This PR includes any and all required license headers
  • This PR ensures that database migration sequence is correct OR this PR does not include a database migration
  • This PR DOES NOT FIX A SERIOUS SECURITY VULNERABILITY (see the Apache Software Foundation's security guidelines for details)

Additional Information

Copy link
Contributor

@ocket8888 ocket8888 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a lot of places where a user-agent name is given as to-api-v1-client-tests (which should say v2 now), and that should probably be a constant somewhere. Not something you need to fix, but a note for the future.

traffic_ops/testing/api/v2/config/cachecfg/cachecfg.go Outdated Show resolved Hide resolved
traffic_ops/testing/api/v2/loginfail_test.go Outdated Show resolved Hide resolved
traffic_ops/testing/api/v2/loginfail_test.go Outdated Show resolved Hide resolved
traffic_ops/testing/api/v2/session_test.go Outdated Show resolved Hide resolved
traffic_ops/testing/api/v2/session_test.go Outdated Show resolved Hide resolved
traffic_ops/testing/api/v2/user_test.go Outdated Show resolved Hide resolved
traffic_ops/testing/api/v2/user_test.go Outdated Show resolved Hide resolved
traffic_ops/testing/api/v2/user_test.go Outdated Show resolved Hide resolved
traffic_ops/testing/api/v2/user_test.go Outdated Show resolved Hide resolved
traffic_ops/testing/api/v2/user_test.go Outdated Show resolved Hide resolved
@ocket8888 ocket8888 added new feature A new feature, capability or behavior tests related to tests and/or testing infrastructure TO Client (Go) related to the Go implementation of a TC client Traffic Ops related to Traffic Ops labels Feb 5, 2020
@ocket8888 ocket8888 self-assigned this Feb 5, 2020
@shamrickus
Copy link
Member Author

Fixed references to 1.x api and removed the UserDeliveryService tests. Note tests now fail since the 2.x api doesn't exist yet

@ocket8888
Copy link
Contributor

"... tests now fail ..."

That's fine, for the moment.

Copy link
Contributor

@ocket8888 ocket8888 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, but we should hold off merging until 2.x actually exists, just so that it can add new tests from new endpoints as they are added to 1.5 (looking at you, LetsEncrypt)

Copy link
Contributor

@mhoppa mhoppa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The README for the api tests should be updated accordingly to include the branching of v1 vs v2 API Tests.

Also does the integration API test container need to be updated to run 2.x tests on top of the 1.x tests?

@shamrickus
Copy link
Member Author

How do you run the integration API test container? I can look into changing it if need be.

@ocket8888
Copy link
Contributor

I think ideally it would just run the 2.x tests, because the 1.x tests pass and nobody should be modifying the 1.x endpoint handlers

@mhoppa
Copy link
Contributor

mhoppa commented Feb 18, 2020

I think it should have the option to run v1 tests as a regression check and in my opinion by default run both. There is going to be (already is) a lot shared code between v1 and v2 and we need to make sure we are not causing any regressions since we as a community are supporting v1.

@rob05c
Copy link
Member

rob05c commented Feb 18, 2020

I think it should have the option to run v1 tests as a regression check and in my opinion by default run both. There is going to be (already is) a lot shared code between v1 and v2 and we need to make sure we are not causing any regressions since we as a community are supporting v1.

+1 Though, abstracting the tests to support multiple versions sounds like a lot of overhead, especially for the 1.x endpoints that shouldn't be changing much.

What if we delete the 1.x tests from the repo, and the operating procedure is for build systems to check out the 4.0.x branch (the latest release before 2.x was added), and run those tests against master TO? And if there are new 1.x tests (which should be rare), we add them to the 4.0.x branch. Seems like that would be easier to manage and maintain.

@rawlinp
Copy link
Contributor

rawlinp commented Feb 18, 2020

I still like the idea of copying the v1 tests (and Go client) to v2 and removing deprecated API usage from the v2 tests (and Go client). Then we can continue to run both v1 and v2 tests, and can cleanly delete all of the v1 tests (and Go client) when the time comes (which should be very soon). The overhead of maintaining two copies of mostly the same tests should be minimal since we'd be deleting everything v1 soon anyways.

@ocket8888 ocket8888 mentioned this pull request Feb 19, 2020
7 tasks
Copy link
Contributor

@ocket8888 ocket8888 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there were some issues rebasing

# github.com/apache/trafficcontrol/traffic_ops/client
traffic_ops/client/deliveryservice.go:134:25: undefined: deliveryServicesByServerEp
traffic_ops/client/deliveryservice.go:367:25: undefined: deliveryServiceStateEp
traffic_ops/client/deliveryservice.go:397:25: undefined: deliveryServiceRoutingEp

Copy link
Contributor

@ocket8888 ocket8888 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think your merge messed some things up

traffic_ops/client/deliveryservice.go Outdated Show resolved Hide resolved
traffic_ops/client/deliveryservice.go Outdated Show resolved Hide resolved
traffic_ops/client/deliveryservice.go Outdated Show resolved Hide resolved
traffic_ops/client/deliveryservice.go Outdated Show resolved Hide resolved
traffic_ops/client/server.go Outdated Show resolved Hide resolved
traffic_ops/client/server.go Outdated Show resolved Hide resolved
traffic_ops/client/server.go Outdated Show resolved Hide resolved
traffic_router/core/src/test/conf/http.properties Outdated Show resolved Hide resolved
traffic_router/core/src/test/conf/dns.properties Outdated Show resolved Hide resolved
@shamrickus
Copy link
Member Author

Tests still failing

@zrhoffman
Copy link
Member

On shamrickus:master, I get 153 API tests run with no failures. Waiting for CDN-in-a-Box to finish loading and running:

docker-compose -f docker-compose.yml -f docker-compose.traffic-ops-test.yml up --force-recreate integration

@ocket8888
Copy link
Contributor

Really? cuz I'm getting tons of failures:

servercapabilities_test.go:36: could not CREATE server capability: 400 Bad Request[400] - Error requesting Traffic Ops https://localhost:6443/api/2.0/server_capabilities {"alerts":[{"text":"server_capability name 'foo' already exists.","level":"error"}]}
servercapabilities_test.go:38: Response:  <nil>
servercapabilities_test.go:36: could not CREATE server capability: 400 Bad Request[400] - Error requesting Traffic Ops https://localhost:6443/api/2.0/server_capabilities {"alerts":[{"text":"server_capability name 'bar' already exists.","level":"error"}]}
servercapabilities_test.go:38: Response:  <nil>
--- FAIL: TestDeliveryServiceServersWithRequiredCapabilities/assign_a_deliveryservice_to_a_required_capability;_deliveryServiceID:_0,_requiredCapability:_foo (0.01s)
	deliveryservices_required_capabilities_test.go:156: 400 Bad Request[400] - Error requesting Traffic Ops https://localhost:6443/api/2.0/deliveryservices_required_capabilities {"alerts":[{"text":"Invalid DS type. Only DNS and HTTP delivery services can have required capabilities","level":"error"}]}
--- FAIL: TestDeliveryServiceServersWithRequiredCapabilities/assign_a_deliveryservice_to_a_required_capability;_deliveryServiceID:_0,_requiredCapability:_bar (0.01s)
	deliveryservices_required_capabilities_test.go:156: 400 Bad Request[400] - Error requesting Traffic Ops https://localhost:6443/api/2.0/deliveryservices_required_capabilities {"alerts":[{"text":"Invalid DS type. Only DNS and HTTP delivery services can have required capabilities","level":"error"}]}
--- FAIL: TestDeliveryServiceServersWithRequiredCapabilities/assign_a_deliveryservice_to_a_required_capability;_deliveryServiceID:_0,_requiredCapability:_bar#01 (0.01s)
	deliveryservices_required_capabilities_test.go:156: 400 Bad Request[400] - Error requesting Traffic Ops https://localhost:6443/api/2.0/deliveryservices_required_capabilities {"alerts":[{"text":"Invalid DS type. Only DNS and HTTP delivery services can have required capabilities","level":"error"}]}
serverservercapability_test.go:49: Response:  atlanta-org-1   {[{server server_capability was created. success}]}
serverservercapability_test.go:49: Response:  atlanta-org-2   {[{server server_capability was created. success}]}
--- FAIL: TestDeliveryServiceServersWithRequiredCapabilities/missing_requirements_for_server_->_DS_assignment (0.01s)
	deliveryserviceservers_test.go:83: *POST delivery service required capability: 400 Bad Request[400] - Error requesting Traffic Ops https://localhost:6443/api/2.0/deliveryservices_required_capabilities {"alerts":[{"text":"Invalid DS type. Only DNS and HTTP delivery services can have required capabilities","level":"error"}]}
--- FAIL: TestDeliveryServiceServersWithRequiredCapabilities/successful_server_->_DS_assignment (0.01s)
	deliveryserviceservers_test.go:83: *POST delivery service required capability: 400 Bad Request[400] - Error requesting Traffic Ops https://localhost:6443/api/2.0/deliveryservices_required_capabilities {"alerts":[{"text":"Invalid DS type. Only DNS and HTTP delivery services can have required capabilities","level":"error"}]}
deliveryserviceservers_test.go:112: no delivery service required capabilites found for ds msods1
serverservercapability_test.go:184: at least one delivery service needs the capability foo required
deliveryservices_required_capabilities_test.go:260: no delivery services returned
servercapabilities_test.go:75: cannot DELETE server capability: 400 Bad Request[400] - Error requesting Traffic Ops https://localhost:6443/api/2.0/server_capabilities?name=foo {"alerts":[{"text":"cannot delete server_capability because it is being used by a server_server_capability","level":"error"}]}
	 - {[]}
servercapabilities_test.go:80: expected error trying to GET deleted server capability: foo, actual: nil
servercapabilities_test.go:83: expected nil trying to GET deleted server capability: foo, actual: non-nil
servercapabilities_test.go:75: cannot DELETE server capability: 400 Bad Request[400] - Error requesting Traffic Ops https://localhost:6443/api/2.0/server_capabilities?name=bar {"alerts":[{"text":"cannot delete server_capability because it is being used by a server_server_capability","level":"error"}]}
	 - {[]}
servercapabilities_test.go:80: expected error trying to GET deleted server capability: bar, actual: nil
servercapabilities_test.go:83: expected nil trying to GET deleted server capability: bar, actual: non-nil
--- FAIL: TestDeliveryServicesRequiredCapabilities/assign_a_deliveryservice_to_a_required_capability;_deliveryServiceID:_0,_requiredCapability:_foo (0.01s)
	deliveryservices_required_capabilities_test.go:156: 400 Bad Request[400] - Error requesting Traffic Ops https://localhost:6443/api/2.0/deliveryservices_required_capabilities {"alerts":[{"text":"Invalid DS type. Only DNS and HTTP delivery services can have required capabilities","level":"error"}]}
--- FAIL: TestDeliveryServicesRequiredCapabilities/assign_a_deliveryservice_to_a_required_capability;_deliveryServiceID:_0,_requiredCapability:_bar (0.01s)
	deliveryservices_required_capabilities_test.go:156: 400 Bad Request[400] - Error requesting Traffic Ops https://localhost:6443/api/2.0/deliveryservices_required_capabilities {"alerts":[{"text":"Invalid DS type. Only DNS and HTTP delivery services can have required capabilities","level":"error"}]}
--- FAIL: TestDeliveryServicesRequiredCapabilities/assign_a_deliveryservice_to_a_required_capability;_deliveryServiceID:_0,_requiredCapability:_bar#01 (0.01s)
	deliveryservices_required_capabilities_test.go:156: 400 Bad Request[400] - Error requesting Traffic Ops https://localhost:6443/api/2.0/deliveryservices_required_capabilities {"alerts":[{"text":"Invalid DS type. Only DNS and HTTP delivery services can have required capabilities","level":"error"}]}
deliveryservices_required_capabilities_test.go:180: delivery service ds1 needs at least one capability required
deliveryservices_required_capabilities_test.go:260: no delivery services returned

Are you sure your docker-compose.traffic-ops-test.yml is running API v2 tests?

@ocket8888
Copy link
Contributor

some of these are probably related to the way capabilities are now created. Instead of using "create" and "delete" tests like other objects, they probably ought to be done in to_db_test.go since the API can no longer actually create or delete them.

Copy link
Contributor

@ocket8888 ocket8888 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I swear the methods for these configfiles endpoints were/should have been removed from the Go client entirely...

traffic_ops/testing/api/v2/atsconfig_meta_test.go Outdated Show resolved Hide resolved
traffic_ops/testing/api/v2/atsconfig_test.go Outdated Show resolved Hide resolved
@ocket8888
Copy link
Contributor

Still getting a failure in the DS tests:

deliveryservices_test.go:396: expected tenant4user to be unable to update tenant3's deliveryservice (ds3)
deliveryservices_test.go:401: expected tenant4user to be unable to delete tenant3's deliveryservice (ds3)

not sure what that means...

Copy link
Contributor

@ocket8888 ocket8888 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests all pass, removes the bad functionality and typos I introduced (which I suppose is what tests are for)

@ocket8888 ocket8888 merged commit dff98af into apache:master Feb 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature A new feature, capability or behavior tests related to tests and/or testing infrastructure TO Client (Go) related to the Go implementation of a TC client Traffic Ops related to Traffic Ops
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants