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

requests.RequestTests fails trying to contact https://httpbin.org (200USD Bounty) #132

Closed
SethTisue opened this issue May 2, 2023 · 9 comments · Fixed by #175
Closed

Comments

@SethTisue
Copy link

SethTisue commented May 2, 2023


From the maintainer Li Haoyi: I'm putting a 200USD bounty on this issue, payable by bank transfer on a merged PR resolving this issue. The solution to this is to download a version of httpbin locally and run it as part of the test setup, both in CI and during manual development, and ensuring all tests pass


I've seen this in the Scala 2 community build and it's also reproducible locally

X requests.Scala2RequestTests.params.post 10555ms 
  requests.TimeoutException: Request to https://httpbin.org/post timed out. (readTimeout: 10000, connectTimout: 10000)
    requests.Requester$$anon$1.liftedTree1$1(Requester.scala:274)
    requests.Requester$$anon$1.readBytesThrough(Requester.scala:266)
    geny.Readable.writeBytesTo(Writable.scala:93)
    geny.Readable.writeBytesTo$(Writable.scala:93)
    requests.Requester$$anon$1.writeBytesTo(Requester.scala:164)
    requests.Requester.apply(Requester.scala:113)
    requests.Scala2RequestTests$.$anonfun$tests$4(Scala2RequestTests.scala:16)
    requests.Scala2RequestTests$.$anonfun$tests$4$adapted(Scala2RequestTests.scala:12)
    scala.collection.immutable.List.foreach(List.scala:431)
    requests.Scala2RequestTests$.$anonfun$tests$3(Scala2RequestTests.scala:12)
X requests.Scala2RequestTests.params.put 10211ms 
  requests.TimeoutException: Request to https://httpbin.org/put timed out. (readTimeout: 10000, connectTimout: 10000)
    requests.Requester$$anon$1.liftedTree1$1(Requester.scala:274)
    requests.Requester$$anon$1.readBytesThrough(Requester.scala:266)
    geny.Readable.writeBytesTo(Writable.scala:93)
    geny.Readable.writeBytesTo$(Writable.scala:93)
    requests.Requester$$anon$1.writeBytesTo(Requester.scala:164)
    requests.Requester.apply(Requester.scala:113)
    requests.Scala2RequestTests$.$anonfun$tests$8(Scala2RequestTests.scala:27)
    requests.Scala2RequestTests$.$anonfun$tests$8$adapted(Scala2RequestTests.scala:23)
    scala.collection.immutable.List.foreach(List.scala:431)
    requests.Scala2RequestTests$.$anonfun$tests$7(Scala2RequestTests.scala:23)
X requests.RequestTests.matchingMethodWorks 10111ms 
  requests.TimeoutException: Request to http://httpbin.org/delete timed out. (readTimeout: 10000, connectTimout: 10000)
    requests.Requester$$anon$1.liftedTree1$1(Requester.scala:274)
    requests.Requester$$anon$1.readBytesThrough(Requester.scala:266)
    geny.Readable.writeBytesTo(Writable.scala:93)
    geny.Readable.writeBytesTo$(Writable.scala:93)
    requests.Requester$$anon$1.writeBytesTo(Requester.scala:164)
    requests.Requester.apply(Requester.scala:113)
    requests.RequestTests$.$anonfun$tests$5(RequestTests.scala:19)
    scala.collection.immutable.List.foreach(List.scala:431)
    requests.RequestTests$.$anonfun$tests$4(RequestTests.scala:18)
    requests.RequestTests$.$anonfun$tests$4$adapted(RequestTests.scala:17)
    scala.collection.immutable.List.foreach(List.scala:431)
    requests.RequestTests$.$anonfun$tests$3(RequestTests.scala:17)
    requests.RequestTests$.$anonfun$tests$3$adapted(RequestTests.scala:16)
    scala.collection.immutable.List.foreach(List.scala:431)
    requests.RequestTests$.$anonfun$tests$2(RequestTests.scala:16)
