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

Add integration test CI task and fix integration test #489

Merged
merged 37 commits into from Oct 2, 2018

Conversation

NicolasMahe
Copy link
Member

@NicolasMahe NicolasMahe commented Sep 21, 2018

This PR was meant to be only to add integration test on CircleCI but as integration test failed I had to fix them.

Closes #445

@NicolasMahe
Copy link
Member Author

NicolasMahe commented Sep 24, 2018

To do:

.circleci/config.yml Outdated Show resolved Hide resolved
- run: docker swarm init # this should be remove when no test are actually using docker
- run: docker build -t sleep docker-images/sleep/ # this should be remove when no test are actually using docker
- run: docker build -t http-server docker-images/http-server/ # this should be remove when no test are actually using docker
- run: env MESG_CORE_IMAGE=mesg/core:NONEXISTINGIMAGE go test -timeout 180s -p 1 -coverprofile=coverage.txt ./...
Copy link
Contributor

Choose a reason for hiding this comment

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

What about syntax:

run:
  name:
  command
  envrioment:

I think is more clear than putting everything in one line

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't have the env variable anymore and CircleCi doesn't provide to anyway to pass arguments through a nice yaml list.
I'm ok to read the command and not a short name.
What do you think @krhubert?

.circleci/config.yml Outdated Show resolved Hide resolved
This parameter tell what event from Docker to wait to confirm the deletion of the network. Can be "remove" or "destroy" depending in context.
container/network.go Outdated Show resolved Hide resolved
# Conflicts:
#	service/start_test.go
#	service/stop.go
#	service/stop_integration_test.go
@NicolasMahe NicolasMahe changed the title [WIP] Add integration test CI task Add integration test CI task Sep 25, 2018
@NicolasMahe
Copy link
Member Author

@mesg-foundation/core ready to review

container/service_integration_test.go Outdated Show resolved Hide resolved
.circleci/config.yml Show resolved Hide resolved
container/network.go Outdated Show resolved Hide resolved
krhubert
krhubert previously approved these changes Sep 26, 2018
antho1404
antho1404 previously approved these changes Sep 26, 2018
// event parameter can be "destroy" or "remove". If the network was used by a service, the event to use is "destroy". If the network has not been used, the event is "remove".
// Remove removes the reference from Docker to the network.
// Destroy removes the network from Docker active network.
func (c *Container) DeleteNetwork(namespace []string, event EventType) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

it's a bit odd to me having event as an argument to this func because it does not change the behavior of network removing. we can listen for both events and return after the first received event. this way use of this func will be agnostic and caller will not need to figure out which event type it should pass.

Copy link
Member

Choose a reason for hiding this comment

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

The problem with this one is that we cannot wait for both. In some cases we will have both (when we create the service and attach the network to this service) but in some other cases when we just create and destroy the network without any service we only have the "remove" event.

I agree this is kind of weird to have this event maybe we can rename it to deletionEvent or something like that.

I don't see any ways to make this function agnostic because it's really related to docker and how we use it but what thing that can be done in the future is to remove this CreateNetwork and DeleteNetwork from the public API and manage the network internally in the container package which totally makes sense.

Copy link
Member Author

Choose a reason for hiding this comment

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

Totally agree with the last part.

This is not a perfect solution but the perfect solution requires to reorganize the container package to match our logic (mesg's service have multiple docker's service, one network) rather than staying close to the docker logic (service, container, network). By doing this, we could extract a lot of docker related logic from the service package to the container package (like start and stop mesg's service with dependencies and network).

Copy link
Contributor

Choose a reason for hiding this comment

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

i don't quite get the limitation of waiting for both destory and remove here. does docker produces two events for both destory and remove when we have a service attached to network?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes it does. But as we run integration test that only create a network and them delete it, we need a way to change the behaviour of DeleteNetwork otherwise we have timeout and the integration test on CreateNetwork doesn't work (as well as others).

Copy link
Member Author

Choose a reason for hiding this comment

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

That's why, after transferring more logic to the container package (where we ALWAYS create a network attached to service), we will be able to remove the event parameter (and directly this public function).

Copy link
Contributor

Choose a reason for hiding this comment

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

I understand now. maybe we should inspect the network to see if there is any services attached to it before removing, this way we can guess the event type fore network removing without doing changes on container package. but there can be a race condition with this approach, while we're inspecting the network some services can be removed or started.

Copy link
Contributor

Choose a reason for hiding this comment

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

i think, the race condition can be prevented by also listening for service start/stop events in this func.

krhubert
krhubert previously approved these changes Sep 26, 2018
@NicolasMahe NicolasMahe dismissed stale reviews from krhubert and antho1404 via 14eb4d6 September 27, 2018 09:04
@ilgooz ilgooz merged commit 8deba12 into dev Oct 2, 2018
@ilgooz ilgooz deleted the feature/ci-integration-test branch October 2, 2018 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add CI task to run integration tests when dev branch is updated
4 participants