-
Notifications
You must be signed in to change notification settings - Fork 15
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 --log-file argument and log test result details #54
base: main
Are you sure you want to change the base?
Changes from all commits
eb92df3
7a75847
87c0352
5aa7e33
c9608a9
7337049
72a2cf0
53a9ab8
febd36a
887cb6e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,7 @@ checks: | |
description: 🌏 Exposes an HTTP interface on port 8888 | ||
probe: | ||
httpGet: | ||
path: / | ||
path: /hub/jovyan | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm curious about the motivation here. This feels orthogonal to the rest of this PR. It's my understanding that Kubeflow only expects a service on port There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This PR has some bug fixes and tests too. One of the bugs was that it wasn't checking the status code when doing |
||
port: 8888 | ||
failureThreshold: 30 | ||
- name: NB_PREFIX | ||
|
@@ -54,7 +54,7 @@ checks: | |
description: "🔓 Sets 'Access-Control-Allow-Origin: *' header" | ||
probe: | ||
httpGet: | ||
path: / | ||
path: /hub/jovyan | ||
port: 8888 | ||
httpHeaders: | ||
- name: User-Agent | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* SPDX-FileCopyrightText: Copyright (c) <2024> NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package validator | ||
|
||
import ( | ||
"testing" | ||
|
||
canaryv1 "github.com/nvidia/container-canary/internal/apis/v1" | ||
"github.com/stretchr/testify/assert" | ||
v1 "k8s.io/api/core/v1" | ||
) | ||
|
||
func TestExecSuccess(t *testing.T) { | ||
assert := assert.New(t) | ||
|
||
c := &dummyContainer{} | ||
probe := &canaryv1.Probe{ | ||
Exec: &v1.ExecAction{ | ||
Command: []string{"success"}, | ||
}, | ||
} | ||
|
||
logger, buf := logger() | ||
e := logger.Info() | ||
result, err := ExecCheck(c, probe, e) | ||
e.Send() | ||
|
||
assert.True(result) | ||
assert.NoError(err) | ||
assert.Equal("{\"level\":\"info\",\"exitCode\":0,\"stdout\":\"Success stdout\",\"stderr\":\"Success stderr\"}\n", buf.String()) | ||
} | ||
|
||
func TestExecFailure(t *testing.T) { | ||
assert := assert.New(t) | ||
|
||
c := &dummyContainer{} | ||
probe := &canaryv1.Probe{ | ||
Exec: &v1.ExecAction{ | ||
Command: []string{"failure"}, | ||
}, | ||
} | ||
|
||
logger, buf := logger() | ||
e := logger.Info() | ||
result, err := ExecCheck(c, probe, e) | ||
e.Send() | ||
assert.False(result) | ||
assert.NoError(err) | ||
assert.Equal("{\"level\":\"info\",\"exitCode\":1,\"stdout\":\"Failure stdout\",\"stderr\":\"Failure stderr\"}\n", buf.String()) | ||
} | ||
|
||
func TestExecError(t *testing.T) { | ||
assert := assert.New(t) | ||
|
||
c := &dummyContainer{} | ||
probe := &canaryv1.Probe{ | ||
Exec: &v1.ExecAction{ | ||
Command: []string{"error"}, | ||
}, | ||
} | ||
|
||
logger, buf := logger() | ||
e := logger.Info() | ||
result, err := ExecCheck(c, probe, e) | ||
e.Send() | ||
assert.False(result) | ||
assert.Error(err, "This command is an error") | ||
assert.Equal("{\"level\":\"info\"}\n", buf.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.
Why not use stdout? That gives more flexibility for redirection.
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 believe stdout is already consumed by the user-readable output. Writing to a separate log file allows us to get separate machine-readable output, and CI can always
cat
the file if we want the developer to see it (that's what I plan on doing).