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

Windows - Cannot run Pact #9

Closed
serinth opened this issue Feb 9, 2017 · 13 comments
Closed

Windows - Cannot run Pact #9

serinth opened this issue Feb 9, 2017 · 13 comments
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@serinth
Copy link

serinth commented Feb 9, 2017

After running the pact release for Windows (v0.0.3) and verifying that the daemon was listening on 6666, the consumer example could not connect to the daemon therefore failing the consumer tests.

pact-go/dsl/client.go
net.Dial and net.DialHttp issues with connecting to localhost. Specifying localhost solved the issue in the server name. This may possibly be linked to IPv6.

After modifying client.go and the daemon logs the connection we have this issue:


2017/02/09 13:50:44 [DEBUG] daemon - starting mock server

2017/02/09 13:50:44 [DEBUG] starting mock service on port: 53215

2017/02/09 13:50:44 [DEBUG] starting service

2017/02/09 13:50:45 [INFO] service: ERROR: "pact-mock-service.rb service" was called with arguments ["--port 53215", "--pact-specification-version 2", "--pact-dir H:\\pact-workshop\\pact-go-consumer\\pacts", "--log H:\\pact-workshop\\pact-go-consumer\\logs/pact.log", "--consumer ui", "--provider ruleservice"]

2017/02/09 13:50:45 [INFO] service: Usage: "pact-mock-service.rb service"

It looks like the pact-mock-service.rb doesn't like Windows paths.

@mefellows mefellows self-assigned this Feb 9, 2017
@mefellows
Copy link
Member

Is there a Vagrant VM you're using for this perchance?

@serinth
Copy link
Author

serinth commented Feb 9, 2017

This was run on Windows 10 Pro with VMWare Fusion.

@serinth
Copy link
Author

serinth commented Feb 9, 2017

On Windows 10 Home (not emulated), I also get this error:

Tony@Home ~/Projects/go/src/github.com/pact-foundation/pact-go/examples (master)
$ ./consumer.exe
2017/02/09 19:03:09 Error on Verify: Post http://localhost:0/interactions: dial tcp [::1]:0: connectex: The requested address is not valid in its context.

The Pact daemon is running on 6666.

@mefellows mefellows added the bug Indicates an unexpected problem or unintended behavior label Feb 12, 2017
@mefellows
Copy link
Member

I'm wondering if perhaps the log path is the issue: H:\\pact-workshop\\pact-go-consumer\\logs/pact.log, note the forward slash in the path.

Looks like the default path for the log file is set at https://github.com/pact-foundation/pact-go/blob/master/dsl/pact.go#L90, and includes a '/' which is probably not portable (I'll fix that if it turns out it's the issue).

Could you please try manually setting the path and seeing if that helps?

@serinth
Copy link
Author

serinth commented Feb 13, 2017

  1. First i modified client.go and changed the Dial and DialHTTP to point to localhost so that it could connect to the Daemon.
  2. Modified the consumer.go file to use DEBUG log level
  3. Modified pact.go and manually specified log file with:
if p.Server == nil {
		p.LogDir = filepath.FromSlash("C:/Users/Tony/Projects/Go/src/github.com/pact-foundation/pact-go/examples/log/pact.log")
		args := []string{
			fmt.Sprintf("--pact-specification-version %d", p.SpecificationVersion),
			fmt.Sprintf("--pact-dir %s", p.PactDir),
			fmt.Sprintf("--log %s", p.LogDir),
			fmt.Sprintf("--consumer %s", p.Consumer),
			fmt.Sprintf("--provider %s", p.Provider),
		}
		client := &PactClient{Port: p.Port}
		p.pactClient = client

		fmt.Println("ARGUMENTS ARE:", args)
		p.Server = client.StartServer(args)
	}

Also printed out the arguments to see what they were:

