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

Introduce logverbose tag for test cases #1054

Merged
merged 13 commits into from
Jun 7, 2018
Merged

Introduce logverbose tag for test cases #1054

merged 13 commits into from
Jun 7, 2018

Conversation

jessiezcc
Copy link
Contributor

update err msg with both expected and actual state

@jessiezcc jessiezcc requested a review from adrcunha June 5, 2018 00:16
@google-prow-robot google-prow-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jun 5, 2018
@@ -93,10 +97,10 @@ func TestContainerErrorMsg(t *testing.T) {
t.Fatalf("Failed to get logUrl from revision %s: %v", revisionName, err)
}

// TODO(jessiezcc@): actually validate the logURL, but requires kibana setup
// TODO(jessiezcc): actually validate the logURL, but requires kibana setup
log.Printf("LogURL: %s", logURL)
Copy link
Contributor

Choose a reason for hiding this comment

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

I mentioned about this log message causing noise in the output, please consider addressing it in this PR.

log.Printf("LogURL: %s", logURL)

// TODO(jessiezcc@): add the check to validate that Route is not marked as ready once https://github.com/elafros/elafros/issues/990 is fixed
// TODO(jessiezcc): add the check to validate that Route is not marked as ready once https://github.com/elafros/elafros/issues/990 is fixed
}

// Get revision name from configuration.
Copy link
Contributor

Choose a reason for hiding this comment

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

Please also consider fixing the comments of the functions in this PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nevermind, this are not public method anymore.

@knative-metrics-robot
Copy link

The following is the coverage report on pkg/. Say /test pull-knative-serving-go-coverage to run the coverage report again

File Old Coverage New Coverage Delta

*TestCoverage feature is being tested, do not rely on any info here yet

@adrcunha
Copy link
Contributor

adrcunha commented Jun 5, 2018

/test pull-knative-serving-integration-tests

@google-prow-robot google-prow-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jun 5, 2018
@knative-metrics-robot
Copy link

The following is the coverage report on pkg/. Say /test pull-knative-serving-go-coverage to run the coverage report again

File Old Coverage New Coverage Delta

*TestCoverage feature is being tested, do not rely on any info here yet

}

// VerboseGLog outputs verbose logging with defined logleve 10.
func VerboseGLog(s string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not simply Debug?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

would like to go with log level so that u can get all logs coming out of k8s libs as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean calling the method "Debug", just for simplicity sake.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah, how about Verbose()? Debug is usually meant to be a build flavor, RTL vs. DBG

if *boolPtr {
flag.Set("alsologtostderr", fmt.Sprintf("%t", true))
var logLevel string
flag.StringVar(&logLevel, "logLevel", "10", "verbose log level")
Copy link
Contributor

Choose a reason for hiding this comment

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

If you're going this path, I suggest defining a constant for the "verbose" output and sticking to it in all the related code.

@bobcatfish I didn't check glog, is it the best approach? I confess I was expecting something simpler to use...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that's the reason that I'm wrapping verbose log in a function to be called by TC.
started with constant, however, couldn't get gLog.V() to work, hence the function.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I don't follow. I understand the initialization and the use of V(), but I fail to understand the relation to the wrapping (which I like) and not being able to use a constant for V().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will explain f2f when u are back to desk, easier that way

@@ -58,3 +60,21 @@ func initializeFlags() *EnvironmentFlags {

return &f
}

func init() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason to not initialize these flags in initializeFlags()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No particular reason, can merge into initializeFlags.

@@ -58,3 +60,21 @@ func initializeFlags() *EnvironmentFlags {

return &f
}

func init() {
boolPtr := flag.Bool("logVerbose", false, "a bool")
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm pretty sure Christie would love seeing "a bool" turned into a way more descriptive text about this flag. :D

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep, definitely

Copy link
Contributor

@adrcunha adrcunha Jun 6, 2018

Choose a reason for hiding this comment

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

a) Can you do it here? :)

b) Flag usage in the other files use the "test.Flags." aproach, which is cleaner. Can't you use that?

[jessie] fix and pushed

flag.Parse()

