Skip to content
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

Set 'currentstep' for PullingBaseImage json event #9844

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pkg/minikube/out/register/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func init() {
SelectingDriver,
DownloadingArtifacts,
StartingNode,
PullingBaseImage,
medyagh marked this conversation as resolved.
Show resolved Hide resolved
RunningLocalhost,
LocalOSRelease,
CreatingContainer,
Expand Down
30 changes: 23 additions & 7 deletions test/integration/aaa_download_only_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ limitations under the License.
package integration

import (
"bufio"
"bytes"
"context"
"crypto/md5"
"encoding/json"
"fmt"
"io/ioutil"
"os"
Expand All @@ -41,7 +44,6 @@ func TestDownloadOnly(t *testing.T) {
t.Run(r, func(t *testing.T) {
// Stores the startup run result for later error messages
var rrr *RunResult
var err error

profile := UniqueProfileName(r)
ctx, cancel := context.WithTimeout(context.Background(), Minutes(30))
Expand All @@ -58,18 +60,32 @@ func TestDownloadOnly(t *testing.T) {
defer PostMortemLogs(t, profile)

// --force to avoid uid check
args := append([]string{"start", "--download-only", "-p", profile, "--force", "--alsologtostderr", fmt.Sprintf("--kubernetes-version=%s", v), fmt.Sprintf("--container-runtime=%s", r)}, StartArgs()...)
args := append([]string{"start", "-o=json", "--download-only", "-p", profile, "--force", "--alsologtostderr", fmt.Sprintf("--kubernetes-version=%s", v), fmt.Sprintf("--container-runtime=%s", r)}, StartArgs()...)

// Preserve the initial run-result for debugging
rt, err := Run(t, exec.CommandContext(ctx, Target(), args...))
if rrr == nil {
rrr, err = Run(t, exec.CommandContext(ctx, Target(), args...))
} else {
_, err = Run(t, exec.CommandContext(ctx, Target(), args...))
// Preserve the initial run-result for debugging
rrr = rt
}

if err != nil {
t.Errorf("failed to download only. args: %q %v", args, err)
}
s := bufio.NewScanner(bytes.NewReader(rt.Stdout.Bytes()))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could potentially be a Subtest
another t.Run with a name like "validateStepNumber"

so when it fails we know exaclty what part of download only test failed

example of adding subtests in TestStartStop test
https://github.com/medyagh/minikube/blob/b6ee8f2f6777921a87959df78e2497fafc9c5864/test/integration/start_stop_delete_test.go#L100

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

for s.Scan() {
var rtObj map[string]interface{}
err = json.Unmarshal(s.Bytes(), &rtObj)
if err != nil {
t.Errorf("failed to parse output: %v", err)
} else {
if step, ok := rtObj["data"]; ok {
if stepMap, ok := step.(map[string]interface{}); ok {
if stepMap["currentstep"] == "" {
t.Errorf("Empty step number for %v", stepMap["name"])
}
}
}
}
}

// skip for none, as none driver does not have preload feature.
if !NoneDriver() {
Expand Down