In this commit, we add e2e tests for the `karmadactl apply`
command to ensure it handles various scenarios correctly.
The tests include:
- Applying configurations without propagating them into member clusters.
- Applying configurations with propagation into specific member clusters.
- Applying configurations and propagating them to all member clusters.
- Verifying that no resources were created during `--dry-run` mode.
- Ensuring the command returns an error for an invalid flag.
- Ensuring the command returns an error when the specified file does not exist.
- Applying configurations with the `--namespace` flag to ensure resources are created in the specified namespace.
- Applying configurations with the `--force-conflicts` flag to ensure conflicts are forcefully resolved during server-side apply.
- Applying configurations using the `--kustomize` flag to process a kustomization directory.
Signed-off-by: Mohamed Awnallah <mohamedmohey2352@gmail.com>
Co-authored-by: zhzhuang-zju <m17799853869@163.com>
Co-authored-by: Chang <changzhen5@huawei.com>
In this commit, we unify the generation of random string
length by utilizing `RandomStrLength` global constant.
Signed-off-by: Mohamed Awnallah <mohamedmohey2352@gmail.com>
In this commit, we add e2e tests for the `karmadactl taint`
command to ensure it handles various scenarios correctly.
The tests include:
- Applying taints with different effects (NoSchedule, NoExecute) to a cluster.
- Reapplying taints without the `--overwrite` flag to ensure an error is returned.
- Overwriting existing taints using the `--overwrite` flag.
- Removing taints from a cluster.
- Running the taint command in `--dry-run` mode to ensure no actual changes are made.
- Verifying that taints were not applied during `--dry-run` mode.
- Ensuring the command returns an error for an invalid flag.
- Ensuring the command returns an error when attempting to taint a non-existent cluster.
Signed-off-by: Mohamed Awnallah <mohamedmohey2352@gmail.com>
Co-authored-by: zhzhuang-zju <m17799853869@163.com>
In this commit, we test `karmadactl options` on listing
all available global options successfully and returning
an error for invalid flag in options.
Signed-off-by: Mohamed Awnallah <mohamedmohey2352@gmail.com>
In this commit, we add tests for the `karmadactl token`
command. These include creating, deleting, listing, and
validating bootstrap tokens. We test scenarios such as
successful token creation and deletion, error handling
for invalid flag, and ensuring the correct format for
tokens. The utility functions `extractTokenIDAndSecret`
and `validateTokenFormat` are used to validate token
format and extract token components.
Signed-off-by: Mohamed Awnallah <mohamedmohey2352@gmail.com>
Co-authored-by: zhzhuang-zju <m17799853869@163.com>
In this commit, we test `karmadactl describe` command
on existing resource, non-existing resource, non-existing
namespace, and invalid resource type.
Signed-off-by: Mohamed Awnallah <mohamedmohey2352@gmail.com>
In this commit, we test `karmadactl get` command
on existing resource, non-existing resource, and
invalid resource type.
Signed-off-by: Mohamed Awnallah <mohamedmohey2352@gmail.com>
In this commit, we test `karmadactl version` command to
make sure it return valid information and return error
when invalid flag is provided.
Signed-off-by: Mohamed Awnallah <mohamedmohey2352@gmail.com>
In this commit, we test `karmadactl logs` command
on existing cluster, existing pod, non-existing pod,
non-existing cluster, and invalid input.
Signed-off-by: Mohamed Awnallah <mohamedmohey2352@gmail.com>