-
Notifications
You must be signed in to change notification settings - Fork 66
control-service: logs endpoint doesn't hang #2370
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
87 changes: 87 additions & 0 deletions
87
...ol_service/src/integration-test/java/com/vmware/taurus/datajobs/it/DataJobViewLogsIT.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| /* | ||
| * Copyright 2021-2023 VMware, Inc. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package com.vmware.taurus.datajobs.it; | ||
|
|
||
| import com.vmware.taurus.ControlplaneApplication; | ||
| import com.vmware.taurus.controlplane.model.data.DataJobExecution; | ||
| import com.vmware.taurus.datajobs.it.common.BaseIT; | ||
| import com.vmware.taurus.datajobs.it.common.DataJobDeploymentExtension; | ||
| import com.vmware.taurus.datajobs.it.common.JobExecutionUtil; | ||
| import com.vmware.taurus.service.execution.JobExecutionService; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.apache.commons.lang3.tuple.ImmutablePair; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.junit.jupiter.api.extension.RegisterExtension; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.boot.test.context.SpringBootTest; | ||
| import org.testcontainers.shaded.org.awaitility.Awaitility; | ||
|
|
||
| import java.util.concurrent.ExecutionException; | ||
| import java.util.concurrent.Executors; | ||
| import java.util.concurrent.TimeUnit; | ||
| import java.util.concurrent.TimeoutException; | ||
|
|
||
| import static com.vmware.taurus.datajobs.it.common.JobExecutionUtil.testDataJobExecutionRead; | ||
|
|
||
| @Slf4j | ||
| @SpringBootTest( | ||
| webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, | ||
| classes = ControlplaneApplication.class) | ||
| public class DataJobViewLogsIT extends BaseIT { | ||
|
|
||
| @Autowired private JobExecutionService executionService; | ||
|
|
||
| // simple_job_read_logs.zip contains a job that would run for more than 30 minutes if allowed | ||
| @RegisterExtension | ||
| static DataJobDeploymentExtension dataJobDeploymentExtension = | ||
| new DataJobDeploymentExtension("simple_job_read_logs.zip"); | ||
|
|
||
| @Test | ||
| public void testJobLogsViewing( | ||
| String jobName, String username, String deploymentId, String teamName) throws Exception { | ||
| // manually start job execution | ||
| ImmutablePair<String, String> executeDataJobResult = | ||
| JobExecutionUtil.executeDataJob(jobName, teamName, username, deploymentId, mockMvc); | ||
| String executionId = executeDataJobResult.getRight(); | ||
| String opId = executeDataJobResult.getLeft(); | ||
| testDataJobExecutionRead( | ||
| executionId, | ||
| DataJobExecution.StatusEnum.RUNNING, | ||
| opId, | ||
| jobName, | ||
| teamName, | ||
| username, | ||
| mockMvc); | ||
| Awaitility.await() | ||
| .atMost(6, TimeUnit.MINUTES) | ||
| .ignoreExceptionsMatching( | ||
| (e) -> | ||
| // It is only by looking 3 exceptions deep that we can tell the reason the logs read | ||
| // failed. | ||
| e.getCause() | ||
| .getCause() | ||
| // If 400 is in the error message then the pod is not up yet and we should keep | ||
| // trying to poll for the logs. | ||
| .getMessage() | ||
| .contains("400")) | ||
| .until( | ||
| () -> { | ||
| getLogsFast(jobName, teamName, executionId); | ||
| return true; | ||
| }); | ||
| } | ||
|
|
||
| /** We are testing that the server returns logs quickly. */ | ||
| private void getLogsFast(String jobName, String teamName, String executionId) | ||
| throws InterruptedException, ExecutionException, TimeoutException { | ||
| Executors.newSingleThreadExecutor() | ||
| .submit( | ||
| () -> { | ||
| executionService.getJobExecutionLogs(teamName, jobName, executionId, 0); | ||
| }) | ||
| .get(5, TimeUnit.SECONDS); | ||
| } | ||
| } | ||
Binary file added
BIN
+2.69 KB
...pelines_control_service/src/integration-test/resources/data_jobs/simple_job_read_logs.zip
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.