-
Notifications
You must be signed in to change notification settings - Fork 111
test(e2e): add e2e tests for authz, secret, log, accesslog, version and dump #1316
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: ravjot07 <ravu2004@gmail.com>
Signed-off-by: ravjot07 <ravu2004@gmail.com>
Signed-off-by: ravjot07 <ravu2004@gmail.com>
Signed-off-by: ravjot07 <ravu2004@gmail.com>
Signed-off-by: ravjot07 <ravu2004@gmail.com>
Signed-off-by: ravjot07 <ravu2004@gmail.com>
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
accesslogs are reported periodically after (5 sec) for long tcp_connections, can you add a e2e test for this ?? @ravjot07 |
ya sure |
test/e2e/kmeshctl_test.go
Outdated
"bufio" | ||
"context" | ||
"crypto/rand" | ||
"encoding/hex" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gofmt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use gofmt
to format the code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
test/e2e/kmeshctl_test.go
Outdated
} | ||
} | ||
|
||
func runAuthzCmd(args ...string) (string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can merge runAuthCmd
, runVersionCmd
, etc and pass parameters as needed, because you have not structed any subcommands yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done pl. review
test/e2e/kmeshctl_test.go
Outdated
|
||
t.Run("kernel-native", func(t *testing.T) { | ||
out, err := runDumpCmd(pod, "kernel-native") | ||
t.Logf("Output of 'kmeshctl dump %s kernel-native':\n%s", pod, out) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should at least check if the command output contains certain key strings instead of printing the log directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done i have updated the test
ping @ravjot07 |
Signed-off-by: ravjot07 <ravu2004@gmail.com>
Signed-off-by: ravjot07 <ravu2004@gmail.com>
test/e2e/kmeshctl_test.go
Outdated
|
||
func TestKmeshctlVersion(t *testing.T) { | ||
pod := findKmeshPod(t) | ||
waitForPodRunning(t, pod) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can ensure that the Kmesh pods are in the running status before running this test, ref: https://github.com/kmesh-net/kmesh/blob/main/test/e2e/run_test.sh#L118
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done pl. review
Signed-off-by: ravjot07 <ravu2004@gmail.com>
Adding label Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
@ravjot07 you should use |
test/e2e/kmeshctl_test.go
Outdated
return outStr, err | ||
} | ||
|
||
func waitForPodReady(t *testing.T, pod string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
test/e2e/kmeshctl_test.go
Outdated
} | ||
} | ||
|
||
func findKmeshPod(t *testing.T) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like it is implemented in init
and can be deleted?
test/e2e/kmeshctl_test.go
Outdated
}) | ||
|
||
t.Run("list", func(t *testing.T) { | ||
time.Sleep(2 * time.Second) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is better not to sleep directly, polling is better, and an error will be reported if the timeout occurs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i have changes this part using polling
@@ -272,8 +290,11 @@ if [[ -z "${SKIP_SETUP:-}" ]]; then | |||
fi | |||
|
|||
if [[ -z "${SKIP_BUILD:-}" ]]; then | |||
setup_kind_registry | |||
build_and_push_images | |||
setup_kind_registry |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
test/e2e/run_test.sh
Outdated
setup_kind_registry | ||
build_and_push_images | ||
echo "Building kmeshctl CLI..." | ||
make kmeshctl || { echo "Failed to build kmeshctl" >&2; exit 1; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we don't compile kmeshctl? Already done in previous build_and_push_images
?
Signed-off-by: ravjot07 <ravu2004@gmail.com>
@@ -209,6 +209,24 @@ function cleanup_docker_registry() { | |||
docker rm "${KIND_REGISTRY_NAME}" || echo "Failed to remove or no such registry '${KIND_REGISTRY_NAME}'." | |||
} | |||
|
|||
TMPBIN="${TMPBIN:-$(mktemp -d)/bin}" | |||
mkdir -p "$TMPBIN" | |||
export PATH="$PATH:$TMPBIN" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we already have this dicretory
# Function to install kmeshctl into the test environment. | ||
function install_kmeshctl() { | ||
echo "Installing kmeshctl CLI into test environment..." | ||
if [[ -f "$ROOT_DIR/kmeshctl" ]]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to check, just copy it.
// Package‐level init ensures Kmesh is ready before any tests run. | ||
func init() { | ||
// 1) Wait up to 2 minutes for all Kmesh pods to become Ready. | ||
wait := exec.Command("kubectl", "-n", kmeshNamespace, "wait", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have already said that the Kmesh pod is ready, no need to check it again
test(e2e): add end-to-end tests for kmeshctl commands
Each test locates a running kmesh daemon pod, waits for readiness, invokes the CLI, and asserts expected behaviour or output.