-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Verify Linux Ctl Integration Test
- Loading branch information
1 parent
0c6d2dd
commit 1fe9a1b
Showing
3 changed files
with
158 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
128 changes: 128 additions & 0 deletions
128
integration/test/sanity/resources/verifyLinuxCtlScript.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
#!/bin/sh | ||
|
||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# SPDX-License-Identifier: MIT | ||
|
||
assertStatus() { | ||
keyToCheck="${1:-}" | ||
expectedVal="${2:-}" | ||
|
||
grepKey='unknown' | ||
case "${keyToCheck}" in | ||
cwa_running_status) | ||
grepKey="\"status\"" | ||
;; | ||
cwa_config_status) | ||
grepKey="\"configstatus\"" | ||
;; | ||
cwoc_running_status) | ||
grepKey="\"cwoc_status\"" | ||
;; | ||
cwoc_config_status) | ||
grepKey="\"cwoc_configstatus\"" | ||
;; | ||
*) echo "Invalid Key To Check: ${keyToCheck}" >&2 | ||
exit 1 | ||
;; | ||
esac | ||
|
||
result=$(/usr/bin/amazon-cloudwatch-agent-ctl -a status | grep "${grepKey}" | awk -F: '{print $2}' | sed 's/ "//; s/",//') | ||
|
||
if [ "${result}" = "${expectedVal}" ]; then | ||
echo "In step ${step}, ${keyToCheck} is expected" | ||
else | ||
echo "In step ${step}, ${keyToCheck} is NOT expected. (actual="${result}"; expected="${expectedVal}")" | ||
exit 1 | ||
fi | ||
} | ||
|
||
# init | ||
step=0 | ||
/usr/bin/amazon-cloudwatch-agent-ctl -a remove-config -c all -o all | ||
/usr/bin/amazon-cloudwatch-agent-ctl -a stop | ||
|
||
step=1 | ||
/usr/bin/amazon-cloudwatch-agent-ctl -a status | ||
assertStatus "cwa_running_status" "stopped" | ||
assertStatus "cwoc_running_status" "stopped" | ||
assertStatus "cwa_config_status" "not configured" | ||
assertStatus "cwoc_config_status" "not configured" | ||
|
||
step=2 | ||
/usr/bin/amazon-cloudwatch-agent-ctl -a start | ||
assertStatus "cwa_running_status" "running" | ||
assertStatus "cwoc_running_status" "stopped" | ||
assertStatus "cwa_config_status" "configured" | ||
assertStatus "cwoc_config_status" "not configured" | ||
|
||
step=3 | ||
/usr/bin/amazon-cloudwatch-agent-ctl -a fetch-config -o default -s | ||
/usr/bin/amazon-cloudwatch-agent-ctl -a remove-config -c default -s | ||
assertStatus "cwa_running_status" "stopped" | ||
assertStatus "cwoc_running_status" "running" | ||
assertStatus "cwa_config_status" "not configured" | ||
assertStatus "cwoc_config_status" "configured" | ||
|
||
step=4 | ||
/usr/bin/amazon-cloudwatch-agent-ctl -a fetch-config -c default -o invalid -s | ||
assertStatus "cwa_running_status" "running" | ||
assertStatus "cwoc_running_status" "running" | ||
assertStatus "cwa_config_status" "configured" | ||
assertStatus "cwoc_config_status" "configured" | ||
|
||
step=5 | ||
/usr/bin/amazon-cloudwatch-agent-ctl -a prep-restart | ||
/usr/bin/amazon-cloudwatch-agent-ctl -a stop | ||
assertStatus "cwa_running_status" "stopped" | ||
assertStatus "cwoc_running_status" "stopped" | ||
assertStatus "cwa_config_status" "configured" | ||
assertStatus "cwoc_config_status" "configured" | ||
|
||
step=6 | ||
/usr/bin/amazon-cloudwatch-agent-ctl -a cond-restart | ||
assertStatus "cwa_running_status" "running" | ||
assertStatus "cwoc_running_status" "running" | ||
assertStatus "cwa_config_status" "configured" | ||
assertStatus "cwoc_config_status" "configured" | ||
|
||
step=7 | ||
/usr/bin/amazon-cloudwatch-agent-ctl -a remove-config -c default -s | ||
assertStatus "cwa_running_status" "stopped" | ||
assertStatus "cwoc_running_status" "running" | ||
assertStatus "cwa_config_status" "not configured" | ||
assertStatus "cwoc_config_status" "configured" | ||
|
||
step=8 | ||
/usr/bin/amazon-cloudwatch-agent-ctl -a remove-config -o default -s | ||
assertStatus "cwa_running_status" "stopped" | ||
assertStatus "cwoc_running_status" "stopped" | ||
assertStatus "cwa_config_status" "not configured" | ||
assertStatus "cwoc_config_status" "not configured" | ||
|
||
step=9 | ||
/usr/bin/amazon-cloudwatch-agent-ctl -a append-config -c default -o default -s | ||
assertStatus "cwa_running_status" "running" | ||
assertStatus "cwoc_running_status" "stopped" | ||
assertStatus "cwa_config_status" "configured" | ||
assertStatus "cwoc_config_status" "not configured" | ||
|
||
step=10 | ||
/usr/bin/amazon-cloudwatch-agent-ctl -a remove-config -c all | ||
assertStatus "cwa_running_status" "running" | ||
assertStatus "cwoc_running_status" "stopped" | ||
assertStatus "cwa_config_status" "not configured" | ||
assertStatus "cwoc_config_status" "not configured" | ||
|
||
step=11 | ||
/usr/bin/amazon-cloudwatch-agent-ctl -a fetch-config -o default -s | ||
assertStatus "cwa_running_status" "running" | ||
assertStatus "cwoc_running_status" "running" | ||
assertStatus "cwa_config_status" "not configured" | ||
assertStatus "cwoc_config_status" "configured" | ||
|
||
step=12 | ||
/usr/bin/amazon-cloudwatch-agent-ctl -a stop | ||
assertStatus "cwa_running_status" "stopped" | ||
assertStatus "cwoc_running_status" "stopped" | ||
assertStatus "cwa_config_status" "not configured" | ||
assertStatus "cwoc_config_status" "configured" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
// +build linux | ||
// +build integration | ||
|
||
package sanity | ||
|
||
import ( | ||
"github.com/aws/amazon-cloudwatch-agent/integration/test" | ||
"testing" | ||
) | ||
|
||
func TestAgentStatus(t *testing.T) { | ||
test.RunShellScript("resources/verifyLinuxCtlScript.sh") | ||
} |