docs: Add documentation-test for run-command.md#52
Conversation
42e65b7 to
841b46d
Compare
841b46d to
81be06a
Compare
81be06a to
763d0d5
Compare
763d0d5 to
aad8b88
Compare
aad8b88 to
c09ff6c
Compare
6ee35b0 to
b9abeeb
Compare
f977fcc to
0646379
Compare
blanquicet
left a comment
There was a problem hiding this comment.
Fist set of comments after a quick review.
| ## Testing | ||
|
|
||
| ### integration tests | ||
|
|
||
| The integration test needs an AKS cluster to run against. You can create one and use following command to run the integration test: | ||
|
|
||
| ``` | ||
| make integration-test | ||
| ``` | ||
|
|
||
| You will need to set `AZURE_RESOURCE_GROUP` and `AZURE_CLUSTER_NAME` environment variables to specify the AKS cluster to run against. | ||
|
|
||
| ### documentation tests | ||
|
|
||
| The documentation tests are used to validate the documentation examples. You can run the documentation tests with the following command: | ||
|
|
||
| ``` | ||
| make documentation-test | ||
| ``` | ||
|
|
||
| or | ||
|
|
||
| ``` | ||
| DOCUMENTATION_TEST_FILES=README.md make documentation-test -o install | ||
| ``` | ||
|
|
||
| An INI file with all the required variables needs to be created to run the documentation tests. A sample INI file for [docs/run-command.md](docs/run-command.md) | ||
| is available [here](docs/run-command.ini.sample). | ||
|
|
There was a problem hiding this comment.
IMO, this should go in another file like "CONTRIBUTING.md" or so. I'd prefer to keep the README clean and simple.
| ``` | ||
| make integration-test | ||
| ``` |
There was a problem hiding this comment.
It would be useful if there is a way to avoid the InnovationEngine executes a code block instead of having to remove the bash.
| echo "mySubID = ${{ secrets.AZURE_AKS_SUBSCRIPTION_ID }}" >> $f | ||
| echo "myRG = ${{ env.AZURE_PREFIX }}-rg" >> $f | ||
| echo "myCluster = ${{ env.AZURE_PREFIX }}-amd64-cluster" >> $f | ||
| echo "myNode = $(echo '${{ needs.create-aks-cluster.outputs.documentation-nodes }}' | jq -r ".[0]")" >> $f |
There was a problem hiding this comment.
I suggest to define them as env variables in the next job step. WDYT?
- name: Run Documentation tests
env:
SUBSCRIPTION: ${{ secrets.AZURE_AKS_SUBSCRIPTION_ID }}
...
run: make documentation-test -o installThere was a problem hiding this comment.
I suggest to continue with the ini file approach.
| When executing `run-command` without passing through Kubernetes, we need to provide the information of the node (VMSS instance) where we want to run the given command. To retrieve such information, we can use the [`config import`](./config.md#importing-configuration) command. Once we got it, we can select the node we want to use and all the subsequent `run-command` commands will be executed on that node: | ||
|
|
||
| ```bash | ||
| # Clean the current configuration (if any) |
There was a problem hiding this comment.
I think comments should now become normal text and it should always looks like:
Now, let's do ...
-bash commands-
In a cluster with three nodes, the output will look like this:
<!!--expected_similarity=X-->
-output-
Next, let's do that ...
-bash commands-
And this time the output ...
<!!--expected_similarity=X-->
-output-
Instead of a set of consecutive code blocks as it is now:
-bash commands-
<!!--expected_similarity=X-->
-output-
-bash commands-
<!!--expected_similarity=X-->
-output-
-bash commands-
<!!--expected_similarity=X-->
-output-
b9abeeb to
8e2f76b
Compare
9abf4d2 to
cfad0e1
Compare
Signed-off-by: Qasim Sarfraz <qasimsarfraz@microsoft.com>
| run: make documentation-test -o kubectl-aks | ||
| run: make documentation-test-readme |
There was a problem hiding this comment.
Why did you remove the -o kubectl-aks?
| kubectl aks config unset-all | ||
| ``` | ||
|
|
||
| Import the nodes information with the cluster information: |
There was a problem hiding this comment.
| Import the nodes information with the cluster information: | |
| Import the nodes information with the cluster information: | |
| > [!NOTE] | |
| > Passing the cluster information to the `config import` command is optional. However, in this specific case, it will force the command to retrieve the nodes information from the Azure API server instead of the Kubernetes API server, making this approach more resilient to issues on the Kubernetes control plane. |
| In case we want to print the imported information, we can use the `show` command: | ||
|
|
||
| ```bash | ||
| kubectl aks config show | ||
| ``` |
There was a problem hiding this comment.
If you check, we always execute config show after a config import. I started thinking that we should automatically print the imported data in the config import (maybe with a --quiet flag). Also for the documentation, it makes things more consistent. For instance:
Import node info:
kubectl aks config importRun command against one of the nodes (Folks will take the node name from the previous output):
kubectk aks run-command --node <myNode>WDYT?
| ```bash | ||
| kubectl aks run-command "ip route" | ||
| ``` | ||
|
|
||
| # Execute the run-command, and it will be automatically executed in aks-agentpool-12345678-vmss000000 | ||
| $ kubectl aks run-command "ip route" | ||
| The output should be similar to this: | ||
|
|
||
| <!--expected_similarity=0.8--> | ||
| ``` |
There was a problem hiding this comment.
I'm wondering if we should use another command that provides a more deterministic output so that we can use <!--expected_similarity=1--> or some regex to match an expected string.
Of course, this is something we can do later, not for this PR.
| Unset the current node to avoid conflict with flags or environment variables: | ||
|
|
||
| ```bash | ||
| kubectl aks config unset-current-node | ||
| ``` |
There was a problem hiding this comment.
#55 should solve this issue. It shouldn't be necessary anymore. In the documentation we said that the precedence is flags, env variables, config file. So, using the flag --id should simply have the precedence and don't go in conflict with the config file.
| GO_VERSION: 1.18 | ||
| AZURE_PREFIX: kubectl-aks-ci | ||
| AZURE_NODE_COUNT: 3 # multiple nodes are needed to allow running parallel 'run-command' against the same cluster | ||
| AZURE_NODE_COUNT: 4 # multiple nodes are needed to allow running parallel 'run-command' against the same cluster |
There was a problem hiding this comment.
| AZURE_NODE_COUNT: 3 # multiple nodes are needed to allow running parallel 'run-command' against the same cluster | |
| AZURE_NODE_COUNT: 4 # multiple nodes are needed to allow running parallel 'run-command' against the same cluster | |
| AZURE_NODE_COUNT: 4 # multiple nodes are needed to allow running parallel 'run-command' against the same cluster. See create-aks-cluster.nodes job. |
|
|
||
| ```bash | ||
| kubectl aks run-command "ip route" --id "/subscriptions/$SUBSCRIPTION/resourceGroups/$NODERESOURCEGROUP/providers/Microsoft.Compute/virtualMachineScaleSets/$VMSS/virtualmachines/$INSTANCEID" | ||
| <!-- TODO: Test following when we have a simple way to get instance information --> |
There was a problem hiding this comment.
We could do it with az in the CI and store that info in the ini file.
| echo "mySubID = ${{ secrets.AZURE_AKS_SUBSCRIPTION_ID }}" >> $f | ||
| echo "myRG = ${{ env.AZURE_PREFIX }}-rg" >> $f | ||
| echo "myCluster = ${{ env.AZURE_PREFIX }}-amd64-cluster" >> $f | ||
| echo "myNode = $(echo '${{ needs.create-aks-cluster.outputs.documentation-nodes }}' | jq -r ".[0]")" >> $f |
There was a problem hiding this comment.
I suggest to continue with the ini file approach.
|
|
||
| ```bash | ||
| kubectl aks run-command "ip route" --subscription $SUBSCRIPTION --node-resource-group $NODERESOURCEGROUP --vmss $VMSS --instance-id $INSTANCEID | ||
| Or using the flags: |
There was a problem hiding this comment.
| Or using the flags: | |
| Or using the individual flags: |
BTW, please add also the same TODO comment here.
| ```bash | ||
| kubectl aks run-command "ip route" --node aks-agentpool-12345678-vmss000000 | ||
| kubectl aks run-command "ip route" --node $myNode | ||
| ``` |
There was a problem hiding this comment.
After #52, we should need to clean up the config file. I think it is fine. We could add the unset-all here and explain that otherwise, the info already available in the config file will be re-used.
| ``` | ||
|
|
||
| Start using one of the nodes e.g `aks-agentpool-12345678-vmss000000` we call it `$myNode` here: | ||
|
|
||
| ```bash | ||
| kubectl aks config use-node $myNode | ||
| ``` | ||
|
|
||
| # Start using one of the nodes | ||
| kubectl aks use-node aks-agentpool-12345678-vmss000000 | ||
| Execute the run-command, and it will be automatically executed in `aks-agentpool-12345678-vmss000000`: | ||
|
|
||
| # Execute the run-command, and it will be automatically executed in aks-agentpool-12345678-vmss000000 | ||
| ```bash | ||
| kubectl aks run-command "ip route" | ||
| ``` | ||
|
|
||
| If we run another command, it will again be executed in `aks-agentpool-12345678-vmss000000`: | ||
|
|
||
| # Another command that will be still executed in aks-agentpool-12345678-vmss000000 | ||
| ```bash | ||
| kubectl aks run-command "hostname" | ||
| ``` |
There was a problem hiding this comment.
I don't know, it doesn't make sense to repeat everything here again. Probably, we should change the structure of this file:
- The two mechanisms to retrieve the info (and we verify the output from both using ExecDocs).
- Show the example (only once and no matter how we retrieve the info as we already tested that both are fine).
It's fine to manage this comment in later.
Add test for run-command.md. In order to test it locally you need to write an INI file at
docs/run-command.iniwith sample:Then use following to run the tests: