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

Adding tests for Service Fabric commands and fixing some arugment parsing logic #3424

Merged
merged 21 commits into from
Jun 8, 2017

Conversation

samedder
Copy link
Contributor

New changes for Service Fabric:

  • Unit tests for components related to argument validation for custom commands in Service Fabric module.
  • Several fixes for commands that were previously too restrictive when validating arguments
  • VCR Recordings for some commands that do not fall into the previous unit testing category
  • Refactor SF configuration into it's own class, for mock-ability

@codecov-io
Copy link

codecov-io commented May 23, 2017

Codecov Report

Merging #3424 into master will increase coverage by 0.49%.
The diff coverage is 52.05%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3424      +/-   ##
==========================================
+ Coverage   71.62%   72.12%   +0.49%     
==========================================
  Files         420      422       +2     
  Lines       26209    26289      +80     
  Branches     3968     3977       +9     
==========================================
+ Hits        18773    18961     +188     
+ Misses       6258     6112     -146     
- Partials     1178     1216      +38
Impacted Files Coverage Δ
...zure-cli-sf/azure/cli/command_modules/sf/config.py 33.33% <33.33%> (ø)
...zure-cli-sf/azure/cli/command_modules/sf/custom.py 40.53% <52.84%> (+30.73%) ⬆️
...re-cli-sf/azure/cli/command_modules/sf/_factory.py 88.23% <84.61%> (+82.67%) ⬆️
...ice/azure/cli/command_modules/appservice/custom.py 73.3% <0%> (-0.37%) ⬇️
...s/azure-cli-interactive/azclishell/az_completer.py 59.9% <0%> (-0.19%) ⬇️
...yvault/azure/cli/command_modules/keyvault/_help.py 100% <0%> (ø) ⬆️
...li-lab/azure/cli/command_modules/lab/validators.py 34.11% <0%> (ø) ⬆️
...i-cloud/azure/cli/command_modules/cloud/_params.py 93.33% <0%> (ø) ⬆️
...cli-find/azure/cli/command_modules/find/_params.py 100% <0%> (ø) ⬆️
...skhelp/azure/cli/command_modules/taskhelp/_help.py 100% <0%> (ø) ⬆️
... and 24 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 14cd4ed...9aa5725. Read the comment docs.

Copy link
Contributor

@troydai troydai left a comment

Choose a reason for hiding this comment

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

Looks good besides a few minor issues. Please rebase your change to the latest master. We've updated pylint.

if using_ca == "True":
return self.az_config.get("servicefabric", "ca_path", fallback=None)
else:
return None
Copy link
Contributor

Choose a reason for hiding this comment

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

Per Pylint 1.7.1

        if using_ca == "True":
             return self.az_config.get("servicefabric", "ca_path", fallback=None)

        return None

@@ -34,7 +34,8 @@
DEPENDENCIES = [
'azure-servicefabric==5.6.130',
'azure-cli-core',
'adal>=0.4.3'
'adal>=0.4.3',
'mock==2.0.0'
Copy link
Contributor

Choose a reason for hiding this comment

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

mock>=2.0.0 do not fix version in setup. We want the user to be able to patch a dependency. And why do we need mock in the production code? It is a testing utility.

@@ -3,6 +3,7 @@
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
# pylint: disable=too-many-lines
# pylint: disable=too-many-locals
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you mark this disable statement to the function where it is needed? It is not encouraged to disable a pylint rule for the scope of the entire file.



def parse_app_metrics(formatted_metrics):
from azure.servicefabric.models.application_metric_description import (
Copy link
Contributor

Choose a reason for hiding this comment

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

The parentheses don't seem to be necessary.

NamedPartitionSchemeDescription
)
# pylint: disable=line-too-long
from azure.servicefabric.models.singleton_partition_scheme_description import ( # noqa: justification, no way to shorten
Copy link
Contributor

Choose a reason for hiding this comment

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

# noqa is not needed.

@troydai
Copy link
Contributor

troydai commented May 31, 2017

Please also take into the account that the line limitation is 120 instead if 100 now.

@troydai
Copy link
Contributor

troydai commented Jun 1, 2017

ping @samedder

@samedder
Copy link
Contributor Author

samedder commented Jun 1, 2017

@troydai. On vacation currently, can this wait till next week? I agree with all your comments.

@troydai
Copy link
Contributor

troydai commented Jun 1, 2017

@samedder sure. no hurry. enjoy your vacation.

@troydai
Copy link
Contributor

troydai commented Jun 7, 2017

@samedder please update the pull request when you have time.

@samedder
Copy link
Contributor Author

samedder commented Jun 7, 2017

@troydai will get to this tommorrow

Copy link
Contributor

@troydai troydai left a comment

Choose a reason for hiding this comment

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

Looks good to me overall. Please the only comments about dependency version and this is good to go.

@@ -35,7 +35,7 @@
'azure-servicefabric==5.6.130',
Copy link
Contributor

Choose a reason for hiding this comment

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

In the setup, the version of the dependencies shouldn't be pinned. Otherwise it will prevents user from applying patch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We want to specifically pin this because we don't want to users to auto-upgrade at this time. I know we have pending work to move into our own CLI, so for the time being I'd just like to leave this as-is, since this version won't change until then anyways. Lets discuss over email what's the right thing to do with others.

endpoint = sf_get_connection_endpoint()
def cf_sf_client(_):
sf_config = SfConfigParser()
endpoint = sf_config.connection_endpoint()
if endpoint is None:
Copy link
Contributor

Choose a reason for hiding this comment

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

if not endpoint:

Unless endpoint == '' as any special meaning and should be accepted.


def ca_cert_info(self):
using_ca = self.az_config.get("servicefabric", "use_ca", fallback="False")
if using_ca == "True":
Copy link
Contributor

Choose a reason for hiding this comment

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

Just want to make sure that you understand the string comparison is case-sensitive.

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, but since we are the only ones who set these strings we expect with the casing that we set them.

@samedder
Copy link
Contributor Author

samedder commented Jun 8, 2017

@troydai I think we may have a transient fault in the CI:

==== Test module dls ====
No output has been received in the last 10m0s, this potentially indicates a stalled build or something wrong with the build itself.
Check the details on how to adjust your build configuration on: https://docs.travis-ci.com/user/common-build-problems/#Build-times-out-because-no-output-was-received

@troydai
Copy link
Contributor

troydai commented Jun 8, 2017

I restart the build. Let's see if the issue persist.

@troydai troydai merged commit 2b563f4 into Azure:master Jun 8, 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.

5 participants