Skip to content

Update service ps to be an API test#33684

Merged
vdemeester merged 3 commits intomoby:masterfrom
dnephin:update-service-ps-tests
Aug 29, 2017
Merged

Update service ps to be an API test#33684
vdemeester merged 3 commits intomoby:masterfrom
dnephin:update-service-ps-tests

Conversation

@dnephin
Copy link
Member

@dnephin dnephin commented Jun 14, 2017

Removed cli tests (which were testing CLI behaviour) and replaced with an API test

Also update LoadBusybox() to use the API instead of the cli

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM

@aaronlehmann
Copy link

LGTM

@thaJeztah
Copy link
Member

Given that this test is testing CLI functionality, but does not catch the bug in #32800

Is there an actual need to merge this? #32800 (comment) suggests rewriting to an API test (which won't do any testing here, as it's only consecutive calls to the same endpoint)

Shall we close this PR and remove the test?

@dnephin
Copy link
Member Author

dnephin commented Jun 15, 2017

If we have other test coverage for this endpoint I would agree we can just remove this test entirely.

@dnephin
Copy link
Member Author

dnephin commented Jun 16, 2017

It looks like we don't have any other tests for this endpoint, so this will need to be converted to api tests.

@dnephin dnephin force-pushed the update-service-ps-tests branch from e18317e to d2c42db Compare June 16, 2017 22:42
@dnephin dnephin changed the title Update service ps test Update service ps to be an API test Jun 16, 2017
@dnephin
Copy link
Member Author

dnephin commented Jun 16, 2017

OK, this PR has been updated accordingly

@aaronlehmann
Copy link

Is there an equivalent test in cli to the one that is being removed?

@dnephin
Copy link
Member Author

dnephin commented Jun 16, 2017

The test should exist in e2e soon.

There is no equivalent in docker/cli right now. We're missing a lot of coverage in that repo. I opened docker/cli#201 as a tracking ticket for test cases we remove from this repo.

I don't think we should wait for those tests to exist before merging this and similar PRs. This test fails on the jenkins integration job because of changes to the CLI . Test coverage of the code in this repo remains the same after this change. We can't rely on tests in this repo to cover behaviour in another repo.

@aaronlehmann
Copy link

I don't think we should wait for those tests to exist before merging this and similar PRs.

I'm afraid I disagree.

This test fails on the jenkins integration job because of changes to the CLI.

So let's fix it instead of removing it.

We can't rely on tests in this repo to cover behaviour in another repo.

We need some way of making sure that the CLI works against the daemon. Currently it's impossible to add tests that verify this, and removing existing tests will make the situation even worse.

@dnephin
Copy link
Member Author

dnephin commented Jun 16, 2017

So let's fix it instead of removing it.

That's exactly what I did here! The fix is to make it an API test.
cc @andrewhsu since we've been talking about this.

We need some way of making sure that the CLI works against the daemon. Currently it's impossible to add tests that verify this, and removing existing tests will make the situation even worse.

Yes we do. It is the responsibility of docker/cli to make sure it works with the daemon.

The daemon should only be responsible for preventing regressions. Using a client binary is not the right way to do that, it hides regressions. We need to write API tests that check expected responses.

That said, the API test I wrote is terrible. I need to update it to expect an exact struct and raw bytes.

@aaronlehmann
Copy link

That's exactly what I did here! The fix is to make it an API test.

The old test checks the behavior of service ps with prefixes and multiple arguments. The replacement tests the ServiceInspect API method with a single full-length ID. I don't see how one is a substitute for the other.

@dnephin
Copy link
Member Author

dnephin commented Jun 16, 2017

The old test checks the behavior of service ps with prefixes and multiple arguments.

That behaviour is in docker/cli. We can not test it here. The only code in this repo that is being exercised by the removed tests is this one API call.

The test coverage of the system under test (the daemon) is exactly the same before and after this change (once I fix the assertion). The old tests checked behaviour outside of this repo, which is a bug in the tests, that is being fixed here.

@cpuguy83
Copy link
Member

I'm not comfortable removing the CLI test until there is a valid replacement in docker/cli.

@dnephin
Copy link
Member Author

dnephin commented Jun 19, 2017

I was wrong, there are actually unit tests covering this: https://github.com/docker/cli/blob/master/cli/command/service/ps_test.go

What value does this test provide? It's testing with an arbitrary frozen version of the CLI. We already know this test is failing with the latest version of the cli.

My first change was to update the test, but @thaJeztah correctly pointed out that it doesn't make sense to keep this test. It's not actually testing anything.

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM

ping @cpuguy83 good to go?

@dnephin
Copy link
Member Author

dnephin commented Jun 29, 2017

This isn't ready yet. I want to update the test to assert the entire struct matches the expect struct, instead of just comparing ID.

@mlaventure mlaventure changed the title Update service ps to be an API test [WIP] Update service ps to be an API test Jun 30, 2017
@dnephin dnephin force-pushed the update-service-ps-tests branch from d2c42db to 2fe4769 Compare July 5, 2017 17:01
@dnephin dnephin changed the title [WIP] Update service ps to be an API test Update service ps to be an API test Jul 5, 2017
@dnephin
Copy link
Member Author

dnephin commented Jul 5, 2017

I've updated the test to compare the entire service instead of just the ID. This is ready for review again.

@thaJeztah
Copy link
Member

Failures look related;

22:40:24 ----------------------------------------------------------------------
22:40:24 FAIL: docker_api_swarm_service_test.go:682: DockerSwarmSuite.TestAPISwarmServicesInspectFull
22:40:24 
22:40:24 [d511d16ba1c2f] waiting for daemon to start
22:40:24 [d511d16ba1c2f] daemon started
22:40:24 
22:40:24 docker_api_swarm_service_test.go:697:
22:40:24     waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, int(instances))
22:40:24 docker_utils_test.go:471:
22:40:24     c.Assert(v, checker, args...)
22:40:24 ... obtained int = 0
22:40:24 ... expected int = 2
22:40:24 
22:40:24 [d511d16ba1c2f] exiting daemon
22:40:49 

@dnephin
Copy link
Member Author

dnephin commented Jul 12, 2017

Hmm, yes it does, but I can't reproduce locally.

@dnephin
Copy link
Member Author

dnephin commented Jul 12, 2017

I don't see any errors in bundles/17.06.0-dev/test-integration-cli/d326d42de1f20/docker.log

@thaJeztah
Copy link
Member

ping @dperny @vdemeester could you have a look at this one; perhaps you have an idea

@dperny
Copy link
Contributor

dperny commented Aug 3, 2017

Something changed, I'm only seeing the PPC test failure which is unrelated.

@thaJeztah
Copy link
Member

oh! that's cool, I thought, well, let's try once more; looks like that resolved it, must've been fixed elsewhere then

Signed-off-by: Daniel Nephin <dnephin@docker.com>
Signed-off-by: Daniel Nephin <dnephin@docker.com>
@dnephin dnephin force-pushed the update-service-ps-tests branch from d959ed5 to 7edb25e Compare August 25, 2017 21:24
@dnephin dnephin requested a review from vdemeester as a code owner August 25, 2017 21:24
Signed-off-by: Daniel Nephin <dnephin@docker.com>
@dnephin
Copy link
Member Author

dnephin commented Aug 28, 2017

This has been updated again to move the API test to the new integration/ suite

Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

LGTM 🐯

os.Exit(1)
}

// TODO: replace this with `testEnv.Print()` to print the full env
Copy link
Member

Choose a reason for hiding this comment

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

❤️

@vdemeester vdemeester merged commit 15b8d04 into moby:master Aug 29, 2017
@dnephin dnephin deleted the update-service-ps-tests branch August 29, 2017 14:57
@thaJeztah thaJeztah mentioned this pull request Apr 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants