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 managed agent stopped and running event integ test #2702

Merged
merged 1 commit into from
Nov 2, 2020

Conversation

fierlion
Copy link
Member

@fierlion fierlion commented Oct 30, 2020

Summary

Adds integration test for state change events RUNNING and STOPPED. Removes redundant container event emission of managed agent RUNNING->RUNNING.

Implementation details

Added a condition around emitContainerEvent.
Re-used a minimal section of TestExecCommandAgent to test managed agent container event emission for RUNNING and for STOPPED

Testing

ran 30x to test for flakiness locally:
sudo -E env "PATH=$PATH" go test -tags sudo -count=1 -v -run="TestManagedAgentEvent" ./agent/engine/...

New tests cover the changes: yes

Description for the changelog

Add ManagedAgentEvent integration test.

Licensing

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@fierlion fierlion force-pushed the integ_test_emit_message branch from 3292273 to cf77aca Compare October 30, 2020 19:02
assert.Equal(t, apicontainerstatus.ManagedAgentRunning, containerEvent.ManagedAgents[0].Status,
"expected managedAgent container state change event did not match actual event")
for event := range stateChangeEvents {
if containerEvent, ok := event.(api.ContainerStateChange); ok {
Copy link
Contributor

@angelcar angelcar Oct 30, 2020

Choose a reason for hiding this comment

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

there's a possibility here that we receive an api.ContainerStateChange but not the one we were looking for. Is there a way to make sure it's a container event for managed agent?

I am thinking actually that maybe api.ContainerStateChange was meant for actual changes in the container state (i.e. docker changes), maybe we should consider to create a api.ManagedAgentStateChange? Not for this PR maybe, but something to consider

Copy link
Member Author

@fierlion fierlion Oct 30, 2020

Choose a reason for hiding this comment

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

Even with the redundant event fix added to docker_task_engine.go I was seeing events with ManagedAgentStatusNone ("NONE") prior to the expected (RUNNING|STOPPED) events, and this function sifted past these NONE events.
I agree that we might want to differentiate the container events used to chat with docker from those we use to make our updates
(not in present pr though.)

client, err := sdkClient.NewClientWithOpts(sdkClient.WithHost(endpoint), sdkClient.WithVersion(sdkclientfactory.GetDefaultVersion().String()))
require.NoError(t, err, "Creating go docker client failed")

testExecCmdHostBinDir, err := filepath.Abs("../../misc/exec-command-agent-test")
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess if this PR gets merged first I could just change this test in #2701 before merging

}
// whether we restarted or failed to restart, we'll want to emit a state change event
// redundant state change events like RUNNING->RUNNING are allowed
mTask.emitContainerEvent(mTask.Task, c, "")
Copy link
Contributor

Choose a reason for hiding this comment

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

just curious, why was this modified?

Copy link
Member Author

Choose a reason for hiding this comment

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

So redundant events (RUNNING->RUNNING) aren't emitted. This change means we only emit a container event when there is a "restarted" (aka STOPPED->RUNNING) or an error (aka RUNNING->STOPPED)

@fierlion fierlion merged commit 6d952ad into aws:feature/ecs_exec Nov 2, 2020
@fierlion fierlion deleted the integ_test_emit_message branch November 2, 2020 18:25
fierlion added a commit to fierlion/amazon-ecs-agent that referenced this pull request Dec 3, 2020
fierlion added a commit to fierlion/amazon-ecs-agent that referenced this pull request Dec 3, 2020
angelcar pushed a commit to angelcar/amazon-ecs-agent that referenced this pull request Dec 29, 2020
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.

4 participants