2017/02/13 11:01:27 [DEBUG] pact setup logging
2017/02/13 11:01:27 [DEBUG] pact setup
ARGUMENTS ARE: [--pact-specification-version 2 --pact-dir C:\Users\Tony\Projects\go\src\github.com\pact-foundation\pact-go\examples\pacts --log C:\Users\Tony\Projects\Go\src\github.com\pact-foundation\pact-go\examples\log\pact.log --consumer MyConsumer --provider MyProvider]
2017/02/13 11:01:27 [DEBUG] client: starting a server
2017/02/13 11:01:27 [DEBUG] creating an HTTP client
2017/02/13 11:01:27 [DEBUG] waiting for port 6666 to become available
2017/02/13 11:01:27 [DEBUG] waiting for port 58166 to become available
2017/02/13 11:01:29 [ERROR] Expected server to start < 1s. Timed out waiting for Mock Server to
                        start on port 58166 - are you sure it's running?
2017/02/13 11:01:29 [DEBUG] pact add interaction
2017/02/13 11:01:29 [DEBUG] pact setup logging
2017/02/13 11:01:29 [DEBUG] pact setup
2017/02/13 11:01:29 [DEBUG] pact add interaction
2017/02/13 11:01:29 [DEBUG] pact setup logging
2017/02/13 11:01:29 [DEBUG] pact setup
2017/02/13 11:01:29 [DEBUG] pact verify
2017/02/13 11:01:29 [DEBUG] mock service add interaction
2017/02/13 11:01:31 Error on Verify: Post http://localhost:58166/interactions: dial tcp [::1]:58166: connectex: No connection could be made because the target machine actively refused it.

Daemon was run with --logLevel DEBUG:

$ ./pact-go_windows_386.exe daemon --logLevel DEBUG
2017/02/13 11:01:21 [DEBUG] setting up a service manager
2017/02/13 11:01:21 [DEBUG] setting up a service manager
2017/02/13 11:01:21 [DEBUG] setting up a service manager
2017/02/13 11:01:21 [DEBUG] setting up a service manager
2017/02/13 11:01:21 [INFO] daemon - starting daemon on port 6666
2017/02/13 11:01:21 [DEBUG] starting service removal monitor
2017/02/13 11:01:21 [DEBUG] starting service creation monitor
2017/02/13 11:01:21 [DEBUG] starting service removal monitor
2017/02/13 11:01:21 [DEBUG] starting service creation monitor
2017/02/13 11:01:21 [DEBUG] starting service creation monitor
2017/02/13 11:01:21 [DEBUG] starting service removal monitor
2017/02/13 11:01:21 method Shutdown has wrong number of ins: 1
2017/02/13 11:01:21 method StartDaemon has wrong number of ins: 2
2017/02/13 11:01:21 [DEBUG] starting service removal monitor
2017/02/13 11:01:21 [DEBUG] starting service creation monitor
2017/02/13 11:01:27 [DEBUG] daemon - starting mock server
2017/02/13 11:01:27 [DEBUG] starting mock service on port: 58166
2017/02/13 11:01:27 [DEBUG] starting service
2017/02/13 11:01:28 [INFO] service: ERROR: "pact-mock-service.rb service" was called with arguments ["--port 58166", "--pact-specification-version 2", "--pact-dir C:\\Users\\Tony\\Projects\\go\\src\\github.com\\pact-foundation\\pact-go\\examples\\pacts", "--log C:\\Users\\Tony\\Projects\\go\\src\\github.com\\pact-foundation\\pact-go\\examples\\log\\pact.log", "--consumer MyConsumer", "--provider MyProvider"]
2017/02/13 11:01:28 [INFO] service: Usage: "pact-mock-service.rb service"

@mefellows
Copy link
Member

Thanks for this @serinth! Might be an issue with the latest mock service or how we provide the arguments to it, I'll dig into it.

Out of interest, can you run the mock service independently of Pact Go? e.g. <path to pact-go>\pact-mock-service\bin\pact-mock-service <args> ?

@mefellows
Copy link
Member

Have verified this issue locally.

@mefellows
Copy link
Member

Update. With your client updates above and also modifying the flags sent to the Ruby Mock Service I have been able to get a successful test case running examples/consumer.go.

