Solved: Issue found in end-to-end-testing golang error: dial tcp: lookup "<ip>": no such host
- Dominant language
- HCL
- Stars
- 925
- Forks
- 930
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 5
Description
### Is there an existing issue for this?
- [X] I have searched the existing issues
### Example Name
https://github.com/Azure/terraform/blob/master/samples/end-to-end-testing/src/test/end2end_test.go#L78
### Terraform Version
1.3.8
### Current Behavior
@jcorioland
There is an issue when the code generates the connection to the public ip.
In the following line, it tries to connect to the public ip address:
[https://github.com/Azure/terraform/blob/master/samples/end-to-end-testing/src/test/end2end_test.go#L78](url)
After several days of troubleshooting the code, I found that it fails because the variable not only contains the ip address, but it also includes double quotes around the ip address, this makes it fail.
### Expected Behavior
Finally fixed it by using the following change:
```
//sshConnection, err := ssh.Dial("tcp", fmt.Sprintf("%s:22", vmLinux1PublicIPAddress), sshConfig)
sshConnection, err := ssh.Dial("tcp", fmt.Sprintf("%s:22", strings.Trim(vmLinux1PublicIPAddress, "\"")), sshConfig)
```
Once that adjustment was done, the code worked!
### Steps To Reproduce
cd /c/git/terraform/samples/end-to-end-testing/src/test
az login --use-device-code
az account set --subscription Playground
cd ~/.ssh
ssh-keygen.exe #This is in test, not definitive yet: -m PEM
make sure id_rsa and id_rsa.pub were created
ls -l ~/.ssh/id_rsa*
export TEST_SSH_KEY_PATH="~/.ssh/id_rsa"
cd /c/git/terraform/samples/end-to-end-testing/src/test
go mod download github.com/gruntwork-io/terratest
go mod download github.com/Azure/go-autorest/autorest
go mod tidy -e
go test -v ./ -timeout 10m
### Anything else?
_No response_
Contributor guide
No contributing guide indexed for this repository
Research direction
The issue points to samples/end-to-end-testing/src/test/end2end_test.go:78; start by reading the SSH connection setup and the reported public-IP value. Run the listed go test command after reproducing the setup, and consider the issue done when the end-to-end test connects successfully without the lookup error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 25/100