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

Created a spinner for let users wait that the test is running #148

Merged
merged 6 commits into from
Feb 15, 2024

Conversation

Bharadwajshivam28
Copy link
Member

@Bharadwajshivam28 Bharadwajshivam28 commented Feb 11, 2024

There was a spinner missing which will indicate user that test is going on so they should wait.

Screencast.from.2024-02-11.06-39-28.webm

fixes - #118

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Feb 11, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @Bharadwajshivam28. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 11, 2024
@rjsadow
Copy link
Collaborator

rjsadow commented Feb 11, 2024

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 11, 2024
@@ -41,7 +48,7 @@ func PrintInfo(clientSet *kubernetes.Clientset, config *rest.Config) {
viper.Set("busybox-image", busyboxImage)
}

log.Printf("API endpoint : %s", config.Host)
log.PrintfAPI("API endpoint : %s", config.Host)
Copy link
Collaborator

Choose a reason for hiding this comment

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

By moving the spinner we can revert this to a normal printf and remove the PrintAPI method.

Copy link
Member Author

@Bharadwajshivam28 Bharadwajshivam28 Feb 11, 2024

Choose a reason for hiding this comment

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

Hey @rjsadow I made a new method PrintAPI because I wanted the Spinner to be at top most and below this the function to be running and when using Printf the output is-
Screenshot from 2024-02-11 23-41-05

and when i create separate method for API line the output is-
Screenshot from 2024-02-11 23-41-29

My end goal is to keep the spinner at top most and everything below it and if i use the common Printf and add a new line in that then all the lines will have a new line..

Please correct me if i am wrong

Comment on lines 36 to 37
spinner := NewSpinner(os.Stdout)
spinner.Start()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of having the spinner start here, I'd like to see it moved just around where we get the pod logs, that's by far the most significant stretch of time a user would be looking for input on if the command is running or has stopped/frozen/exited.

Instead of running NewSpinner and Start here in PrintInfo, lets move it to root.go and wrap the PrintE2ELogs function, like:

spinner := common.NewSpinner(os.Stdout)
spinner.Start()
client.PrintE2ELogs()
spinner.Stop()

Copy link
Member Author

@Bharadwajshivam28 Bharadwajshivam28 Feb 11, 2024

Choose a reason for hiding this comment

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

can you please expand this? sorry i not got it..

I created a separate file for spinner in common directory so are you saying me to move the start method in the root.go file? and use the method created in root.go in the file args.go file?

@@ -87,3 +94,102 @@ func ValidateArgs() error {
}
return nil
}

var spinnerFrames = []string{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Lets move all this code for the spinner to a new spinner.go file, I'm alright with leaving it in the common package for now. Eventually we might want to move it to a utils or cli package.

Copy link
Member Author

Choose a reason for hiding this comment

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

okay let me make the changes..

Comment on lines 129 to 139
func (s *Spinner) SetPrefix(prefix string) {
s.mu.Lock()
defer s.mu.Unlock()
s.prefix = prefix
}

func (s *Spinner) SetSuffix(suffix string) {
s.mu.Lock()
defer s.mu.Unlock()
s.suffix = suffix
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are these methods used? If not, let's remove them.

Copy link
Member Author

Choose a reason for hiding this comment

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

oh not saw these.. let me fix it

Comment on lines 185 to 195
func (s *Spinner) Write(p []byte) (n int, err error) {
s.mu.Lock()
defer s.mu.Unlock()
if !s.running {
return s.writer.Write(p)
}
if _, err := s.writer.Write([]byte("\r")); err != nil {
return 0, err
}
return s.writer.Write(p)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this method needed? If not, lets remove it.

@Bharadwajshivam28
Copy link
Member Author

Hey @rjsadow I made the changes suggested by you..

@rjsadow
Copy link
Collaborator

rjsadow commented Feb 15, 2024

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 15, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Bharadwajshivam28, rjsadow

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 Feb 15, 2024
@k8s-ci-robot k8s-ci-robot merged commit 94e1d49 into kubernetes-sigs:main Feb 15, 2024
6 of 7 checks passed
@Bharadwajshivam28 Bharadwajshivam28 deleted the Spinner branch February 16, 2024 00:34
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. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants