Skip to content

Conversation

@jackdcasey
Copy link
Contributor

@jackdcasey jackdcasey commented Dec 29, 2019

Test-Connection: Increase output detail when performing a tcp test

These changes provide more detail when using Test-Connection cmdlet with the -TCPPort option. This will provide functionality more in line with the ping test, and the classic Test-NetConnection cmdlet.

Currently, the returned value when performing this test is a boolean true / false. This provides some insight into if the connection was successful but not much else.

Here's the current output:

Test-Connection google.com -TCPPort 443

True

Here is an example of the same command, with the changes:

Test-Connection google.com -TCPPort 443

   Destination: google.com

Test Source           Destination      DestinationAddress    Port Latency Result
                                                                     (ms)
---- ------           -----------      ------------------    ---- ------- ------
   1 Jacks-MBP        google.com       172.217.3.174          443      15 Success

The -Count and -Repeat options are also implemented, as seen below:

Test-Connection google.com -TCPPort 443 -Count 4

   Destination: google.com

Test Source           Destination      DestinationAddress    Port Latency Result
                                                                     (ms)
---- ------           -----------      ------------------    ---- ------- ------
   1 Jacks-MBP        google.com       172.217.3.174          443      13 Success
   2 Jacks-MBP        google.com       172.217.3.174          443      10 Success
   3 Jacks-MBP        google.com       172.217.3.174          443      16 Success
   4 Jacks-MBP        google.com       172.217.3.174          443      16 Success
Test-Connection google.com -TCPPort 443 -Repeat 

   Destination: google.com

Test Source           Destination      DestinationAddress    Port Latency Result
                                                                     (ms)
---- ------           -----------      ------------------    ---- ------- ------
   1 Jacks-MBP        google.com       172.217.3.174          443      15 Success
   2 Jacks-MBP        google.com       172.217.3.174          443      15 Success
   3 Jacks-MBP        google.com       172.217.3.174          443      10 Success
   4 Jacks-MBP        google.com       172.217.3.174          443      16 Success
   5 Jacks-MBP        google.com       172.217.3.174          443      16 Success
   6 Jacks-MBP        google.com       172.217.3.174          443      15 Success
   7 Jacks-MBP        google.com       172.217.3.174          443      18 Success
   8 Jacks-MBP        google.com       172.217.3.174          443      16 Success
   9 Jacks-MBP        google.com       172.217.3.174          443      16 Success
  10 Jacks-MBP        google.com       172.217.3.174          443      17 Success
   ...

To provide a boolean output, the -Quiet option is used:

Test-Connection google.com -TCPPort 443 -Quiet

True

Most of the code changes are implementing a new TcpTestStatus class to facilitate the output. A few changes to existing code to implement the existing switches.

PR Context

This opens up a lot more functionality with Test-Connection when working with TCP. Often, while working on connectivity issues, we need more detail than just if the connection is established, or not.

These changes should provide much of the fundamental TCP functionality from the classic Test-NetConnection.

PR Checklist

Fix: #11440

@msftclas
Copy link

msftclas commented Dec 29, 2019

CLA assistant check
All CLA requirements met.

Copy link
Collaborator

@vexx32 vexx32 left a comment

Choose a reason for hiding this comment

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

Great work here!

A few minor things I think we should address but on the whole this looks like a great improvement 😊

@ghost ghost added the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Dec 29, 2019
@ghost ghost removed the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Dec 29, 2019
Copy link
Collaborator

@vexx32 vexx32 left a comment

Choose a reason for hiding this comment

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

Couple smaller things I noticed on a re-read. 🙂

@adityapatwardhan adityapatwardhan removed this from the 7.1.0-preview.4 milestone Jun 29, 2020
@ghost ghost added the Review - Needed The PR is being reviewed label Jul 7, 2020
@ghost
Copy link

ghost commented Jul 7, 2020

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

@jackdcasey
Copy link
Contributor Author

@SteveL-MSFT Thank you for the update!

