Skip to content

Commit

Permalink
Merge pull request #9844 from ilya-zuyev/gh_9754_downloadprogress_cur…
Browse files Browse the repository at this point in the history
…rentstep

Set 'currentstep' for PullingBaseImage json event
  • Loading branch information
medyagh authored Dec 8, 2020
2 parents dd6a445 + f0b3291 commit 268a938
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
2 changes: 2 additions & 0 deletions pkg/minikube/out/register/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"k8s.io/minikube/pkg/trace"
)

// If you add a new step here, please also add it to register.Reg registry inside the init() function
const (
InitialSetup RegStep = "Initial Minikube Setup"
SelectingDriver RegStep = "Selecting Driver"
Expand Down Expand Up @@ -70,6 +71,7 @@ func init() {
SelectingDriver,
DownloadingArtifacts,
StartingNode,
PullingBaseImage,
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)
}
t.Run("check json events", func(t *testing.T) {
s := bufio.NewScanner(bytes.NewReader(rt.Stdout.Bytes()))
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

0 comments on commit 268a938

Please sign in to comment.