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

integ-cli: remove ICMP dependency from test, use nslookup #11310

Merged
merged 1 commit into from Mar 11, 2015

Conversation

Projects
None yet
10 participants
@ahmetb
Contributor

ahmetb commented Mar 11, 2015

As we started running CI machines on Azure cloud and Azure
doesn't have ICMP stack implemented (yes, you heard right)
replacing ping 8.8.8.8 with nslookup google.com.

Signed-off-by: Ahmet Alp Balkan ahmetalpbalkan@gmail.com
cc: @tianon @jfrazelle @icecrime

if err != nil {
t.Fatalf("failed to run container: %v, output: %q", err, out)
t.Fatalf("failed to run container: %v, exitCode=%d, output: %q", err, ec, out)

This comment has been minimized.

@tiborvass

tiborvass Mar 11, 2015

Collaborator

@ahmetalpbalkan you won't like my comment but the exitCode is redundant since err will contain the exitcode in its message.

This comment has been minimized.

@ahmetb

ahmetb Mar 11, 2015

Contributor

This cmd actially exits with no msg or output. So if we keep the command like this exitCode is necessary.

This comment has been minimized.

@tiborvass

tiborvass Mar 11, 2015

Collaborator

@ahmetalpbalkan if we do nslookup google.com can we remove exit code?

This comment has been minimized.

@ahmetb

ahmetb Mar 11, 2015

Contributor

@tiborvass yeah.

defer deleteAllContainers()
runCmd := exec.Command(dockerBinary, "run", "busybox", "ping", "-c", "1", "8.8.8.8")
out, _, _, err := runCommandWithStdoutStderr(runCmd)
runCmd := exec.Command(dockerBinary, "run", "busybox", "sh", "-c", `[[ -n "$(nslookup 8.8.8.8 | grep google.com)" ]]`)

This comment has been minimized.

@tiborvass

tiborvass Mar 11, 2015

Collaborator

I don't have a strong opinion on this. Could be just nslookup 8.8.8.8 or you can verify its indeed google's IP I don't mind. Others?

This comment has been minimized.

@icecrime

icecrime Mar 11, 2015

Contributor

I would personally simplify this as exec.Command(dockerBinary, "run", "--rm", "busybox", "nslookup", "8.8.8.8") and test the exit code from that (and eventually if !strings.Contains(out, "google.com") { ...).

This comment has been minimized.

@tianon

tianon Mar 11, 2015

Member

Why using [[ -n instead of just grep -q and exit codes?

This comment has been minimized.

@tianon

tianon Mar 11, 2015

Member

or even simpler, doing the nslookup by itself with no shell, and doing the "search for google.com" in Go?

This comment has been minimized.

@tianon

tianon Mar 11, 2015

Member

Doh, GitHub didn't load comments -- or what @icecrime said, which is even simpler. 👍

This comment has been minimized.

@ahmetb

ahmetb Mar 11, 2015

Contributor

@icecrime because "nslookup 8.8.8.8" doesnt exit with a nonzero code even when network is not present. It's still successful but doesn't contain "google.com" string in the output. @tianon

This comment has been minimized.

@tiborvass

tiborvass Mar 11, 2015

Collaborator

@ahmetalpbalkan then let's use grep -q

integ-cli: remove ICMP dependency from test, use nslookup
As we started running CI machines on Azure cloud and Azure
doesn't have ICMP stack implemented by replacing
`ping 8.8.8.8` with `nslookup google.com`.

Signed-off-by: Ahmet Alp Balkan <ahmetalpbalkan@gmail.com>
@ahmetb

This comment has been minimized.

Contributor

ahmetb commented Mar 11, 2015

@tiborvass @tianon updated to use nslookup google.com, it is much simpler now.

@jessfraz

This comment has been minimized.

Contributor

jessfraz commented Mar 11, 2015

LGTM

1 similar comment
@tiborvass

This comment has been minimized.

Collaborator

tiborvass commented Mar 11, 2015

LGTM

tiborvass added a commit that referenced this pull request Mar 11, 2015

Merge pull request #11310 from ahmetalpbalkan/win-cli/ping-icmp
integ-cli: remove ICMP dependency from test, use nslookup

@tiborvass tiborvass merged commit d6a6c7d into moby:master Mar 11, 2015

1 check passed

janky Jenkins build Docker-PRs 3141 has succeeded
Details
// this will fail when Internet access is unavailable
func TestRunPingGoogle(t *testing.T) {
func TestRunLookupGoogleDns(t *testing.T) {

This comment has been minimized.

@dmitshur

dmitshur Jun 16, 2016

Contributor

This is a really minor issue, but Dns should be DNS here.

My source is that the Docker coding style document says:

  1. All code should follow the guidelines covered in Effective Go and Go Code Review Comments.

Which has a section on initialisms at https://github.com/golang/go/wiki/CodeReviewComments#initialisms:

Words in names that are initialisms or acronyms (e.g. "URL" or "NATO") have a consistent case. For example, "URL" should appear as "URL" or "url" (as in "urlPony", or "URLPony"), never as "Url". Here's an example: ServeHTTP not ServeHttp.

Though I can see this file has multiple other instances of Dns instead of DNS, so this is probably a wide spread issue that is best addressed at scale.

This comment has been minimized.

@thaJeztah

thaJeztah Jun 17, 2016

Member

@shurcooL If you want to contribute and open a PR to update, please do! 👍

mavenugo added a commit to mavenugo/docker that referenced this pull request Jun 29, 2016

integration-cli: Change "Dns" to "DNS".
This fixes a minor lint/style issue, improves consistency.

According to Go style, which this project follows, acronyms should have
a consistent case. Source: https://github.com/golang/go/wiki/CodeReviewComments#initialisms

See moby#11310 (comment).

Signed-off-by: Dmitri Shuralyov <shurcooL@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment