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 spire-agent CLI commands integration test #4969

Merged
merged 9 commits into from
May 21, 2024

Conversation

FedeNQ
Copy link
Contributor

@FedeNQ FedeNQ commented Mar 12, 2024

Pull Request check list

  • Commit conforms to CONTRIBUTING.md?
  • Proper tests/regressions included?
  • Documentation updated?

Affected functionality
Integration tests have been implemented for the following spire agent commands:

  • validate
  • healthcheck
  • api watch

Which issue this PR fixes
Fixes #1890

INVALID_CONFIG=0


for ((m=1;m<=$RETRIES;m++)); do
Copy link
Collaborator

Choose a reason for hiding this comment

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

since step 4 will validate that agent is up, I think the same validation in all test cases is not required

HEALTHCHECK_FAIL=1
fi

if [ $AGENT_FOUND -eq 1 ] && [ $HEALTHCHECK -eq 1 ] && [ $HEALTHCHECK_FAIL -eq 1 ]; then
Copy link
Collaborator

Choose a reason for hiding this comment

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

how can we know witch one fails? may we verify one at time? (same comment for all test cases)

fi
done

echo "$AGENTS"
Copy link
Collaborator

Choose a reason for hiding this comment

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

are echos required here?

wait $API_WATCH_PID


# Continuously check the output file for the desired pattern with a timeout of 20 seconds
Copy link
Collaborator

Choose a reason for hiding this comment

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

since the function behind api watch is to watch updates on SVID/bundles, what do you think about setting very log SVID rotations (1m or something like that) and verify that SVID rotates?

INVALID_CONFIG=1
fi

if [ $VALID_CONFIG -eq 1 ] && [ $INVALID_CONFIG -eq 1 ]; then
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you add log to understand quickly witch one fails?

test/integration/suites/agent-cli/06-check-api-watch-fail Outdated Show resolved Hide resolved

# If timeout is reached, the test was succesful
if [ $TIMEOUT_REACHED -eq 1 ]; then
kill -9 $API_WATCH_PID # If timeout reached, kill the background process
Copy link
Collaborator

Choose a reason for hiding this comment

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

why it is required? are not we going to finish compose?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We decided to stop the api watch command in the succesful path, so we can add the entry, start to look again in another file, and after that assert that we receive the "Received" message (in 07-check-api-watch)
But that was just one of the valid approachs that we have, maybe is there another way to do it?

Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe this can be related to previous comment :D

CURRENT_TIME=$(date +%s)
ELAPSED_TIME=$((CURRENT_TIME - START_TIME))
if [ $ELAPSED_TIME -gt $TIMEOUT ]; then
echo "Error: Timeout reached while waiting for 'Received' message."
Copy link
Collaborator

Choose a reason for hiding this comment

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

fail-now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I remove the echo message too?


TIMEOUT=60
START_TIME=$(date +%s)
while true; do
Copy link
Collaborator

Choose a reason for hiding this comment

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

what is the intention here?
Server has a ttl of 10m that measn that svids will be rotating every 5m,
but this test case is for 1m, so there is no rotation here,
maybe you can reduce ttl to 1m and verify that the svid rotated once, that will reduce the time for this for to 30s (because it will be finishing as soon an update is done)

echo "$SUCCESS"
docker-compose logs
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
echo "$SUCCESS"
docker-compose logs
docker-compose logs

Signed-off-by: FedeNQ <fedenahuel07@gmail.com>
Signed-off-by: FedeNQ <fedenahuel07@gmail.com>
Signed-off-by: FedeNQ <fedenahuel07@gmail.com>
Signed-off-by: FedeNQ <fedenahuel07@gmail.com>
Signed-off-by: FedeNQ <fedenahuel07@gmail.com>
Signed-off-by: FedeNQ <fedenahuel07@gmail.com>
Signed-off-by: FedeNQ <fedenahuel07@gmail.com>
Signed-off-by: FedeNQ <fedenahuel07@gmail.com>
Signed-off-by: FedeNQ <fedenahuel07@gmail.com>
@FedeNQ FedeNQ force-pushed the add-agent-integration-test branch from dc9f0fd to ca4bcc9 Compare May 21, 2024 15:33
@MarcosDY MarcosDY merged commit b899683 into spiffe:main May 21, 2024
33 checks passed
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 integration tests to exercise spire-agent CLI commands
2 participants