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

Strip the version prefix before calling semver #7054

Merged
merged 2 commits into from
Mar 18, 2020

Conversation

afbjorklund
Copy link
Collaborator

Needs a mirror country unit test, apparently.

Closes #7052

@afbjorklund afbjorklund requested a review from tstromberg March 15, 2020 11:32
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Mar 15, 2020
@k8s-ci-robot k8s-ci-robot requested review from medyagh and RA489 March 15, 2020 11:32
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: afbjorklund

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 15, 2020
@codecov-io
Copy link

codecov-io commented Mar 15, 2020

Codecov Report

Merging #7054 into master will increase coverage by 0.29%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #7054      +/-   ##
==========================================
+ Coverage   36.94%   37.24%   +0.29%     
==========================================
  Files         146      146              
  Lines        9094     9094              
==========================================
+ Hits         3360     3387      +27     
+ Misses       5322     5292      -30     
- Partials      412      415       +3
Impacted Files Coverage Δ
cmd/minikube/cmd/start.go 38.47% <100%> (+4.67%) ⬆️

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Mar 15, 2020
@afbjorklund
Copy link
Collaborator Author

Test seems to be working as intended, catches the previous error which was the idea:

=== RUN   TestMirrorCountry
=== RUN   TestMirrorCountry/image-repository_none,_image-mirror-country_none
=== RUN   TestMirrorCountry/image-repository_auto,_image-mirror-country_none
panic: semver: Parse(v1.17.3): Invalid character(s) found in major number "v1" [recovered]
	panic: semver: Parse(v1.17.3): Invalid character(s) found in major number "v1"

It doesn't really verify the repository though, since it could still be defined as empty:

        // ImageRepositories contains all known image repositories
        ImageRepositories = map[string][]string{
                "global": {""},
                "cn":     {"registry.cn-hangzhou.aliyuncs.com/google_containers"},
        }

for _, test := range tests {
t.Run(test.description, func(t *testing.T) {
cmd := &cobra.Command{}
viper.SetDefault(imageRepository, test.imageRepository)
Copy link
Member

Choose a reason for hiding this comment

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

Calling viper.Set in unit test has un-wanted side effects, such as setting the user 's settings and also can not run in parallel safely

Could we break down generateCfgFromFlags func so we can test only the mirror func without need to pass cobra ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No idea, think I only copied what the test above was doing or something

                        viper.SetDefault(kubernetesVersion, test.paramVersion)

Copy link
Member

Choose a reason for hiding this comment

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

I think we can refactor our tests not to use viper as much as possible, we could parameterize the funcs into small independent testable units. what do u think? maybe good opprotunity to refactor this part of the code?

@tstromberg tstromberg merged commit ce1cc8d into kubernetes:master Mar 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

run minikube start with --image-mirror-country=cn failed
5 participants