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

fix inverted logic for resource logic #6700

Merged
merged 4 commits into from
Feb 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ func validateFlags(cmd *cobra.Command, drvName string) {
validateDiskSize()
validateMemorySize()

if !driver.HasResourceLimits(drvName) { // both podman and none need root and they both cant specify resources
if !driver.HasResourceLimits(drvName) {
if cmd.Flags().Changed(cpus) {
out.WarningT("The '{{.name}}' driver does not respect the --cpus flag", out.V{"name": drvName})
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/minikube/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func NeedsRoot(name string) bool {

// HasResourceLimits returns true if driver can set resource limits such as memory size or CPU count.
func HasResourceLimits(name string) bool {
return name == None || name == Podman
return !(name == None || name == Podman)
}

// FlagHints are hints for what default options should be used for this driver
Expand Down
121 changes: 66 additions & 55 deletions test/integration/functional_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,68 +494,79 @@ func validateLogsCmd(ctx context.Context, t *testing.T, profile string) {

// validateProfileCmd asserts "profile" command functionality
func validateProfileCmd(ctx context.Context, t *testing.T, profile string) {
// Profile command should not create a nonexistent profile
nonexistentProfile := "lis"
rr, err := Run(t, exec.CommandContext(ctx, Target(), "profile", nonexistentProfile))
rr, err = Run(t, exec.CommandContext(ctx, Target(), "profile", "list", "--output", "json"))
if err != nil {
t.Errorf("%s failed: %v", rr.Args, err)
}
var profileJson map[string][]map[string]interface{}
err = json.Unmarshal(rr.Stdout.Bytes(), &profileJson)
if err != nil {
t.Errorf("%s failed: %v", rr.Args, err)
}
for profileK := range profileJson {
for _, p := range profileJson[profileK] {
var name = p["Name"]
if (name == nonexistentProfile) {
t.Errorf("minikube profile %s should not exist", nonexistentProfile)
t.Run("profile_not_create", func(t *testing.T) {
// Profile command should not create a nonexistent profile
nonexistentProfile := "lis"
rr, err := Run(t, exec.CommandContext(ctx, Target(), "profile", nonexistentProfile))
if err != nil {
t.Errorf("%s failed: %v", rr.Args, err)
}
rr, err = Run(t, exec.CommandContext(ctx, Target(), "profile", "list", "--output", "json"))
if err != nil {
t.Errorf("%s failed: %v", rr.Args, err)
}
var profileJSON map[string][]map[string]interface{}
err = json.Unmarshal(rr.Stdout.Bytes(), &profileJSON)
if err != nil {
t.Errorf("%s failed: %v", rr.Args, err)
}
for profileK := range profileJSON {
for _, p := range profileJSON[profileK] {
var name = p["Name"]
if name == nonexistentProfile {
t.Errorf("minikube profile %s should not exist", nonexistentProfile)
}
}
}
}
})

// List profiles
rr, err = Run(t, exec.CommandContext(ctx, Target(), "profile", "list"))
if err != nil {
t.Errorf("%s failed: %v", rr.Args, err)
}
t.Run("profile_list", func(t *testing.T) {
// List profiles
rr, err := Run(t, exec.CommandContext(ctx, Target(), "profile", "list"))
if err != nil {
t.Errorf("%s failed: %v", rr.Args, err)
}

// Table output
listLines := strings.Split(strings.TrimSpace(rr.Stdout.String()), "\n")
profileExists := false
for i := 3; i < (len(listLines) - 1); i++ {
profileLine := listLines[i]
if strings.Contains(profileLine, profile) {
profileExists = true
break
// Table output
listLines := strings.Split(strings.TrimSpace(rr.Stdout.String()), "\n")
profileExists := false
for i := 3; i < (len(listLines) - 1); i++ {
profileLine := listLines[i]
if strings.Contains(profileLine, profile) {
profileExists = true
break
}
}
if !profileExists {
t.Errorf("%s failed: Missing profile '%s'. Got '\n%s\n'", rr.Args, profile, rr.Stdout.String())
}
}
if !profileExists {
t.Errorf("%s failed: Missing profile '%s'. Got '\n%s\n'", rr.Args, profile, rr.Stdout.String())
}

// Json output
rr, err = Run(t, exec.CommandContext(ctx, Target(), "profile", "list", "--output", "json"))
if err != nil {
t.Errorf("%s failed: %v", rr.Args, err)
}
var jsonObject map[string][]map[string]interface{}
err = json.Unmarshal(rr.Stdout.Bytes(), &jsonObject)
if err != nil {
t.Errorf("%s failed: %v", rr.Args, err)
}
validProfiles := jsonObject["valid"]
profileExists = false
for _, profileObject := range validProfiles {
if profileObject["Name"] == profile {
profileExists = true
break
})

t.Run("profile_json_output", func(t *testing.T) {
// Json output
rr, err := Run(t, exec.CommandContext(ctx, Target(), "profile", "list", "--output", "json"))
if err != nil {
t.Errorf("%s failed: %v", rr.Args, err)
}
}
if !profileExists {
t.Errorf("%s failed: Missing profile '%s'. Got '\n%s\n'", rr.Args, profile, rr.Stdout.String())
}
var jsonObject map[string][]map[string]interface{}
err = json.Unmarshal(rr.Stdout.Bytes(), &jsonObject)
if err != nil {
t.Errorf("%s failed: %v", rr.Args, err)
}
validProfiles := jsonObject["valid"]
profileExists := false
for _, profileObject := range validProfiles {
if profileObject["Name"] == profile {
profileExists = true
break
}
}
if !profileExists {
t.Errorf("%s failed: Missing profile '%s'. Got '\n%s\n'", rr.Args, profile, rr.Stdout.String())
}

})
}

// validateServiceCmd asserts basic "service" command functionality
Expand Down