-
Notifications
You must be signed in to change notification settings - Fork 696
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
Fix the timestamp shown during cabal update #7934
Fix the timestamp shown during cabal update #7934
Conversation
7934d90
to
eef2219
Compare
Hi! Thank you for the PR. I can't find the mini-changelog file. A mini-test would be great, too... |
eef2219
to
e431a36
Compare
Hi @Mikolaj thanks for the quick reply. I added a the mini changelog file (it's minimal but the change is not big either). |
@andreabedini The tests under |
Hi @robx, this is very helpful thanks. I was looking for tests inside the I have played along the lines of I just pushed the test implementation. Let me know if I am on the right track. Thanks! |
Before the patch, the sequence
would produce
The second and third timestamps are wrong; this is only wrong in the message, After the patch, it produces:
Where the message about setting the |
Yeah unfortunately it seems a remote repo is needed to test this. The "right" way to test that within this test suite would be to spawn a fake hackage server on localhost in-test. But that seems like excessive effort for this change. I don't know the code-base well though, maybe there's something around somewhere? I imagine there might be some integration test coverage of communication with a remote repo. I'll have to defer to the maintainers, sorry. |
I don't remember myself. Could you grep the repo ( |
I just realised taking to the real hackage will make the test flaky. If the index actually changes between the two calls the message will evidently change. I will have a check if we have any test infra for hackage. |
all right, I had a look a I couldn't find anything regarding a remote repository. Here is my plan:
Furhter notes:
Comments? Feedback? It's totally possible that I missed something we already have. EDIT: if it's too complicated to set up a secure repo on the fly in Haskell code, we can prepopulate one and check it into git |
Would that help?
|
@Mikolaj yes it does! 🤦 |
@@ -63,7 +63,8 @@ run _verbosity mb_cwd env_overrides path0 args input = do | |||
, std_out = UseHandle writeh | |||
, std_err = UseHandle writeh | |||
} | |||
(stdin_h, _, _, procHandle) <- createProcess prc | |||
|
|||
withCreateProcess prc $ \stdin_h _ _ procHandle -> do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is required to make sure the spawn process is termined with the Haskell thread is terminated. This is important when we want to run long-running processes in parallel with a part of our code.
Opinions, anybody? |
FWIW, there's a
guarding |
Oh great, so perhaps that'd be enough. What does it really do if there's no python? Crash? Stop tests? Displays a warning and goes on with tests? |
My understanding is that any test using Just as we discuss this, I notice that I am never checking for the presence of hackage-repo-tool and indeed the tests are failing. Apologies. 1) I'll add |
I am afraid our only option is to install hackage-repo-tool from source :-/ |
That's fine. With some luck (and configuration) CI would even cache the compiled tool. |
There's a failure on GHC 7.10.3 due to |
Please keep in mind #7534. So if it only breaks cabal-install testing (not Cabal), just mark the test as failing and move on. |
Thanks. Ok, it only breaks on ghc-7.10.3 likely because it picks a old version of process which does not have cabal-testsuite pass on Windows but the test get skipped because it relies on unix paths (same as with withRepo, that part is common).
Sorry for the continous stream of conciousness, the test is rightly skipped on linux and macos because of the missing hackage-repo-tool. I'll just add that to the CI then. |
28db31d
to
97ce5c4
Compare
Rebased on master |
I have some failures on MacOS that I need to investigate. |
63e5026
to
2db988f
Compare
Oh right, checks have passed now but I belive the test I wrote is flaky and I would not rely on it much. It uses threadDelay to wait until the python webserver is up but this is very unreliable. I am testing a solution that waits for the webserver port to be available. |
@jneira @Mikolaj I am more confident I have the right solution now. Timing might have not been the only problem after all. Leaving the binding address unspecified might have caused a mistmatch between the http server and cabal on the address (and the family of addresses (IPv4/IPv6)). This is inherently platform and host configuration dependent, which must have been why the test was failing only on mac originally. You can see here that waiting an entire minute was not enough. You can also try to reproduce this confusion on your machine. This is what I get on my (it defaults to IPv4 and
Hopefully, generous waiting for the server to come up (exponential backoff limited at one minute) and explicity binding host would do the trick. <3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Magnificent work.
Passing an index-state timestamp to cabal update currently makes it write a message saying the index has been updated to the *previous* timestamp. $ cabal update hackage.haskell.org,2016-09-24T17:47:48Z Downloading the latest package list from hackage.haskell.org Package list of hackage.haskell.org is up to date at index-state 2022-01-27T12:59:23Z This is because of a confusion between downloading the index and setting the index state. These are independent actions. This patch makes separates the two messages (updating the index and updating the index-state timestamp) and makes sure the right timestamp is printed.
- Introduce `withRemoteRepo`. The function `withRemoteRepo` takes a folder with packages (in the same way as `withRepo` and presents it to cabal as a secure remote repository. - Convert NewUpewte/UpdateIndexState test from using Hackage to withRemoteRepo.
Note: as it is, this won't work on GHC 8.2 because network-wait-0.1.1.0 doesn't support it. Hopefully we can resolve this soon.
Thanks @mbg!
bb0d71e
to
00c9776
Compare
run: | | ||
cd $(mktemp -d) | ||
cabal install hackage-repo-tool | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great move, improving the test suite
As written in the comments current_ts can be a non valid timestamp (nullTimestamp) if the timestamp is missing. In this case it does not make sense to tell the user how to revert to current_ts.
As written in the comments current_ts can be a non valid timestamp (nullTimestamp) if the timestamp is missing. In this case it does not make sense to tell the user how to revert to current_ts.
As written in the comments current_ts can be a non valid timestamp (nullTimestamp) if the timestamp is missing. In this case it does not make sense to tell the user how to revert to current_ts.
Minor clean up after PR #7934
Passing an index-state timestamp to cabal update currently makes it
write a message saying the index has been updated to the previous
timestamp.
This is because of a confusion between downloading the index and setting
the index state. These are independent actions.
This patch makes separates the two messages (updating the index and
updating the index-state timestamp) and makes sure the right timestamp
is printed.
I am sure there was an issue for this but I cannot find it (@fgaz ?).This addresses #7246
I have tested this manually, with something like
Please include the following checklist in your PR:
Please also shortly describe how you tested your change. Bonus points for added tests!