if *boolPtr {
flag.Set("alsologtostderr", fmt.Sprintf("%t", true))
Copy link
Contributor

Choose a reason for hiding this comment

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

flag.Set("alsologtostderr", "true")

Interesting, I thought glog would output directly to stdout/stderr by default.

Copy link
Contributor

@adrcunha adrcunha Jun 6, 2018

Choose a reason for hiding this comment

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

Looks like I wasn't clear here: replace fmt.Sprintf() with just "true".

[jessie] fixed

var logLevel string
flag.StringVar(&logLevel, "logLevel", "10", "verbose log level")
flag.Lookup("v").Value.Set(logLevel)
glog.Info("logVerbose %v", boolPtr)
Copy link
Contributor

Choose a reason for hiding this comment

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

boolPtr will be always true here. What about simply

glog.Info("Logging set to verbose mode")

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will do

@adrcunha
Copy link
Contributor

adrcunha commented Jun 6, 2018

I like the (simple) wrapping approach because it requires less boilerplate code, thus there're (fewer) excuses for not logging things appropriately.

@jessiezcc
Copy link
Contributor Author

@bobcatfish, are you ok with function approach? Test case will call test.Verbose(...) .
If we are all in agreement with function, I will go ahead update the doc.

@jessiezcc
Copy link
Contributor Author

also @adrcunha, @bobcatfish , are you fine with 2 PRs approach:
First PR to introduce verbose flag and function, call verbose function from error condition test case and relevant doc changes.
Second PR to switch all test logs from log to glog, and relevant doc changes.

flag.Lookup("v").Value.Set(logLevel)
glog.Info("logVerbose %v", boolPtr)
glog.Infof("Logging set to verbose mode with logleve %d", VerboseLogLevel)
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: logLevel

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

@adrcunha adrcunha Jun 6, 2018

Choose a reason for hiding this comment

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

Looks like you missed the typo. :)

[Jessie] also fixed

boolPtr := flag.Bool("logVerbose", false, "a bool")
flag.Parse()

if *boolPtr {
flag.Set("alsologtostderr", fmt.Sprintf("%t", true))
var logLevel string
flag.StringVar(&logLevel, "logLevel", "10", "verbose log level")
flag.StringVar(&logLevel, "logLevel", fmt.Sprint(VerboseLogLevel), "verbose log level")
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: Sprintf

Would string() work here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tried string, didn't work

// VerboseGLog outputs verbose logging with defined logleve 10.
func VerboseGLog(s string) {
glog.V(10).Infof(s)
// Verbose outputs verbose logging with defined logleve 10.
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: logLevel

But I would replace "logLevel 10" with "VerboseLogLevel".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -58,3 +60,21 @@ func initializeFlags() *EnvironmentFlags {

return &f
}

func init() {
boolPtr := flag.Bool("logVerbose", false, "a bool")
Copy link
Contributor

@adrcunha adrcunha Jun 6, 2018

Choose a reason for hiding this comment

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

a) Can you do it here? :)

b) Flag usage in the other files use the "test.Flags." aproach, which is cleaner. Can't you use that?

[jessie] fix and pushed

flag.Parse()

if *boolPtr {
flag.Set("alsologtostderr", fmt.Sprintf("%t", true))
Copy link
Contributor

@adrcunha adrcunha Jun 6, 2018

Choose a reason for hiding this comment

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

Looks like I wasn't clear here: replace fmt.Sprintf() with just "true".

[jessie] fixed

flag.Lookup("v").Value.Set(logLevel)
glog.Info("logVerbose %v", boolPtr)
glog.Infof("Logging set to verbose mode with logleve %d", VerboseLogLevel)
Copy link
Contributor

@adrcunha adrcunha Jun 6, 2018

Choose a reason for hiding this comment

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

Looks like you missed the typo. :)

[Jessie] also fixed

@jessiezcc
Copy link
Contributor Author

/retest

@adrcunha
Copy link
Contributor

adrcunha commented Jun 6, 2018

/lgtm
/approve

@google-prow-robot google-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 6, 2018
@google-prow-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: adrcunha, jessiezcc

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

Copy link
Contributor

@bobcatfish bobcatfish left a comment

Choose a reason for hiding this comment

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

imo if you also update the e2e scripts so that they enable verbose logging, we can resolve #763 as well :D

var logLevel string
flag.StringVar(&logLevel, "logLevel", fmt.Sprint(VerboseLogLevel), "verbose log level")
flag.Lookup("v").Value.Set(logLevel)
glog.Infof("Logging set to verbose mode with logLevel %d", VerboseLogLevel)
Copy link
Contributor

Choose a reason for hiding this comment

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

cool!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will need to update doc, will include changes for #763 as well.

@bobcatfish
Copy link
Contributor

@bobcatfish, are you ok with function approach? Test case will call test.Verbose(...) .
If we are all in agreement with function, I will go ahead update the doc.

I still have a different opinion on this but I don't feel strongly! I say go ahead with it and we can see how it turns out, wouldn't be hard to change later if we change our minds.

@jessiezcc jessiezcc changed the title update err msg with both expected and actual state Introduce logverbose tag for test cases Jun 6, 2018
@jessiezcc
Copy link
Contributor Author

/retest

@google-prow-robot google-prow-robot merged commit 0957785 into knative:master Jun 7, 2018
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. lgtm Indicates that a PR is ready to be merged. 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.

5 participants