X requests.RequestTests.params.get 10333ms 
  requests.TimeoutException: Request to https://httpbin.org/get?hello=world&foo=baz timed out. (readTimeout: 10000, connectTimout: 10000)
    requests.Requester$$anon$1.liftedTree1$1(Requester.scala:274)
    requests.Requester$$anon$1.readBytesThrough(Requester.scala:266)
    geny.Readable.writeBytesTo(Writable.scala:93)
    geny.Readable.writeBytesTo$(Writable.scala:93)
    requests.Requester$$anon$1.writeBytesTo(Requester.scala:164)
    requests.Requester.apply(Requester.scala:113)
    requests.RequestTests$.$anonfun$tests$11(RequestTests.scala:37)
X requests.RequestTests.cookies.raw 10004ms 
  requests.TimeoutException: Request to https://httpbin.org/cookies timed out. (readTimeout: 10000, connectTimout: 10000)
    requests.Requester$$anon$1.liftedTree1$1(Requester.scala:274)
    requests.Requester$$anon$1.readBytesThrough(Requester.scala:266)
    geny.Readable.writeBytesTo(Writable.scala:93)
    geny.Readable.writeBytesTo$(Writable.scala:93)
    requests.Requester$$anon$1.writeBytesTo(Requester.scala:164)
    requests.Requester.apply(Requester.scala:113)
    requests.RequestTests$.$anonfun$tests$34(RequestTests.scala:89)
requests.RequestTests.redirects.maxRelative 12988ms 
  requests.TimeoutException: Request to https://httpbin.org/relative-redirect/3 timed out. (readTimeout: 10000, connectTimout: 10000)
    requests.Requester$$anon$1.liftedTree1$1(Requester.scala:274)
    requests.Requester$$anon$1.readBytesThrough(Requester.scala:266)
    requests.Requester$$anon$1.readBytesThrough(Requester.scala:315)
    geny.Readable.writeBytesTo(Writable.scala:93)
    geny.Readable.writeBytesTo$(Writable.scala:93)
    requests.Requester$$anon$1.writeBytesTo(Requester.scala:164)
    requests.Requester.apply(Requester.scala:113)
    requests.RequestTests$.$anonfun$tests$48(RequestTests.scala:117)
@SethTisue
Copy link
Author

the Dotty folks also experienced this and pulled the tests from their community build: scala/scala3#17199

@SethTisue
Copy link
Author

for now, I did scala/community-build@e86a969

@lihaoyi lihaoyi changed the title requests.RequestTests fails trying to contact https://httpbin.org requests.RequestTests fails trying to contact https://httpbin.org (200USD Bounty) Jul 22, 2024
@rvangsgaard
Copy link

I made some first simple steps at solving this issue, and I would appreciate your feedback if this is the right approach. This is the code https://github.com/rvangsgaard/requests-scala/tree/132-switch-from-remote-httpbin-to-local-when-running-tests. Here is a link to a Gitter chat on the subject https://matrix.to/#/!zXvttAKLPnvdnmiYsY:matrix.am/$H-w8vMhK-Pav-UkQNNqcVIyR7e734Kaanjdn3jT-vOY?via=matrix.am&via=gitter.im&via=matrix.org.

It is not clear and obvious to me how to extend and compose Tasks in Mill.

@rvangsgaard
Copy link

Will you consider testcontainers as a test dependency in the build?

@lihaoyi
Copy link
Member

lihaoyi commented Jul 26, 2024

sure i think testcontainets is fine

@nafg
Copy link
Contributor

nafg commented Sep 3, 2024

The tests already have a local server that's used a little, perhaps it's better to just extend that

wb14123 added a commit to wb14123/requests-scala that referenced this issue Sep 15, 2024
Fix com-lihaoyi#132

Start a local httpbin container to run tests against.

Https requests are still using remote one since it's hard to setup local
secure ssl. The requests using https are simple and during my tests I
haven't seen any timeout.
@wb14123
Copy link
Contributor

wb14123 commented Sep 15, 2024

The local server is just an echo server which cannot support most of the test cases. I created a PR to use httpbin with testcontainers : #175

@SethTisue
Copy link
Author

in the Scala 2 community build we lack the capability to run Docker-based tests, so I have to leave the test disabled. so oh well — regardless, it's good this was fixed for others!

not sure about Scala 3

@lihaoyi
Copy link
Member

lihaoyi commented Sep 18, 2024

No worries, there should be plenty of other reos for you to test! I dont think this one does anything special

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.

5 participants