Skip to content

Commit 268a938

Browse files
authored
Merge pull request #9844 from ilya-zuyev/gh_9754_downloadprogress_currentstep
Set 'currentstep' for PullingBaseImage json event
2 parents dd6a445 + f0b3291 commit 268a938

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

pkg/minikube/out/register/register.go

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"k8s.io/minikube/pkg/trace"
2525
)
2626

27+
// If you add a new step here, please also add it to register.Reg registry inside the init() function
2728
const (
2829
InitialSetup RegStep = "Initial Minikube Setup"
2930
SelectingDriver RegStep = "Selecting Driver"
@@ -70,6 +71,7 @@ func init() {
7071
SelectingDriver,
7172
DownloadingArtifacts,
7273
StartingNode,
74+
PullingBaseImage,
7375
RunningLocalhost,
7476
LocalOSRelease,
7577
CreatingContainer,

test/integration/aaa_download_only_test.go

+23-7
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@ limitations under the License.
1919
package integration
2020

2121
import (
22+
"bufio"
23+
"bytes"
2224
"context"
2325
"crypto/md5"
26+
"encoding/json"
2427
"fmt"
2528
"io/ioutil"
2629
"os"
@@ -41,7 +44,6 @@ func TestDownloadOnly(t *testing.T) {
4144
t.Run(r, func(t *testing.T) {
4245
// Stores the startup run result for later error messages
4346
var rrr *RunResult
44-
var err error
4547

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

6062
// --force to avoid uid check
61-
args := append([]string{"start", "--download-only", "-p", profile, "--force", "--alsologtostderr", fmt.Sprintf("--kubernetes-version=%s", v), fmt.Sprintf("--container-runtime=%s", r)}, StartArgs()...)
63+
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()...)
6264

63-
// Preserve the initial run-result for debugging
65+
rt, err := Run(t, exec.CommandContext(ctx, Target(), args...))
6466
if rrr == nil {
65-
rrr, err = Run(t, exec.CommandContext(ctx, Target(), args...))
66-
} else {
67-
_, err = Run(t, exec.CommandContext(ctx, Target(), args...))
67+
// Preserve the initial run-result for debugging
68+
rrr = rt
6869
}
69-
7070
if err != nil {
7171
t.Errorf("failed to download only. args: %q %v", args, err)
7272
}
73+
t.Run("check json events", func(t *testing.T) {
74+
s := bufio.NewScanner(bytes.NewReader(rt.Stdout.Bytes()))
75+
for s.Scan() {
76+
var rtObj map[string]interface{}
77+
err = json.Unmarshal(s.Bytes(), &rtObj)
78+
if err != nil {
79+
t.Errorf("failed to parse output: %v", err)
80+
} else if step, ok := rtObj["data"]; ok {
81+
if stepMap, ok := step.(map[string]interface{}); ok {
82+
if stepMap["currentstep"] == "" {
83+
t.Errorf("Empty step number for %v", stepMap["name"])
84+
}
85+
}
86+
}
87+
}
88+
})
7389

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

0 commit comments

Comments
 (0)