I've made the changes to implement the parameter sets you've described. As mentioned, the default return with -TCPPort will be boolean, and will be an object if using -Detailed, -Repeat, and -Count.

Please let me know if these changes align with what's expected 😁

@jackdcasey
Copy link
Contributor Author

Commenting to bump, is there anything else required to merge these changes? I'm very excited to move things forward!

@pull-request-quantifier-deprecated

This PR has 144 quantified lines of changes. In general, a change size of upto 200 lines is ideal for the best PR experience!


Quantification details

Label      : Medium
Size       : +126 -18
Percentile : 48.8%

Total files changed: 3

Change summary by file extension:
.cs : +98 -17
.ps1 : +28 -1

Change counts above are quantified counts, based on the PullRequestQuantifier customizations.

Why proper sizing of changes matters

Optimal pull request sizes drive a better predictable PR flow as they strike a
balance between between PR complexity and PR review overhead. PRs within the
optimal size (typical small, or medium sized PRs) mean:

  • Fast and predictable releases to production:
    • Optimal size changes are more likely to be reviewed faster with fewer
      iterations.
    • Similarity in low PR complexity drives similar review times.
  • Review quality is likely higher as complexity is lower:
    • Bugs are more likely to be detected.
    • Code inconsistencies are more likely to be detetcted.
  • Knowledge sharing is improved within the participants:
    • Small portions can be assimilated better.
  • Better engineering practices are exercised:
    • Solving big problems by dividing them in well contained, smaller problems.
    • Exercising separation of concerns within the code changes.

What can I do to optimize my changes

  • Use the PullRequestQuantifier to quantify your PR accurately
    • Create a context profile for your repo using the context generator
    • Exclude files that are not necessary to be reviewed or do not increase the review complexity. Example: Autogenerated code, docs, project IDE setting files, binaries, etc. Check out the Excluded section from your prquantifier.yaml context profile.
    • Understand your typical change complexity, drive towards the desired complexity by adjusting the label mapping in your prquantifier.yaml context profile.
    • Only use the labels that matter to you, see context specification to customize your prquantifier.yaml context profile.
  • Change your engineering behaviors
    • For PRs that fall outside of the desired spectrum, review the details and check if:
      • Your PR could be split in smaller, self-contained PRs instead
      • Your PR only solves one particular issue. (For example, don't refactor and code new features in the same PR).

How to interpret the change counts in git diff output

  • One line was added: +1 -0
  • One line was deleted: +0 -1
  • One line was modified: +1 -1 (git diff doesn't know about modified, it will
    interpret that line like one addition plus one deletion)
  • Change percentiles: Change characteristics (addition, deletion, modification)
    of this PR in relation to all other PRs within the repository.


Was this comment helpful? 👍  :ok_hand:  :thumbsdown: (Email)
Customize PullRequestQuantifier for this repository.

@TravisEz13
Copy link
Member

/azp run PowerShell-CI-windows

@ghost ghost removed the Review - Needed The PR is being reviewed label May 13, 2022
@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ghost ghost added the Review - Needed The PR is being reviewed label May 21, 2022
@ghost
Copy link

ghost commented May 21, 2022

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

@TravisEz13 TravisEz13 merged commit 698742e into PowerShell:master May 1, 2023
@ghost ghost removed the Review - Needed The PR is being reviewed label May 1, 2023
@sdwheeler
Copy link
Collaborator

@TravisEz13 The documentation for this cmdlet needs to be updated. Please file a docs issue.
cc: @SteveL-MSFT

@sdwheeler sdwheeler added the PowerShell-Docs needed The PR was reviewed and a PowerShell Docs update is needed label Jun 1, 2023
@ghost
Copy link

ghost commented Jun 29, 2023

🎉v7.4.0-preview.4 has been released which incorporates this pull request.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-BreakingChange Indicates that a PR should be marked as a breaking change in the Change Log CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log Committee-Reviewed PS-Committee has reviewed this and made a decision Medium PowerShell-Docs needed The PR was reviewed and a PowerShell Docs update is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Increase output detail of Test-Connection when performing a tcp connection test