X Tutup
The Wayback Machine - https://web.archive.org/web/20221128204233/https://github.com/PowerShell/PowerShell/pull/11452
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

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

Open
wants to merge 51 commits into
base: master
Choose a base branch
from

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

Great work here!

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

@msftbot msftbot bot added the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Dec 29, 2019
@msftbot msftbot bot 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

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

@sdwheeler
Copy link
Collaborator

sdwheeler commented Jun 18, 2020

@vexx32 The difference between pings and TCP connections is that TCP connections continue to use system resources during the TIME_WAIT state after the connection is closed. So even if there is a throttle on how fast they are created, they will still exist for 4 minutes. See https://docs.microsoft.com/en-us/windows/client-management/troubleshoot-tcpip-port-exhaust

Learn how to troubleshoot port exhaustion issues.

@TravisEz13 TravisEz13 added Review - Committee The PR/Issue needs a review from the PowerShell Committee and removed Committee-Reviewed PS-Committee has reviewed this and made a decision labels Jun 18, 2020
@msftbot msftbot bot removed the Review - Needed The PR is being reviewed label Jun 18, 2020
@TravisEz13
Copy link
Member

TravisEz13 commented Jun 18, 2020

sending back to the committee for #11452 (comment)

@SteveL-MSFT
Copy link
Member

SteveL-MSFT commented Jun 24, 2020

@PowerShell/powershell-committee reviewed this, we are concerned about a breaking change from 7.0 which is an LTS release.

Proposed parameter sets:

Test-Connection -TCPPort <port>
Test-Connection -TCPPort <port> -Detailed
Test-Connection -TCPPort <port> -Count <count>
Test-Connection -TCPPort <port> -Repeat

Therefore, Test-Connection -TCPPort <port> would continue to return a boolean and -Detailed must be specified to return an object.

-Count and -Repeat are likely used interactively so returning objects is fine and can still be handled by automation.

@SteveL-MSFT SteveL-MSFT added Committee-Reviewed PS-Committee has reviewed this and made a decision and removed Review - Committee The PR/Issue needs a review from the PowerShell Committee labels Jun 24, 2020
@adityapatwardhan adityapatwardhan removed this from the 7.1.0-preview.4 milestone Jun 29, 2020
@msftbot msftbot bot added the Review - Needed The PR is being reviewed label Jul 7, 2020
@msftbot
Copy link

msftbot bot 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

jackdcasey commented Jul 9, 2020

@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

jackdcasey commented Sep 10, 2020

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

@pull-request-quantifier
Copy link

pull-request-quantifier bot commented May 12, 2022

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? 👍  👌  👎 (Email)
Customize PullRequestQuantifier for this repository.

@TravisEz13
Copy link
Member

TravisEz13 commented May 13, 2022

/azp run PowerShell-CI-windows

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

azure-pipelines bot commented May 13, 2022

Azure Pipelines successfully started running 1 pipeline(s).

@msftbot
Copy link

msftbot bot 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

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 Review - Needed The PR is being reviewed
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
X Tutup