-
Notifications
You must be signed in to change notification settings - Fork 27
Bottlerocket Testing Cli #487
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
Merged
ecpullen
merged 1 commit into
bottlerocket-os:develop
from
vyaghras:Bottlerocket_esting_cli
Aug 17, 2022
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,28 @@ | ||
| [package] | ||
| name = "test-agent-cli" | ||
| version = "0.1.0" | ||
| edition = "2021" | ||
| publish = false | ||
| license = "MIT OR Apache-2.0" | ||
|
|
||
| [dependencies] | ||
| argh = "0.1" | ||
| agent-common = { version = "0.0.1", path = "../agent-common" } | ||
| test-agent = { version = "0.0.1", path = "../test-agent" } | ||
| tokio = { version = "1", features = ["macros", "rt-multi-thread", "fs"] } | ||
| tokio-util = "0.7" | ||
| log = "0.4" | ||
| model = { version = "0.0.1", path = "../../model" } | ||
| snafu = "0.7" | ||
| async-trait = "0.1" | ||
| tempfile = "3" | ||
| serde_json = "1" | ||
| env_logger = "0.9" | ||
| serde_plain = "0.3" | ||
| serde_derive = "1" | ||
| serde = "1" | ||
| tar = "0.4" | ||
|
|
||
| [dev-dependencies] | ||
| assert_cmd = "2.0" | ||
| selftest = { version = "0.0.1", path = "../../selftest" } |
This file contains hidden or 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,99 @@ | ||
| # Steps to use Test-agent Command Line Interface | ||
|
vyaghras marked this conversation as resolved.
|
||
| `test-agent-cli` lets you write TestSys test using Bash and help in receiving and sending information from/to the TestSys cluster. | ||
|
|
||
| ## Prerequisites: | ||
|
vyaghras marked this conversation as resolved.
|
||
| * kind: https://kind.sigs.k8s.io/docs/user/quick-start/ | ||
| * Kubectl: https://kubernetes.io/docs/tasks/tools/ | ||
| * Docker : https://docs.docker.com/get-started/ | ||
|
|
||
| ## Steps to install TestSys | ||
| Set the TESTSYS_DIR variable to point to the directory in which you have cloned the project. For example: | ||
| ```shell | ||
| export TESTSYS_DIR="${HOME}/repos/bottlerocket-test-system" | ||
| ``` | ||
| Set alias | ||
| ```shell | ||
| alias cli="${TESTSYS_DIR}/.cargo/bin/cli" | ||
| ``` | ||
| Install the `cli` command line tool into the local CARGO_HOME as: | ||
| ```shell | ||
| cd "${TESTSYS_DIR}" | ||
| cargo install --path "${TESTSYS_DIR}/cli" --force | ||
| ``` | ||
|
|
||
| ## Steps to create Bash based TestAgent: | ||
|
|
||
| The following commands can be used to communicate with a TestSys cluster. Create a bash script like [Example test](../examples/example_test_agent_cli/example-test.sh). | ||
| ```shell | ||
| # Get the configuration details and set the task state running | ||
| test-agent-cli init | ||
|
|
||
| # Get the number of retires allowed in case of failing tests | ||
| test-agent-cli retry-count | ||
|
|
||
| # Get the secret value using the secret key | ||
| test-agent-cli get-secret secret-key | ||
|
|
||
| # Send the result of every test run to test object in Controller | ||
| test-agent-cli send-result -o pass -p 1 -f 0 -s 0 | ||
|
|
||
| # Send any error encountered in test | ||
| test-agent-cli send-error error-message | ||
|
|
||
| # Mark the test as completed | ||
| test-agent-cli terminate --results-dir results_directory | ||
| ``` | ||
| Create a [Dockerfile](../examples/example_test_agent_cli/Dockerfile).\ | ||
| Remember to set the ENTRYPOINT to the test Bash script and install the required packages. | ||
|
|
||
| Create the docker image.\ | ||
| **Note**: Add a target to the `Makefile` to create the new image. | ||
| ```shell | ||
| make example-test-agent-cli | ||
|
vyaghras marked this conversation as resolved.
|
||
| docker image tag example-test-agent-cli example-test-agent-cli:bash | ||
| ``` | ||
|
|
||
| Create and tag the controller image. | ||
| ```shell | ||
| make controller | ||
| docker image tag controller controller:bash | ||
| ``` | ||
|
|
||
| ## Steps to use Bash based TestAgent: | ||
|
|
||
| Check if the cluster already exists: | ||
| ```shell | ||
| kind get clusters | ||
| ``` | ||
| If the cluster already exists, it should be deleted. | ||
| ```shell | ||
| kind delete cluster --name <testsys_cluster_name> | ||
| ``` | ||
| Create the new cluster. | ||
| ```shell | ||
| kind create cluster --name <testsys_cluster_name> | ||
| ``` | ||
| Now the images created earlier need to be added to the cluster. | ||
| ```shell | ||
| kind load docker-image controller:bash example-test-agent-cli:bash --name <testsys_cluster_name> | ||
| ``` | ||
| Install TestSys to the cluster. | ||
| ```shell | ||
| cli install --controller-uri controller:bash | ||
| ``` | ||
|
|
||
| Create a [yaml file](../tests/data/deploy_test.yaml) for Test. | ||
|
|
||
| Run the test. | ||
| ```shell | ||
| cli run file <filename> | ||
| ``` | ||
| Check the status of the test. | ||
| ```shell | ||
| cli status -c | ||
| ``` | ||
| Cleanup all the resources. | ||
| ```shell | ||
| cli delete | ||
| ``` | ||
|
|
||
30 changes: 30 additions & 0 deletions
30
agent/test-agent-cli/examples/example_test_agent_cli/Dockerfile
This file contains hidden or 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,30 @@ | ||
| # syntax=docker/dockerfile:1.1.3-experimental | ||
|
vyaghras marked this conversation as resolved.
|
||
| ARG BUILDER_IMAGE | ||
| FROM ${BUILDER_IMAGE} as build | ||
|
|
||
| ARG ARCH | ||
| USER root | ||
| # We need these environment variables set for building the `openssl-sys` crate | ||
| ENV PKG_CONFIG_PATH=/${ARCH}-bottlerocket-linux-musl/sys-root/usr/lib/pkgconfig | ||
| ENV PKG_CONFIG_ALLOW_CROSS=1 | ||
| ENV CARGO_HOME=/src/.cargo | ||
| ENV OPENSSL_STATIC=true | ||
| ENV CARGO_HOME=/src/.cargo | ||
| ADD ./ /src/ | ||
| WORKDIR /src/agent/test-agent-cli | ||
| RUN --mount=type=cache,mode=0777,target=/src/target \ | ||
| cargo install --locked --offline --target ${ARCH}-bottlerocket-linux-musl --path . --root ./ | ||
|
|
||
| FROM public.ecr.aws/amazonlinux/amazonlinux:2 | ||
| # Install all the required packages for Bash test script. | ||
| RUN yum update -y \ | ||
| && yum install -y jq \ | ||
| && yum clean all | ||
|
|
||
| COPY --from=build /src/agent/test-agent-cli/bin/test-agent-cli /usr/local/bin/ | ||
| # Copy the Bash test script | ||
| COPY --from=build /src/agent/test-agent-cli/examples/example_test_agent_cli/example-test.sh ./ | ||
|
|
||
| # Mark the test script as entry point | ||
| ENTRYPOINT ["/bin/bash", "./example-test.sh"] | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.