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
gateway/runservice: add api to delete step logs #157
Conversation
@camandel Thanks for the PR! before reviewing, can you add some tests (as integration tests and runservice tests)? Related agola-web issues: agola-io/agola-web#5 agola-io/agola-web#24 |
13ca376
to
9ac06bc
Compare
@sgotti I've add two integration tests in setup_test.go but I did not find a way to add runservice tests. |
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.
@camandel The integration tests looks good. For the runservice test there isn't an existing one right now. The idea is to create a test self contained in the runservice that will create a run and then delete the logs. But this could be done in another PR.
Comments inline. Tests are failing due to golangci-lint errors.
9ac06bc
to
b977a6f
Compare
@sgotti Modified to use httpError function and new errors types. Added new tests to check non existing logs. |
@camandel Thanks. Looks like |
b977a6f
to
2681d64
Compare
I tried it in my env (all-in-one server with docker executor) but the test I tried to add a delay of 5 seconds before to check if the log exists. Need it find a better way to handle this. |
Run fetching from the executor is always asyncronous: agola/internal/services/runservice/scheduler.go Lines 1109 to 1124 in 581a610
Now fetching is executed every 2 seconds. The test fails for me also locally because it's not related to being in a single process or not since they always are distinct components. You should wait for it for being archived but the run response provided by the gateway doesn't export information on the logs/archives fetch state (they are low level information that don't have to be exposed to external clients) so currently sleeping is the unique way in these integration tests. |
Thinking more about this, if we want to show a |
Now that #175 is merged we can use it in the tests to wait for the log to be archived. |
2681d64
to
2611faf
Compare
5979f73
to
6bf38e2
Compare
Code modified as indicated and fixed the integration test (it checked logArchived only for step one). |
6bf38e2
to
502b274
Compare
502b274
to
1e8f48d
Compare
For tests on logs with no existing step I used
I was wondering if it's possible to align the prefix |
Yes, just use the same code used in LogsHandler to add the agola/internal/services/runservice/api/api.go Lines 196 to 201 in 519e7aa
You can use strings.HasPrefix which is cleaner than strings.Compare. Using only util.IsNotExits will check the error type but won't check the expected error text so it'll also catch an ErrNotExist caused by another code path. |
1e8f48d
to
3e47bc6
Compare
Aligned error message prefix and changed check with strings.HasPrefix. |
@camandel Thanks a lot! Merging. |
gateway/runservice: add api to delete step logs
gateway/runservice: add api to delete step logs
A try to fix issue #41 for logs deletion.