The flags must be sent individually, rather than as key-pair combinations (e.g. https://github.com/pact-foundation/pact-go/blob/master/dsl/pact.go#L88-L92) .

I'll continue to look into it this week and find a solution that works nicely for both Windows and non-Windows clients.

@mefellows
Copy link
Member

OK, I just have one remaining issue. When the tests complete, the connection to the Ruby service seems to remain open. The interrupt signal is being received, but Ruby doesn't want to shut down. Need to track down why there is a connection, but I have managed to create a workaround which I'll publish shortly to this branch.

mefellows added a commit that referenced this issue Feb 20, 2017
@mefellows mefellows mentioned this issue Feb 22, 2017
@mefellows
Copy link
Member

I've pushed a package that I've tested on a local Windows VM (Windows 11, 64bit).

Could you please check it out? (v0.0.3)

@mefellows mefellows reopened this Feb 22, 2017
@mefellows
Copy link
Member

It seems due to the naming of my branch that was merged closed the ticket - reopening until you can confirm.

@serinth
Copy link
Author

serinth commented Feb 22, 2017

I just pulled from master and ran the 0.0.3 release for windows. The following are the logs:

from Pact Daemon:

$ ./pact-go_windows_386.exe daemon -v -l DEBUG
2017/02/23 09:04:26 [DEBUG] setting up a service manager
2017/02/23 09:04:26 [DEBUG] setting up a service manager
2017/02/23 09:04:26 [DEBUG] setting up a service manager
2017/02/23 09:04:26 [DEBUG] setting up a service manager
2017/02/23 09:04:26 [INFO] daemon - starting daemon on network: tcp address:  port: 6666
2017/02/23 09:04:26 method Shutdown has wrong number of ins: 1
2017/02/23 09:04:26 [DEBUG] starting service removal monitor
2017/02/23 09:04:26 method StartDaemon has wrong number of ins: 4
2017/02/23 09:04:26 [DEBUG] starting service creation monitor
2017/02/23 09:04:26 [DEBUG] starting service creation monitor
2017/02/23 09:04:26 [DEBUG] starting service removal monitor
2017/02/23 09:04:26 [DEBUG] starting service creation monitor
2017/02/23 09:04:26 [DEBUG] starting service creation monitor
2017/02/23 09:04:26 [DEBUG] starting service removal monitor
2017/02/23 09:04:26 [DEBUG] starting service removal monitor
2017/02/23 09:04:30 [DEBUG] daemon - starting mock server with args: [--pact-specification-version 2 --pact-dir C:\MYPATH\Projects\Go\src\github.com\pact-foundation\pact-go\examples\pacts --log C:\MYPATH\Projects\Go\src\github.com\pact-foundation\pact-go\examples\logs\pact.log --consumer MyConsumer --provider MyProvider]
2017/02/23 09:04:30 [DEBUG] starting mock service on port: 55267
2017/02/23 09:04:30 [DEBUG] starting service
2017/02/23 09:04:30 [INFO] service: [2017-02-23 09:04:30] INFO  WEBrick 1.3.1
2017/02/23 09:04:30 [INFO] service: [2017-02-23 09:04:30] INFO  ruby 2.1.5 (2014-11-13) [i386-mingw32]
2017/02/23 09:04:30 [INFO] service: [2017-02-23 09:04:30] INFO  WEBrick::HTTPServer#start: pid=10800 port=55267
2017/02/23 09:04:31 [DEBUG] daemon - stopping mock server
2017/02/23 09:04:31 [DEBUG] stopping service with pid 10280
2017/02/23 09:04:34 [INFO] service: [2017-02-23 09:04:34] ERROR Errno::ECONNRESET: An existing connection was forcibly closed by the remote host. @ io_fillbuf - fd:7
2017/02/23 09:04:34 [INFO] service:     C:/MYPATH/pact-mock-service/lib/vendor/ruby/2.1.0/gems/webrick-1.3.1/lib/webrick/httpserver.rb:80:in `eof?'
2017/02/23 09:04:34 [INFO] service:     C:/MYPATH/pact-mock-service/lib/vendor/ruby/2.1.0/gems/webrick-1.3.1/lib/webrick/httpserver.rb:80:in `run'
2017/02/23 09:04:34 [INFO] service:     C:/MYPATH/pact-mock-service/lib/vendor/ruby/2.1.0/gems/webrick-1.3.1/lib/webrick/server.rb:191:in `block in start_thread'
2017/02/23 09:04:34 [INFO] service: [2017-02-23 09:04:34] ERROR Errno::ECONNRESET: An existing connection was forcibly closed by the remote host. @ io_fillbuf - fd:8
2017/02/23 09:04:34 [INFO] service:     C:/MYPATH/pact-mock-service/lib/vendor/ruby/2.1.0/gems/webrick-1.3.1/lib/webrick/httpserver.rb:80:in `eof?'
2017/02/23 09:04:34 [INFO] service:     C:/MYPATH/pact-mock-service/lib/vendor/ruby/2.1.0/gems/webrick-1.3.1/lib/webrick/httpserver.rb:80:in `run'
2017/02/23 09:04:34 [INFO] service:     C:/MYPATH/pact-mock-service/lib/vendor/ruby/2.1.0/gems/webrick-1.3.1/lib/webrick/server.rb:191:in `block in start_thread'
2017/02/23 09:04:34 [INFO] service: [2017-02-23 09:04:34] ERROR Errno::ECONNRESET: An existing connection was forcibly closed by the remote host. @ io_fillbuf - fd:6
2017/02/23 09:04:34 [INFO] service:     C:/MYPATH/pact-mock-service/lib/vendor/ruby/2.1.0/gems/webrick-1.3.1/lib/webrick/httpserver.rb:80:in `eof?'
2017/02/23 09:04:34 [INFO] service:     C:/MYPATH/pact-mock-service/lib/vendor/ruby/2.1.0/gems/webrick-1.3.1/lib/webrick/httpserver.rb:80:in `run'
2017/02/23 09:04:34 [INFO] service:     C:/MYPATH/pact-mock-service/lib/vendor/ruby/2.1.0/gems/webrick-1.3.1/lib/webrick/server.rb:191:in `block in start_thread'

And from the consumer example:

2017/02/23 09:04:30 [DEBUG] pact setup logging
2017/02/23 09:04:30 [DEBUG] pact setup
2017/02/23 09:04:30 [DEBUG] client: starting a server
2017/02/23 09:04:30 [DEBUG] creating an HTTP client
2017/02/23 09:04:30 [DEBUG] waiting for port 6666 to become available
2017/02/23 09:04:30 [DEBUG] waiting for port 55267 to become available
2017/02/23 09:04:31 [DEBUG] pact add interaction
2017/02/23 09:04:31 [DEBUG] pact setup logging
2017/02/23 09:04:31 [DEBUG] pact setup
2017/02/23 09:04:31 [DEBUG] pact add interaction
2017/02/23 09:04:31 [DEBUG] pact setup logging
2017/02/23 09:04:31 [DEBUG] pact setup
2017/02/23 09:04:31 [DEBUG] pact verify
2017/02/23 09:04:31 [DEBUG] mock service add interaction
2017/02/23 09:04:31 [DEBUG] mock service response Body: Set interactions
2017/02/23 09:04:31 [DEBUG] mock service add interaction
2017/02/23 09:04:31 [DEBUG] mock service response Body: Set interactions
2017/02/23 09:04:31 [DEBUG] mock service verify
2017/02/23 09:04:31 [DEBUG] mock service response Body: Interactions matched
2017/02/23 09:04:31 [DEBUG] mock service delete interactions
2017/02/23 09:04:31 [DEBUG] mock service response Body: Deleted interactions
Test Passed!
2017/02/23 09:04:31 [DEBUG] teardown
2017/02/23 09:04:31 [DEBUG] client: stop server
2017/02/23 09:04:31 [DEBUG] creating an HTTP client
2017/02/23 09:04:31 [DEBUG] waiting for port 6666 to become available

Seems to be working.

@mefellows
Copy link
Member

Great - sorry about the logs though - eww!

I'm looking into the underlying cause of the connection not closing (this work was probably required anyway). I'll close this for now and re-open another ticket to resolve the logging situation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants