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

[Monitor] Fixing issue #3957: bug in Get-AzureRmLog cmdlet, returning… #4066

Merged
merged 7 commits into from
Jun 26, 2017

Conversation

gucalder
Copy link
Contributor

@gucalder gucalder commented Jun 2, 2017

#4056

Description

  • Fixing issue Get-AzureRmLog maxevents not honored #3957: bug in Get-AzureRmLog cmdlet, returning at most 200 records despite of MaxEvents.
  • Adding an alias to the MaxEvents parameter, i.e.: MaxRecords.
  • Fixing documentation for this command.

This checklist is used to make sure that common guidelines for a pull request are followed. You can find a more complete discussion of PowerShell cmdlet best practices here.

General Guidelines

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.
  • The pull request does not introduce breaking changes (unless a major version change occurs in the assembly and module).

Testing Guidelines

  • Pull request includes test coverage for the included changes.
  • PowerShell scripts used in tests should do any necessary setup as part of the test or suite setup, and should not use hard-coded values for locations or existing resources.

Cmdlet Signature Guidelines

  • New cmdlets that make changes or have side effects should implement ShouldProcess and have SupportShouldProcess=true specified in the cmdlet attribute. You can find more information on ShouldProcess here.
  • Cmdlet specifies OutputType attribute if any output is produced - if the cmdlet produces no output, it should implement a PassThru parameter.

Cmdlet Parameter Guidelines

  • Parameter types should not expose types from the management library - complex parameter types should be defined in the module.
  • Complex parameter types are discouraged - a parameter type should be simple types as often as possible. If complex types are used, they should be shallow and easily creatable from a constructor or another cmdlet.
  • Cmdlet parameter sets should be mutually exclusive - each parameter set must have at least one mandatory parameter not in other parameter sets.

…rning at most 200 records despite of MaxEvents
Copy link
Member

@cormacpayne cormacpayne left a comment

Choose a reason for hiding this comment

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

@gucalder can you add a test to verify this bug fix?

[ValidateNotNullOrEmpty]
public virtual int MaxEvents { get; set; }
public virtual int MaxRecords { get; set; }
Copy link
Member

Choose a reason for hiding this comment

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

@gucalder any reason for the parameter name change?

jagadisk
jagadisk previously approved these changes Jun 2, 2017
Copy link
Member

@markcowl markcowl left a comment

Choose a reason for hiding this comment

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

Need a test for this, and need to update the changelog.md to describe the fix

@cormacpayne
Copy link
Member

@gucalder Hey Guillermo, is this PR ready for review?

@gucalder
Copy link
Contributor Author

Now it should be ready for review.

Copy link
Member

@cormacpayne cormacpayne left a comment

Choose a reason for hiding this comment

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

@gucalder Hey Guillermo, just a couple of quick clarifying questions

this.MaxEvents = value;
}
// If value is not acceptable this forces the use of the default value
this.MaxRecords = (value > 0 && value <= 100000) ? value : 0;
Copy link
Member

Choose a reason for hiding this comment

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

@gucalder in the change log, you mentioned

Any value for MaxEvents that is less than 1 is ignored and the default is used instead

and that the default value is 1000. However, here you are setting the value to 0. If this is setting something different, ignore this comment 😄

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 know it is odd.
There are historic reasons to do it that way. They have to do with the fact that this part of the code is shared by two other cmdlets where MaxEvents is not defined as a parameter, and also MaxEvents was added later.
Anyway this is one thing that I might change later to make it a bit less confusing.

Copy link
Member

Choose a reason for hiding this comment

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

@gucalder just to make sure I understand, does the MaxEvent value get set to 1000 somewhere else (by default), or is the description in the change log incorrect?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, MaxEvent is assigned 1000 somewhere else.

.SYNOPSIS
Tests getting the logs for a subscription Id.
#>
function Test-GetAzureSubscriptionIdLogMaxEvents
Copy link
Member

Choose a reason for hiding this comment

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

@gucalder are these the tests containing the pages of size 10 that return 15 elements? (the test you mentioned in the email)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that is one of the places where this is tested.
This is another scenario test for that. NOTE: the page here is set to 6 records, but the are 8 records in total.
Test-GetAzureSubscriptionIdLogPaged (same file as Test-GetAzureSubscriptionIdLogMaxEvents)

This is another place, the unit test below. Here the first page is 10 records and the second 5.
GetAzureSubscriptionIdLogCommandParametersProcessing()

I added more comments to clarify the goal of the individual tests and also added more cases to the existing scenario tests.

…their goal and adding some more cases to the tests.
@cormacpayne cormacpayne dismissed markcowl’s stale review June 26, 2017 16:50

Tests and change log have been added

@cormacpayne cormacpayne merged commit 9877237 into Azure:preview Jun 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants