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 failure with modified RUBY_PG_TEST_DIR #576

Closed
voxik opened this issue Aug 7, 2024 · 2 comments · Fixed by #581
Closed

Test failure with modified RUBY_PG_TEST_DIR #576

voxik opened this issue Aug 7, 2024 · 2 comments · Fixed by #581

Comments

@voxik
Copy link

voxik commented Aug 7, 2024

I have the source code in deeply nested directory, therefore I am forced to modify RUBY_PG_TEST_DIR, because otherwise PG fails to start with Unix-domain socket path "..." is too long (maximum 107 bytes) error 🤯. But with the modified RUBY_PG_TEST_DIR, I observer these errors:

Failures:

  1) PG::Connection with async established connection can work with changing IO while connection setup
     Failure/Error: expect( conn.ssl_in_use? ).to be_falsey

       expected: falsey value
            got: true
     # ./spec/pg/connection_spec.rb:571:in `block (3 levels) in <top (required)>'
     # /builddir/build/BUILD/rubygem-pg-1.5.4-build/spec/helpers.rb:56:in `block in included'

  2) running with sync_* methods PG::Connection with async established connection can work with changing IO while connection setup
     Failure/Error: expect( conn.ssl_in_use? ).to be_falsey

       expected: falsey value
            got: true
     # ./spec/pg/connection_spec.rb:571:in `block (4 levels) in <top (required)>'
     # /builddir/build/BUILD/rubygem-pg-1.5.4-build/spec/helpers.rb:56:in `block in included'

The naive patch to fix this would be:

$ git diff 
diff --git a/spec/pg/connection_spec.rb b/spec/pg/connection_spec.rb
index fcc277b..fd06346 100644
--- a/spec/pg/connection_spec.rb
+++ b/spec/pg/connection_spec.rb
@@ -567,7 +567,7 @@ describe PG::Connection do
                        # Connect with SSL, but use a wrong client cert, so that connection is aborted.
                        # A second connection is then started with a new IO.
                        # And since the pipes above were freed in the concurrent thread above, there is a high chance that it's a lower file descriptor than before.
-                       conn = PG.connect( @conninfo + " sslcert=tmp_test_specs/data/ruby-pg-ca-cert" )
+                       conn = PG.connect( @conninfo + " sslcert=#{TEST_DIRECTORY}/tmp_test_specs/data/ruby-pg-ca-cert" )
                        expect( conn.ssl_in_use? ).to be_falsey
 
                        # The new connection should work even when the file descriptor has changed.

However, I don't think it is correct. It would likely be better to access this variable:

@test_dir = TEST_DIRECTORY + "tmp_test_#{@name}"

or construct it by different means.

@larskanis
Copy link
Collaborator

@voxik Is #581 OK for your use case?

@voxik
Copy link
Author

voxik commented Aug 12, 2024

Thanks for the PR. Looking 👀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants