status
stringclasses
1 value
repo_name
stringclasses
31 values
repo_url
stringclasses
31 values
issue_id
int64
1
104k
title
stringlengths
4
233
body
stringlengths
0
186k
issue_url
stringlengths
38
56
pull_url
stringlengths
37
54
before_fix_sha
stringlengths
40
40
after_fix_sha
stringlengths
40
40
report_datetime
timestamp[us, tz=UTC]
language
stringclasses
5 values
commit_datetime
timestamp[us, tz=UTC]
updated_file
stringlengths
7
188
chunk_content
stringlengths
1
1.03M
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,301
[Migration][Test] jUnit4 -> jUnit5 UT cases migration
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * This is part of DSIP-10 #10573 * By this moment, we have added jUnit 5 dependencies #11332 and removed all `Powermock` related code #11405. It is high time that we migrate all the UT cases from jUnit 4 to jUnit 5 and remove the dependency of `junit-vintage-engine` so that there will be one and only one version of unit test cases, which is jUnit5, in the whole project. ### SOP These two following articles are recommended for you to understand the whole process. In order to keep the instructions brief and concise, I summarize some key points of these two articles as well as add a few extra operations based on practice for your reference: * https://blogs.oracle.com/javamagazine/post/migrating-from-junit-4-to-junit-5-important-differences-and-benefits * https://blog.jetbrains.com/idea/2020/08/migrating-from-junit-4-to-junit-5/ BTW, I suggest you perform this SOP below by module or by file, instead of doing it for the whole project. This helps you increase efficiency. 1. Perform basic migration through `Intellij IDE` for the module you choose. ![screenshot1](https://user-images.githubusercontent.com/34905992/194875626-6560812b-c776-4601-9425-4eafea3288bb.png) 2. Replace `@RunWith(MockitoJUnitRunner.class)` with `@ExtendWith(MockitoExtension.class)` if necessary. 3. Replace `Assert` with `Assertions`. 4. Fix expected exception if necessary. ```java // jUnit 4 @Test(expected = Exception.class) public void testThrowsException() throws Exception { // ... } // jUnit 5 @Test public void testThrowsException() throws Exception { Assertions.assertThrows(Exception.class, () -> { //... }); } ``` 6. Fix timeout if necessary. ```java // jUnit 4 @Test(timeout = 10) public void testFailWithTimeout() throws InterruptedException { Thread.sleep(100); } // jUnit 5 @Test void testFailWithTimeout() throws InterruptedException { Assertions.assertTimeout(Duration.ofMillis(10), () -> Thread.sleep(100)); } Assertions.assertTimeout(Duration.ofMillis(60000), () -> {}); ``` 8. Replace `@Ignore` with `@Disable` if necessary. 9. Replace `org.junit.rules.TemporaryFolder` with `org.junit.jupiter.api.io.TempDir` and use `@TempDir` if necessary. 10. Run the UT file you changed to see whether all cases pass successfully. 11. Fix unnecessary stubbings if necessary. This is caused by changing `@Before` into `@BeforeEach`. The recommend method is to use `@MockitoSettings(strictness = Strictness.LENIENT)`. Alternatively, you could either remove the unnecessary stubbings from `@BeforeEach` and only put them where they needed or use `Mockito.lenient().when(......` for `Mockito.when(......` to bypass the `stubbing check`. 12. Global search in your module and make sure all `org.junit.xxxx` has been migrated to `org.junit.jupiter.api.xxx` ### PR Example * #12299 ### Sub-Tasks We hope to complete all the following sub-tasks ***before Oct. 25th*** because DSIP-10 depends on this issue and all UT cases are supposed to be migrated to jUnit 5 before the start of UT refactoring. - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `task-plugin` module: #12299 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `alert` and `api` module: #12313 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `dao` module: #12319 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `data-quality`, `datasource-plugin` and `registry` module: #12322 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `master`, `worker` and `remote` module: #12316 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `common`, `service` and `spi` module: #12317 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `microbench` and `e2e` module: #12333 - [x] Block explicit imports of jUnit 4 library. #12395 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12301
https://github.com/apache/dolphinscheduler/pull/12450
0eef2e3e10ca8d20d8a0ad59b0f0674f90ee321c
0a6e8af864423dac2aff279bf56f6f1ee95e95b9
2022-10-10T12:48:52Z
java
2022-10-20T04:12:17Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
return ""; } Tenant tenant = tenantMapper.queryById(user.getTenantId()); if (Objects.isNull(tenant)) { return ""; } return tenant.getTenantCode(); } /** * find schedule list by process define codes. * * @param codes codes * @return schedule list */ @Override public List<Schedule> selectAllByProcessDefineCode(long[] codes) { return scheduleMapper.selectAllByProcessDefineArray(codes); } /** * find last scheduler process instance in the date interval * * @param definitionCode definitionCode * @param dateInterval dateInterval * @return process instance */ @Override public ProcessInstance findLastSchedulerProcessInterval(Long definitionCode, DateInterval dateInterval, int testFlag) { return processInstanceMapper.queryLastSchedulerProcess(definitionCode, dateInterval.getStartTime(),
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,301
[Migration][Test] jUnit4 -> jUnit5 UT cases migration
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * This is part of DSIP-10 #10573 * By this moment, we have added jUnit 5 dependencies #11332 and removed all `Powermock` related code #11405. It is high time that we migrate all the UT cases from jUnit 4 to jUnit 5 and remove the dependency of `junit-vintage-engine` so that there will be one and only one version of unit test cases, which is jUnit5, in the whole project. ### SOP These two following articles are recommended for you to understand the whole process. In order to keep the instructions brief and concise, I summarize some key points of these two articles as well as add a few extra operations based on practice for your reference: * https://blogs.oracle.com/javamagazine/post/migrating-from-junit-4-to-junit-5-important-differences-and-benefits * https://blog.jetbrains.com/idea/2020/08/migrating-from-junit-4-to-junit-5/ BTW, I suggest you perform this SOP below by module or by file, instead of doing it for the whole project. This helps you increase efficiency. 1. Perform basic migration through `Intellij IDE` for the module you choose. ![screenshot1](https://user-images.githubusercontent.com/34905992/194875626-6560812b-c776-4601-9425-4eafea3288bb.png) 2. Replace `@RunWith(MockitoJUnitRunner.class)` with `@ExtendWith(MockitoExtension.class)` if necessary. 3. Replace `Assert` with `Assertions`. 4. Fix expected exception if necessary. ```java // jUnit 4 @Test(expected = Exception.class) public void testThrowsException() throws Exception { // ... } // jUnit 5 @Test public void testThrowsException() throws Exception { Assertions.assertThrows(Exception.class, () -> { //... }); } ``` 6. Fix timeout if necessary. ```java // jUnit 4 @Test(timeout = 10) public void testFailWithTimeout() throws InterruptedException { Thread.sleep(100); } // jUnit 5 @Test void testFailWithTimeout() throws InterruptedException { Assertions.assertTimeout(Duration.ofMillis(10), () -> Thread.sleep(100)); } Assertions.assertTimeout(Duration.ofMillis(60000), () -> {}); ``` 8. Replace `@Ignore` with `@Disable` if necessary. 9. Replace `org.junit.rules.TemporaryFolder` with `org.junit.jupiter.api.io.TempDir` and use `@TempDir` if necessary. 10. Run the UT file you changed to see whether all cases pass successfully. 11. Fix unnecessary stubbings if necessary. This is caused by changing `@Before` into `@BeforeEach`. The recommend method is to use `@MockitoSettings(strictness = Strictness.LENIENT)`. Alternatively, you could either remove the unnecessary stubbings from `@BeforeEach` and only put them where they needed or use `Mockito.lenient().when(......` for `Mockito.when(......` to bypass the `stubbing check`. 12. Global search in your module and make sure all `org.junit.xxxx` has been migrated to `org.junit.jupiter.api.xxx` ### PR Example * #12299 ### Sub-Tasks We hope to complete all the following sub-tasks ***before Oct. 25th*** because DSIP-10 depends on this issue and all UT cases are supposed to be migrated to jUnit 5 before the start of UT refactoring. - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `task-plugin` module: #12299 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `alert` and `api` module: #12313 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `dao` module: #12319 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `data-quality`, `datasource-plugin` and `registry` module: #12322 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `master`, `worker` and `remote` module: #12316 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `common`, `service` and `spi` module: #12317 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `microbench` and `e2e` module: #12333 - [x] Block explicit imports of jUnit 4 library. #12395 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12301
https://github.com/apache/dolphinscheduler/pull/12450
0eef2e3e10ca8d20d8a0ad59b0f0674f90ee321c
0a6e8af864423dac2aff279bf56f6f1ee95e95b9
2022-10-10T12:48:52Z
java
2022-10-20T04:12:17Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
dateInterval.getEndTime(), testFlag); } /** * find last manual process instance interval * * @param definitionCode process definition code * @param dateInterval dateInterval * @return process instance */ @Override public ProcessInstance findLastManualProcessInterval(Long definitionCode, DateInterval dateInterval, int testFlag) { return processInstanceMapper.queryLastManualProcess(definitionCode, dateInterval.getStartTime(), dateInterval.getEndTime(), testFlag); } /** * find last running process instance * * @param definitionCode process definition code * @param startTime start time * @param endTime end time * @return process instance */ @Override public ProcessInstance findLastRunningProcess(Long definitionCode, Date startTime, Date endTime, int testFlag) { return processInstanceMapper.queryLastRunningProcess(definitionCode, startTime, endTime,
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,301
[Migration][Test] jUnit4 -> jUnit5 UT cases migration
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * This is part of DSIP-10 #10573 * By this moment, we have added jUnit 5 dependencies #11332 and removed all `Powermock` related code #11405. It is high time that we migrate all the UT cases from jUnit 4 to jUnit 5 and remove the dependency of `junit-vintage-engine` so that there will be one and only one version of unit test cases, which is jUnit5, in the whole project. ### SOP These two following articles are recommended for you to understand the whole process. In order to keep the instructions brief and concise, I summarize some key points of these two articles as well as add a few extra operations based on practice for your reference: * https://blogs.oracle.com/javamagazine/post/migrating-from-junit-4-to-junit-5-important-differences-and-benefits * https://blog.jetbrains.com/idea/2020/08/migrating-from-junit-4-to-junit-5/ BTW, I suggest you perform this SOP below by module or by file, instead of doing it for the whole project. This helps you increase efficiency. 1. Perform basic migration through `Intellij IDE` for the module you choose. ![screenshot1](https://user-images.githubusercontent.com/34905992/194875626-6560812b-c776-4601-9425-4eafea3288bb.png) 2. Replace `@RunWith(MockitoJUnitRunner.class)` with `@ExtendWith(MockitoExtension.class)` if necessary. 3. Replace `Assert` with `Assertions`. 4. Fix expected exception if necessary. ```java // jUnit 4 @Test(expected = Exception.class) public void testThrowsException() throws Exception { // ... } // jUnit 5 @Test public void testThrowsException() throws Exception { Assertions.assertThrows(Exception.class, () -> { //... }); } ``` 6. Fix timeout if necessary. ```java // jUnit 4 @Test(timeout = 10) public void testFailWithTimeout() throws InterruptedException { Thread.sleep(100); } // jUnit 5 @Test void testFailWithTimeout() throws InterruptedException { Assertions.assertTimeout(Duration.ofMillis(10), () -> Thread.sleep(100)); } Assertions.assertTimeout(Duration.ofMillis(60000), () -> {}); ``` 8. Replace `@Ignore` with `@Disable` if necessary. 9. Replace `org.junit.rules.TemporaryFolder` with `org.junit.jupiter.api.io.TempDir` and use `@TempDir` if necessary. 10. Run the UT file you changed to see whether all cases pass successfully. 11. Fix unnecessary stubbings if necessary. This is caused by changing `@Before` into `@BeforeEach`. The recommend method is to use `@MockitoSettings(strictness = Strictness.LENIENT)`. Alternatively, you could either remove the unnecessary stubbings from `@BeforeEach` and only put them where they needed or use `Mockito.lenient().when(......` for `Mockito.when(......` to bypass the `stubbing check`. 12. Global search in your module and make sure all `org.junit.xxxx` has been migrated to `org.junit.jupiter.api.xxx` ### PR Example * #12299 ### Sub-Tasks We hope to complete all the following sub-tasks ***before Oct. 25th*** because DSIP-10 depends on this issue and all UT cases are supposed to be migrated to jUnit 5 before the start of UT refactoring. - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `task-plugin` module: #12299 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `alert` and `api` module: #12313 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `dao` module: #12319 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `data-quality`, `datasource-plugin` and `registry` module: #12322 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `master`, `worker` and `remote` module: #12316 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `common`, `service` and `spi` module: #12317 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `microbench` and `e2e` module: #12333 - [x] Block explicit imports of jUnit 4 library. #12395 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12301
https://github.com/apache/dolphinscheduler/pull/12450
0eef2e3e10ca8d20d8a0ad59b0f0674f90ee321c
0a6e8af864423dac2aff279bf56f6f1ee95e95b9
2022-10-10T12:48:52Z
java
2022-10-20T04:12:17Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
testFlag, WorkflowExecutionStatus.getNeedFailoverWorkflowInstanceState()); } /** * query user queue by process instance * * @param processInstance processInstance * @return queue */ @Override public String queryUserQueueByProcessInstance(ProcessInstance processInstance) { String queue = ""; if (processInstance == null) { return queue; } User executor = userMapper.selectById(processInstance.getExecutorId()); if (executor != null) { queue = executor.getQueue(); } return queue; } /** * query project name and user name by processInstanceId. * * @param processInstanceId processInstanceId * @return projectName and userName */ @Override public ProjectUser queryProjectWithUserByProcessInstanceId(int processInstanceId) { return projectMapper.queryProjectWithUserByProcessInstanceId(processInstanceId);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,301
[Migration][Test] jUnit4 -> jUnit5 UT cases migration
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * This is part of DSIP-10 #10573 * By this moment, we have added jUnit 5 dependencies #11332 and removed all `Powermock` related code #11405. It is high time that we migrate all the UT cases from jUnit 4 to jUnit 5 and remove the dependency of `junit-vintage-engine` so that there will be one and only one version of unit test cases, which is jUnit5, in the whole project. ### SOP These two following articles are recommended for you to understand the whole process. In order to keep the instructions brief and concise, I summarize some key points of these two articles as well as add a few extra operations based on practice for your reference: * https://blogs.oracle.com/javamagazine/post/migrating-from-junit-4-to-junit-5-important-differences-and-benefits * https://blog.jetbrains.com/idea/2020/08/migrating-from-junit-4-to-junit-5/ BTW, I suggest you perform this SOP below by module or by file, instead of doing it for the whole project. This helps you increase efficiency. 1. Perform basic migration through `Intellij IDE` for the module you choose. ![screenshot1](https://user-images.githubusercontent.com/34905992/194875626-6560812b-c776-4601-9425-4eafea3288bb.png) 2. Replace `@RunWith(MockitoJUnitRunner.class)` with `@ExtendWith(MockitoExtension.class)` if necessary. 3. Replace `Assert` with `Assertions`. 4. Fix expected exception if necessary. ```java // jUnit 4 @Test(expected = Exception.class) public void testThrowsException() throws Exception { // ... } // jUnit 5 @Test public void testThrowsException() throws Exception { Assertions.assertThrows(Exception.class, () -> { //... }); } ``` 6. Fix timeout if necessary. ```java // jUnit 4 @Test(timeout = 10) public void testFailWithTimeout() throws InterruptedException { Thread.sleep(100); } // jUnit 5 @Test void testFailWithTimeout() throws InterruptedException { Assertions.assertTimeout(Duration.ofMillis(10), () -> Thread.sleep(100)); } Assertions.assertTimeout(Duration.ofMillis(60000), () -> {}); ``` 8. Replace `@Ignore` with `@Disable` if necessary. 9. Replace `org.junit.rules.TemporaryFolder` with `org.junit.jupiter.api.io.TempDir` and use `@TempDir` if necessary. 10. Run the UT file you changed to see whether all cases pass successfully. 11. Fix unnecessary stubbings if necessary. This is caused by changing `@Before` into `@BeforeEach`. The recommend method is to use `@MockitoSettings(strictness = Strictness.LENIENT)`. Alternatively, you could either remove the unnecessary stubbings from `@BeforeEach` and only put them where they needed or use `Mockito.lenient().when(......` for `Mockito.when(......` to bypass the `stubbing check`. 12. Global search in your module and make sure all `org.junit.xxxx` has been migrated to `org.junit.jupiter.api.xxx` ### PR Example * #12299 ### Sub-Tasks We hope to complete all the following sub-tasks ***before Oct. 25th*** because DSIP-10 depends on this issue and all UT cases are supposed to be migrated to jUnit 5 before the start of UT refactoring. - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `task-plugin` module: #12299 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `alert` and `api` module: #12313 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `dao` module: #12319 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `data-quality`, `datasource-plugin` and `registry` module: #12322 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `master`, `worker` and `remote` module: #12316 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `common`, `service` and `spi` module: #12317 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `microbench` and `e2e` module: #12333 - [x] Block explicit imports of jUnit 4 library. #12395 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12301
https://github.com/apache/dolphinscheduler/pull/12450
0eef2e3e10ca8d20d8a0ad59b0f0674f90ee321c
0a6e8af864423dac2aff279bf56f6f1ee95e95b9
2022-10-10T12:48:52Z
java
2022-10-20T04:12:17Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
} /** * get task worker group * * @param taskInstance taskInstance * @return workerGroupId */ @Override public String getTaskWorkerGroup(TaskInstance taskInstance) { String workerGroup = taskInstance.getWorkerGroup(); if (!Strings.isNullOrEmpty(workerGroup)) { return workerGroup; } int processInstanceId = taskInstance.getProcessInstanceId(); ProcessInstance processInstance = findProcessInstanceById(processInstanceId); if (processInstance != null) { return processInstance.getWorkerGroup(); } logger.info("task : {} will use default worker group", taskInstance.getId()); return Constants.DEFAULT_WORKER_GROUP; } /** * get have perm project list * * @param userId userId * @return project list */ @Override public List<Project> getProjectListHavePerm(int userId) { List<Project> createProjects = projectMapper.queryProjectCreatedByUser(userId);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,301
[Migration][Test] jUnit4 -> jUnit5 UT cases migration
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * This is part of DSIP-10 #10573 * By this moment, we have added jUnit 5 dependencies #11332 and removed all `Powermock` related code #11405. It is high time that we migrate all the UT cases from jUnit 4 to jUnit 5 and remove the dependency of `junit-vintage-engine` so that there will be one and only one version of unit test cases, which is jUnit5, in the whole project. ### SOP These two following articles are recommended for you to understand the whole process. In order to keep the instructions brief and concise, I summarize some key points of these two articles as well as add a few extra operations based on practice for your reference: * https://blogs.oracle.com/javamagazine/post/migrating-from-junit-4-to-junit-5-important-differences-and-benefits * https://blog.jetbrains.com/idea/2020/08/migrating-from-junit-4-to-junit-5/ BTW, I suggest you perform this SOP below by module or by file, instead of doing it for the whole project. This helps you increase efficiency. 1. Perform basic migration through `Intellij IDE` for the module you choose. ![screenshot1](https://user-images.githubusercontent.com/34905992/194875626-6560812b-c776-4601-9425-4eafea3288bb.png) 2. Replace `@RunWith(MockitoJUnitRunner.class)` with `@ExtendWith(MockitoExtension.class)` if necessary. 3. Replace `Assert` with `Assertions`. 4. Fix expected exception if necessary. ```java // jUnit 4 @Test(expected = Exception.class) public void testThrowsException() throws Exception { // ... } // jUnit 5 @Test public void testThrowsException() throws Exception { Assertions.assertThrows(Exception.class, () -> { //... }); } ``` 6. Fix timeout if necessary. ```java // jUnit 4 @Test(timeout = 10) public void testFailWithTimeout() throws InterruptedException { Thread.sleep(100); } // jUnit 5 @Test void testFailWithTimeout() throws InterruptedException { Assertions.assertTimeout(Duration.ofMillis(10), () -> Thread.sleep(100)); } Assertions.assertTimeout(Duration.ofMillis(60000), () -> {}); ``` 8. Replace `@Ignore` with `@Disable` if necessary. 9. Replace `org.junit.rules.TemporaryFolder` with `org.junit.jupiter.api.io.TempDir` and use `@TempDir` if necessary. 10. Run the UT file you changed to see whether all cases pass successfully. 11. Fix unnecessary stubbings if necessary. This is caused by changing `@Before` into `@BeforeEach`. The recommend method is to use `@MockitoSettings(strictness = Strictness.LENIENT)`. Alternatively, you could either remove the unnecessary stubbings from `@BeforeEach` and only put them where they needed or use `Mockito.lenient().when(......` for `Mockito.when(......` to bypass the `stubbing check`. 12. Global search in your module and make sure all `org.junit.xxxx` has been migrated to `org.junit.jupiter.api.xxx` ### PR Example * #12299 ### Sub-Tasks We hope to complete all the following sub-tasks ***before Oct. 25th*** because DSIP-10 depends on this issue and all UT cases are supposed to be migrated to jUnit 5 before the start of UT refactoring. - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `task-plugin` module: #12299 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `alert` and `api` module: #12313 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `dao` module: #12319 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `data-quality`, `datasource-plugin` and `registry` module: #12322 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `master`, `worker` and `remote` module: #12316 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `common`, `service` and `spi` module: #12317 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `microbench` and `e2e` module: #12333 - [x] Block explicit imports of jUnit 4 library. #12395 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12301
https://github.com/apache/dolphinscheduler/pull/12450
0eef2e3e10ca8d20d8a0ad59b0f0674f90ee321c
0a6e8af864423dac2aff279bf56f6f1ee95e95b9
2022-10-10T12:48:52Z
java
2022-10-20T04:12:17Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
List<Project> authedProjects = projectMapper.queryAuthedProjectListByUserId(userId); if (createProjects == null) { createProjects = new ArrayList<>(); } if (authedProjects != null) { createProjects.addAll(authedProjects); } return createProjects; } /** * list unauthorized udf function * * @param userId user id * @param needChecks data source id array * @return unauthorized udf function list */ @Override public <T> List<T> listUnauthorized(int userId, T[] needChecks, AuthorizationType authorizationType) { List<T> resultList = new ArrayList<>(); if (Objects.nonNull(needChecks) && needChecks.length > 0) { Set<T> originResSet = new HashSet<>(Arrays.asList(needChecks)); switch (authorizationType) { case RESOURCE_FILE_ID: case UDF_FILE: List<Resource> ownUdfResources = resourceMapper.listAuthorizedResourceById(userId, needChecks); addAuthorizedResources(ownUdfResources, userId); Set<Integer> authorizedResourceFiles = ownUdfResources.stream().map(Resource::getId).collect(toSet()); originResSet.removeAll(authorizedResourceFiles); break;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,301
[Migration][Test] jUnit4 -> jUnit5 UT cases migration
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * This is part of DSIP-10 #10573 * By this moment, we have added jUnit 5 dependencies #11332 and removed all `Powermock` related code #11405. It is high time that we migrate all the UT cases from jUnit 4 to jUnit 5 and remove the dependency of `junit-vintage-engine` so that there will be one and only one version of unit test cases, which is jUnit5, in the whole project. ### SOP These two following articles are recommended for you to understand the whole process. In order to keep the instructions brief and concise, I summarize some key points of these two articles as well as add a few extra operations based on practice for your reference: * https://blogs.oracle.com/javamagazine/post/migrating-from-junit-4-to-junit-5-important-differences-and-benefits * https://blog.jetbrains.com/idea/2020/08/migrating-from-junit-4-to-junit-5/ BTW, I suggest you perform this SOP below by module or by file, instead of doing it for the whole project. This helps you increase efficiency. 1. Perform basic migration through `Intellij IDE` for the module you choose. ![screenshot1](https://user-images.githubusercontent.com/34905992/194875626-6560812b-c776-4601-9425-4eafea3288bb.png) 2. Replace `@RunWith(MockitoJUnitRunner.class)` with `@ExtendWith(MockitoExtension.class)` if necessary. 3. Replace `Assert` with `Assertions`. 4. Fix expected exception if necessary. ```java // jUnit 4 @Test(expected = Exception.class) public void testThrowsException() throws Exception { // ... } // jUnit 5 @Test public void testThrowsException() throws Exception { Assertions.assertThrows(Exception.class, () -> { //... }); } ``` 6. Fix timeout if necessary. ```java // jUnit 4 @Test(timeout = 10) public void testFailWithTimeout() throws InterruptedException { Thread.sleep(100); } // jUnit 5 @Test void testFailWithTimeout() throws InterruptedException { Assertions.assertTimeout(Duration.ofMillis(10), () -> Thread.sleep(100)); } Assertions.assertTimeout(Duration.ofMillis(60000), () -> {}); ``` 8. Replace `@Ignore` with `@Disable` if necessary. 9. Replace `org.junit.rules.TemporaryFolder` with `org.junit.jupiter.api.io.TempDir` and use `@TempDir` if necessary. 10. Run the UT file you changed to see whether all cases pass successfully. 11. Fix unnecessary stubbings if necessary. This is caused by changing `@Before` into `@BeforeEach`. The recommend method is to use `@MockitoSettings(strictness = Strictness.LENIENT)`. Alternatively, you could either remove the unnecessary stubbings from `@BeforeEach` and only put them where they needed or use `Mockito.lenient().when(......` for `Mockito.when(......` to bypass the `stubbing check`. 12. Global search in your module and make sure all `org.junit.xxxx` has been migrated to `org.junit.jupiter.api.xxx` ### PR Example * #12299 ### Sub-Tasks We hope to complete all the following sub-tasks ***before Oct. 25th*** because DSIP-10 depends on this issue and all UT cases are supposed to be migrated to jUnit 5 before the start of UT refactoring. - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `task-plugin` module: #12299 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `alert` and `api` module: #12313 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `dao` module: #12319 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `data-quality`, `datasource-plugin` and `registry` module: #12322 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `master`, `worker` and `remote` module: #12316 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `common`, `service` and `spi` module: #12317 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `microbench` and `e2e` module: #12333 - [x] Block explicit imports of jUnit 4 library. #12395 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12301
https://github.com/apache/dolphinscheduler/pull/12450
0eef2e3e10ca8d20d8a0ad59b0f0674f90ee321c
0a6e8af864423dac2aff279bf56f6f1ee95e95b9
2022-10-10T12:48:52Z
java
2022-10-20T04:12:17Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
case RESOURCE_FILE_NAME: List<Resource> ownResources = resourceMapper.listAuthorizedResource(userId, needChecks); addAuthorizedResources(ownResources, userId); Set<String> authorizedResources = ownResources.stream().map(Resource::getFullName).collect(toSet()); originResSet.removeAll(authorizedResources); break; case DATASOURCE: Set<Integer> authorizedDatasources = dataSourceMapper.listAuthorizedDataSource(userId, needChecks) .stream().map(DataSource::getId).collect(toSet()); originResSet.removeAll(authorizedDatasources); break; case UDF: Set<Integer> authorizedUdfs = udfFuncMapper.listAuthorizedUdfFunc(userId, needChecks).stream() .map(UdfFunc::getId).collect(toSet()); originResSet.removeAll(authorizedUdfs); break; default: break; } resultList.addAll(originResSet); } return resultList; } /** * get user by user id * * @param userId user id * @return User */ @Override
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,301
[Migration][Test] jUnit4 -> jUnit5 UT cases migration
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * This is part of DSIP-10 #10573 * By this moment, we have added jUnit 5 dependencies #11332 and removed all `Powermock` related code #11405. It is high time that we migrate all the UT cases from jUnit 4 to jUnit 5 and remove the dependency of `junit-vintage-engine` so that there will be one and only one version of unit test cases, which is jUnit5, in the whole project. ### SOP These two following articles are recommended for you to understand the whole process. In order to keep the instructions brief and concise, I summarize some key points of these two articles as well as add a few extra operations based on practice for your reference: * https://blogs.oracle.com/javamagazine/post/migrating-from-junit-4-to-junit-5-important-differences-and-benefits * https://blog.jetbrains.com/idea/2020/08/migrating-from-junit-4-to-junit-5/ BTW, I suggest you perform this SOP below by module or by file, instead of doing it for the whole project. This helps you increase efficiency. 1. Perform basic migration through `Intellij IDE` for the module you choose. ![screenshot1](https://user-images.githubusercontent.com/34905992/194875626-6560812b-c776-4601-9425-4eafea3288bb.png) 2. Replace `@RunWith(MockitoJUnitRunner.class)` with `@ExtendWith(MockitoExtension.class)` if necessary. 3. Replace `Assert` with `Assertions`. 4. Fix expected exception if necessary. ```java // jUnit 4 @Test(expected = Exception.class) public void testThrowsException() throws Exception { // ... } // jUnit 5 @Test public void testThrowsException() throws Exception { Assertions.assertThrows(Exception.class, () -> { //... }); } ``` 6. Fix timeout if necessary. ```java // jUnit 4 @Test(timeout = 10) public void testFailWithTimeout() throws InterruptedException { Thread.sleep(100); } // jUnit 5 @Test void testFailWithTimeout() throws InterruptedException { Assertions.assertTimeout(Duration.ofMillis(10), () -> Thread.sleep(100)); } Assertions.assertTimeout(Duration.ofMillis(60000), () -> {}); ``` 8. Replace `@Ignore` with `@Disable` if necessary. 9. Replace `org.junit.rules.TemporaryFolder` with `org.junit.jupiter.api.io.TempDir` and use `@TempDir` if necessary. 10. Run the UT file you changed to see whether all cases pass successfully. 11. Fix unnecessary stubbings if necessary. This is caused by changing `@Before` into `@BeforeEach`. The recommend method is to use `@MockitoSettings(strictness = Strictness.LENIENT)`. Alternatively, you could either remove the unnecessary stubbings from `@BeforeEach` and only put them where they needed or use `Mockito.lenient().when(......` for `Mockito.when(......` to bypass the `stubbing check`. 12. Global search in your module and make sure all `org.junit.xxxx` has been migrated to `org.junit.jupiter.api.xxx` ### PR Example * #12299 ### Sub-Tasks We hope to complete all the following sub-tasks ***before Oct. 25th*** because DSIP-10 depends on this issue and all UT cases are supposed to be migrated to jUnit 5 before the start of UT refactoring. - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `task-plugin` module: #12299 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `alert` and `api` module: #12313 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `dao` module: #12319 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `data-quality`, `datasource-plugin` and `registry` module: #12322 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `master`, `worker` and `remote` module: #12316 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `common`, `service` and `spi` module: #12317 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `microbench` and `e2e` module: #12333 - [x] Block explicit imports of jUnit 4 library. #12395 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12301
https://github.com/apache/dolphinscheduler/pull/12450
0eef2e3e10ca8d20d8a0ad59b0f0674f90ee321c
0a6e8af864423dac2aff279bf56f6f1ee95e95b9
2022-10-10T12:48:52Z
java
2022-10-20T04:12:17Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
public User getUserById(int userId) { return userMapper.selectById(userId); } /** * get resource by resource id * * @param resourceId resource id * @return Resource */ @Override public Resource getResourceById(int resourceId) { return resourceMapper.selectById(resourceId); } /** * list resources by ids * * @param resIds resIds * @return resource list */ @Override public List<Resource> listResourceByIds(Integer[] resIds) { return resourceMapper.listResourceByIds(resIds); } /** * format task app id in task instance */ @Override public String formatTaskAppId(TaskInstance taskInstance) { ProcessInstance processInstance = findProcessInstanceById(taskInstance.getProcessInstanceId()); if (processInstance == null) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,301
[Migration][Test] jUnit4 -> jUnit5 UT cases migration
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * This is part of DSIP-10 #10573 * By this moment, we have added jUnit 5 dependencies #11332 and removed all `Powermock` related code #11405. It is high time that we migrate all the UT cases from jUnit 4 to jUnit 5 and remove the dependency of `junit-vintage-engine` so that there will be one and only one version of unit test cases, which is jUnit5, in the whole project. ### SOP These two following articles are recommended for you to understand the whole process. In order to keep the instructions brief and concise, I summarize some key points of these two articles as well as add a few extra operations based on practice for your reference: * https://blogs.oracle.com/javamagazine/post/migrating-from-junit-4-to-junit-5-important-differences-and-benefits * https://blog.jetbrains.com/idea/2020/08/migrating-from-junit-4-to-junit-5/ BTW, I suggest you perform this SOP below by module or by file, instead of doing it for the whole project. This helps you increase efficiency. 1. Perform basic migration through `Intellij IDE` for the module you choose. ![screenshot1](https://user-images.githubusercontent.com/34905992/194875626-6560812b-c776-4601-9425-4eafea3288bb.png) 2. Replace `@RunWith(MockitoJUnitRunner.class)` with `@ExtendWith(MockitoExtension.class)` if necessary. 3. Replace `Assert` with `Assertions`. 4. Fix expected exception if necessary. ```java // jUnit 4 @Test(expected = Exception.class) public void testThrowsException() throws Exception { // ... } // jUnit 5 @Test public void testThrowsException() throws Exception { Assertions.assertThrows(Exception.class, () -> { //... }); } ``` 6. Fix timeout if necessary. ```java // jUnit 4 @Test(timeout = 10) public void testFailWithTimeout() throws InterruptedException { Thread.sleep(100); } // jUnit 5 @Test void testFailWithTimeout() throws InterruptedException { Assertions.assertTimeout(Duration.ofMillis(10), () -> Thread.sleep(100)); } Assertions.assertTimeout(Duration.ofMillis(60000), () -> {}); ``` 8. Replace `@Ignore` with `@Disable` if necessary. 9. Replace `org.junit.rules.TemporaryFolder` with `org.junit.jupiter.api.io.TempDir` and use `@TempDir` if necessary. 10. Run the UT file you changed to see whether all cases pass successfully. 11. Fix unnecessary stubbings if necessary. This is caused by changing `@Before` into `@BeforeEach`. The recommend method is to use `@MockitoSettings(strictness = Strictness.LENIENT)`. Alternatively, you could either remove the unnecessary stubbings from `@BeforeEach` and only put them where they needed or use `Mockito.lenient().when(......` for `Mockito.when(......` to bypass the `stubbing check`. 12. Global search in your module and make sure all `org.junit.xxxx` has been migrated to `org.junit.jupiter.api.xxx` ### PR Example * #12299 ### Sub-Tasks We hope to complete all the following sub-tasks ***before Oct. 25th*** because DSIP-10 depends on this issue and all UT cases are supposed to be migrated to jUnit 5 before the start of UT refactoring. - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `task-plugin` module: #12299 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `alert` and `api` module: #12313 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `dao` module: #12319 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `data-quality`, `datasource-plugin` and `registry` module: #12322 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `master`, `worker` and `remote` module: #12316 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `common`, `service` and `spi` module: #12317 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `microbench` and `e2e` module: #12333 - [x] Block explicit imports of jUnit 4 library. #12395 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12301
https://github.com/apache/dolphinscheduler/pull/12450
0eef2e3e10ca8d20d8a0ad59b0f0674f90ee321c
0a6e8af864423dac2aff279bf56f6f1ee95e95b9
2022-10-10T12:48:52Z
java
2022-10-20T04:12:17Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
return ""; } ProcessDefinition definition = findProcessDefinition(processInstance.getProcessDefinitionCode(), processInstance.getProcessDefinitionVersion()); if (definition == null) { return ""; } return String.format("%s_%s_%s", definition.getId(), processInstance.getId(), taskInstance.getId()); } /** * switch process definition version to process definition log version */ @Override public int switchVersion(ProcessDefinition processDefinition, ProcessDefinitionLog processDefinitionLog) { if (null == processDefinition || null == processDefinitionLog) { return Constants.DEFINITION_FAILURE; } processDefinitionLog.setId(processDefinition.getId()); processDefinitionLog.setReleaseState(ReleaseState.OFFLINE); processDefinitionLog.setFlag(Flag.YES); int result = processDefineMapper.updateById(processDefinitionLog); if (result > 0) { result = switchProcessTaskRelationVersion(processDefinitionLog); if (result <= 0) { return Constants.EXIT_CODE_FAILURE; } } return result; } @Override
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,301
[Migration][Test] jUnit4 -> jUnit5 UT cases migration
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * This is part of DSIP-10 #10573 * By this moment, we have added jUnit 5 dependencies #11332 and removed all `Powermock` related code #11405. It is high time that we migrate all the UT cases from jUnit 4 to jUnit 5 and remove the dependency of `junit-vintage-engine` so that there will be one and only one version of unit test cases, which is jUnit5, in the whole project. ### SOP These two following articles are recommended for you to understand the whole process. In order to keep the instructions brief and concise, I summarize some key points of these two articles as well as add a few extra operations based on practice for your reference: * https://blogs.oracle.com/javamagazine/post/migrating-from-junit-4-to-junit-5-important-differences-and-benefits * https://blog.jetbrains.com/idea/2020/08/migrating-from-junit-4-to-junit-5/ BTW, I suggest you perform this SOP below by module or by file, instead of doing it for the whole project. This helps you increase efficiency. 1. Perform basic migration through `Intellij IDE` for the module you choose. ![screenshot1](https://user-images.githubusercontent.com/34905992/194875626-6560812b-c776-4601-9425-4eafea3288bb.png) 2. Replace `@RunWith(MockitoJUnitRunner.class)` with `@ExtendWith(MockitoExtension.class)` if necessary. 3. Replace `Assert` with `Assertions`. 4. Fix expected exception if necessary. ```java // jUnit 4 @Test(expected = Exception.class) public void testThrowsException() throws Exception { // ... } // jUnit 5 @Test public void testThrowsException() throws Exception { Assertions.assertThrows(Exception.class, () -> { //... }); } ``` 6. Fix timeout if necessary. ```java // jUnit 4 @Test(timeout = 10) public void testFailWithTimeout() throws InterruptedException { Thread.sleep(100); } // jUnit 5 @Test void testFailWithTimeout() throws InterruptedException { Assertions.assertTimeout(Duration.ofMillis(10), () -> Thread.sleep(100)); } Assertions.assertTimeout(Duration.ofMillis(60000), () -> {}); ``` 8. Replace `@Ignore` with `@Disable` if necessary. 9. Replace `org.junit.rules.TemporaryFolder` with `org.junit.jupiter.api.io.TempDir` and use `@TempDir` if necessary. 10. Run the UT file you changed to see whether all cases pass successfully. 11. Fix unnecessary stubbings if necessary. This is caused by changing `@Before` into `@BeforeEach`. The recommend method is to use `@MockitoSettings(strictness = Strictness.LENIENT)`. Alternatively, you could either remove the unnecessary stubbings from `@BeforeEach` and only put them where they needed or use `Mockito.lenient().when(......` for `Mockito.when(......` to bypass the `stubbing check`. 12. Global search in your module and make sure all `org.junit.xxxx` has been migrated to `org.junit.jupiter.api.xxx` ### PR Example * #12299 ### Sub-Tasks We hope to complete all the following sub-tasks ***before Oct. 25th*** because DSIP-10 depends on this issue and all UT cases are supposed to be migrated to jUnit 5 before the start of UT refactoring. - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `task-plugin` module: #12299 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `alert` and `api` module: #12313 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `dao` module: #12319 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `data-quality`, `datasource-plugin` and `registry` module: #12322 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `master`, `worker` and `remote` module: #12316 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `common`, `service` and `spi` module: #12317 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `microbench` and `e2e` module: #12333 - [x] Block explicit imports of jUnit 4 library. #12395 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12301
https://github.com/apache/dolphinscheduler/pull/12450
0eef2e3e10ca8d20d8a0ad59b0f0674f90ee321c
0a6e8af864423dac2aff279bf56f6f1ee95e95b9
2022-10-10T12:48:52Z
java
2022-10-20T04:12:17Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
public int switchProcessTaskRelationVersion(ProcessDefinition processDefinition) { List<ProcessTaskRelation> processTaskRelationList = processTaskRelationMapper .queryByProcessCode(processDefinition.getProjectCode(), processDefinition.getCode()); if (!processTaskRelationList.isEmpty()) { processTaskRelationMapper.deleteByCode(processDefinition.getProjectCode(), processDefinition.getCode()); } List<ProcessTaskRelation> processTaskRelationListFromLog = processTaskRelationLogMapper .queryByProcessCodeAndVersion(processDefinition.getCode(), processDefinition.getVersion()).stream() .map(ProcessTaskRelation::new).collect(Collectors.toList()); int batchInsert = processTaskRelationMapper.batchInsert(processTaskRelationListFromLog); if (batchInsert == 0) { return Constants.EXIT_CODE_FAILURE; } else { int result = 0; for (ProcessTaskRelation taskRelation : processTaskRelationListFromLog) { int switchResult = switchTaskDefinitionVersion(taskRelation.getPostTaskCode(), taskRelation.getPostTaskVersion()); if (switchResult != Constants.EXIT_CODE_FAILURE) { result++; } } return result; } } @Override public int switchTaskDefinitionVersion(long taskCode, int taskVersion) { TaskDefinition taskDefinition = taskDefinitionMapper.queryByCode(taskCode); if (taskDefinition == null) { return Constants.EXIT_CODE_FAILURE; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,301
[Migration][Test] jUnit4 -> jUnit5 UT cases migration
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * This is part of DSIP-10 #10573 * By this moment, we have added jUnit 5 dependencies #11332 and removed all `Powermock` related code #11405. It is high time that we migrate all the UT cases from jUnit 4 to jUnit 5 and remove the dependency of `junit-vintage-engine` so that there will be one and only one version of unit test cases, which is jUnit5, in the whole project. ### SOP These two following articles are recommended for you to understand the whole process. In order to keep the instructions brief and concise, I summarize some key points of these two articles as well as add a few extra operations based on practice for your reference: * https://blogs.oracle.com/javamagazine/post/migrating-from-junit-4-to-junit-5-important-differences-and-benefits * https://blog.jetbrains.com/idea/2020/08/migrating-from-junit-4-to-junit-5/ BTW, I suggest you perform this SOP below by module or by file, instead of doing it for the whole project. This helps you increase efficiency. 1. Perform basic migration through `Intellij IDE` for the module you choose. ![screenshot1](https://user-images.githubusercontent.com/34905992/194875626-6560812b-c776-4601-9425-4eafea3288bb.png) 2. Replace `@RunWith(MockitoJUnitRunner.class)` with `@ExtendWith(MockitoExtension.class)` if necessary. 3. Replace `Assert` with `Assertions`. 4. Fix expected exception if necessary. ```java // jUnit 4 @Test(expected = Exception.class) public void testThrowsException() throws Exception { // ... } // jUnit 5 @Test public void testThrowsException() throws Exception { Assertions.assertThrows(Exception.class, () -> { //... }); } ``` 6. Fix timeout if necessary. ```java // jUnit 4 @Test(timeout = 10) public void testFailWithTimeout() throws InterruptedException { Thread.sleep(100); } // jUnit 5 @Test void testFailWithTimeout() throws InterruptedException { Assertions.assertTimeout(Duration.ofMillis(10), () -> Thread.sleep(100)); } Assertions.assertTimeout(Duration.ofMillis(60000), () -> {}); ``` 8. Replace `@Ignore` with `@Disable` if necessary. 9. Replace `org.junit.rules.TemporaryFolder` with `org.junit.jupiter.api.io.TempDir` and use `@TempDir` if necessary. 10. Run the UT file you changed to see whether all cases pass successfully. 11. Fix unnecessary stubbings if necessary. This is caused by changing `@Before` into `@BeforeEach`. The recommend method is to use `@MockitoSettings(strictness = Strictness.LENIENT)`. Alternatively, you could either remove the unnecessary stubbings from `@BeforeEach` and only put them where they needed or use `Mockito.lenient().when(......` for `Mockito.when(......` to bypass the `stubbing check`. 12. Global search in your module and make sure all `org.junit.xxxx` has been migrated to `org.junit.jupiter.api.xxx` ### PR Example * #12299 ### Sub-Tasks We hope to complete all the following sub-tasks ***before Oct. 25th*** because DSIP-10 depends on this issue and all UT cases are supposed to be migrated to jUnit 5 before the start of UT refactoring. - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `task-plugin` module: #12299 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `alert` and `api` module: #12313 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `dao` module: #12319 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `data-quality`, `datasource-plugin` and `registry` module: #12322 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `master`, `worker` and `remote` module: #12316 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `common`, `service` and `spi` module: #12317 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `microbench` and `e2e` module: #12333 - [x] Block explicit imports of jUnit 4 library. #12395 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12301
https://github.com/apache/dolphinscheduler/pull/12450
0eef2e3e10ca8d20d8a0ad59b0f0674f90ee321c
0a6e8af864423dac2aff279bf56f6f1ee95e95b9
2022-10-10T12:48:52Z
java
2022-10-20T04:12:17Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
if (taskDefinition.getVersion() == taskVersion) { return Constants.EXIT_CODE_SUCCESS; } TaskDefinitionLog taskDefinitionUpdate = taskDefinitionLogMapper.queryByDefinitionCodeAndVersion(taskCode, taskVersion); if (taskDefinitionUpdate == null) { return Constants.EXIT_CODE_FAILURE; } taskDefinitionUpdate.setUpdateTime(new Date()); taskDefinitionUpdate.setId(taskDefinition.getId()); return taskDefinitionMapper.updateById(taskDefinitionUpdate); } /** * get resource ids * * @param taskDefinition taskDefinition * @return resource ids */ @Override public String getResourceIds(TaskDefinition taskDefinition) { Set<Integer> resourceIds = null; AbstractParameters params = taskPluginManager.getParameters(ParametersNode.builder() .taskType(taskDefinition.getTaskType()).taskParams(taskDefinition.getTaskParams()).build()); if (params != null && CollectionUtils.isNotEmpty(params.getResourceFilesList())) { resourceIds = params.getResourceFilesList().stream() .filter(t -> t.getId() != null) .map(ResourceInfo::getId) .collect(toSet()); } if (CollectionUtils.isEmpty(resourceIds)) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,301
[Migration][Test] jUnit4 -> jUnit5 UT cases migration
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * This is part of DSIP-10 #10573 * By this moment, we have added jUnit 5 dependencies #11332 and removed all `Powermock` related code #11405. It is high time that we migrate all the UT cases from jUnit 4 to jUnit 5 and remove the dependency of `junit-vintage-engine` so that there will be one and only one version of unit test cases, which is jUnit5, in the whole project. ### SOP These two following articles are recommended for you to understand the whole process. In order to keep the instructions brief and concise, I summarize some key points of these two articles as well as add a few extra operations based on practice for your reference: * https://blogs.oracle.com/javamagazine/post/migrating-from-junit-4-to-junit-5-important-differences-and-benefits * https://blog.jetbrains.com/idea/2020/08/migrating-from-junit-4-to-junit-5/ BTW, I suggest you perform this SOP below by module or by file, instead of doing it for the whole project. This helps you increase efficiency. 1. Perform basic migration through `Intellij IDE` for the module you choose. ![screenshot1](https://user-images.githubusercontent.com/34905992/194875626-6560812b-c776-4601-9425-4eafea3288bb.png) 2. Replace `@RunWith(MockitoJUnitRunner.class)` with `@ExtendWith(MockitoExtension.class)` if necessary. 3. Replace `Assert` with `Assertions`. 4. Fix expected exception if necessary. ```java // jUnit 4 @Test(expected = Exception.class) public void testThrowsException() throws Exception { // ... } // jUnit 5 @Test public void testThrowsException() throws Exception { Assertions.assertThrows(Exception.class, () -> { //... }); } ``` 6. Fix timeout if necessary. ```java // jUnit 4 @Test(timeout = 10) public void testFailWithTimeout() throws InterruptedException { Thread.sleep(100); } // jUnit 5 @Test void testFailWithTimeout() throws InterruptedException { Assertions.assertTimeout(Duration.ofMillis(10), () -> Thread.sleep(100)); } Assertions.assertTimeout(Duration.ofMillis(60000), () -> {}); ``` 8. Replace `@Ignore` with `@Disable` if necessary. 9. Replace `org.junit.rules.TemporaryFolder` with `org.junit.jupiter.api.io.TempDir` and use `@TempDir` if necessary. 10. Run the UT file you changed to see whether all cases pass successfully. 11. Fix unnecessary stubbings if necessary. This is caused by changing `@Before` into `@BeforeEach`. The recommend method is to use `@MockitoSettings(strictness = Strictness.LENIENT)`. Alternatively, you could either remove the unnecessary stubbings from `@BeforeEach` and only put them where they needed or use `Mockito.lenient().when(......` for `Mockito.when(......` to bypass the `stubbing check`. 12. Global search in your module and make sure all `org.junit.xxxx` has been migrated to `org.junit.jupiter.api.xxx` ### PR Example * #12299 ### Sub-Tasks We hope to complete all the following sub-tasks ***before Oct. 25th*** because DSIP-10 depends on this issue and all UT cases are supposed to be migrated to jUnit 5 before the start of UT refactoring. - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `task-plugin` module: #12299 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `alert` and `api` module: #12313 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `dao` module: #12319 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `data-quality`, `datasource-plugin` and `registry` module: #12322 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `master`, `worker` and `remote` module: #12316 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `common`, `service` and `spi` module: #12317 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `microbench` and `e2e` module: #12333 - [x] Block explicit imports of jUnit 4 library. #12395 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12301
https://github.com/apache/dolphinscheduler/pull/12450
0eef2e3e10ca8d20d8a0ad59b0f0674f90ee321c
0a6e8af864423dac2aff279bf56f6f1ee95e95b9
2022-10-10T12:48:52Z
java
2022-10-20T04:12:17Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
return ""; } return Joiner.on(",").join(resourceIds); } @Override public int saveTaskDefine(User operator, long projectCode, List<TaskDefinitionLog> taskDefinitionLogs, Boolean syncDefine) { Date now = new Date(); List<TaskDefinitionLog> newTaskDefinitionLogs = new ArrayList<>(); List<TaskDefinitionLog> updateTaskDefinitionLogs = new ArrayList<>(); for (TaskDefinitionLog taskDefinitionLog : taskDefinitionLogs) { taskDefinitionLog.setProjectCode(projectCode); taskDefinitionLog.setUpdateTime(now); taskDefinitionLog.setOperateTime(now); taskDefinitionLog.setOperator(operator.getId()); taskDefinitionLog.setResourceIds(getResourceIds(taskDefinitionLog)); if (taskDefinitionLog.getCode() == 0) { taskDefinitionLog.setCode(CodeGenerateUtils.getInstance().genCode()); } if (taskDefinitionLog.getVersion() == 0) { taskDefinitionLog.setVersion(Constants.VERSION_FIRST); } TaskDefinitionLog definitionCodeAndVersion = taskDefinitionLogMapper.queryByDefinitionCodeAndVersion( taskDefinitionLog.getCode(), taskDefinitionLog.getVersion()); if (definitionCodeAndVersion == null) { taskDefinitionLog.setUserId(operator.getId()); taskDefinitionLog.setCreateTime(now); newTaskDefinitionLogs.add(taskDefinitionLog); continue;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,301
[Migration][Test] jUnit4 -> jUnit5 UT cases migration
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * This is part of DSIP-10 #10573 * By this moment, we have added jUnit 5 dependencies #11332 and removed all `Powermock` related code #11405. It is high time that we migrate all the UT cases from jUnit 4 to jUnit 5 and remove the dependency of `junit-vintage-engine` so that there will be one and only one version of unit test cases, which is jUnit5, in the whole project. ### SOP These two following articles are recommended for you to understand the whole process. In order to keep the instructions brief and concise, I summarize some key points of these two articles as well as add a few extra operations based on practice for your reference: * https://blogs.oracle.com/javamagazine/post/migrating-from-junit-4-to-junit-5-important-differences-and-benefits * https://blog.jetbrains.com/idea/2020/08/migrating-from-junit-4-to-junit-5/ BTW, I suggest you perform this SOP below by module or by file, instead of doing it for the whole project. This helps you increase efficiency. 1. Perform basic migration through `Intellij IDE` for the module you choose. ![screenshot1](https://user-images.githubusercontent.com/34905992/194875626-6560812b-c776-4601-9425-4eafea3288bb.png) 2. Replace `@RunWith(MockitoJUnitRunner.class)` with `@ExtendWith(MockitoExtension.class)` if necessary. 3. Replace `Assert` with `Assertions`. 4. Fix expected exception if necessary. ```java // jUnit 4 @Test(expected = Exception.class) public void testThrowsException() throws Exception { // ... } // jUnit 5 @Test public void testThrowsException() throws Exception { Assertions.assertThrows(Exception.class, () -> { //... }); } ``` 6. Fix timeout if necessary. ```java // jUnit 4 @Test(timeout = 10) public void testFailWithTimeout() throws InterruptedException { Thread.sleep(100); } // jUnit 5 @Test void testFailWithTimeout() throws InterruptedException { Assertions.assertTimeout(Duration.ofMillis(10), () -> Thread.sleep(100)); } Assertions.assertTimeout(Duration.ofMillis(60000), () -> {}); ``` 8. Replace `@Ignore` with `@Disable` if necessary. 9. Replace `org.junit.rules.TemporaryFolder` with `org.junit.jupiter.api.io.TempDir` and use `@TempDir` if necessary. 10. Run the UT file you changed to see whether all cases pass successfully. 11. Fix unnecessary stubbings if necessary. This is caused by changing `@Before` into `@BeforeEach`. The recommend method is to use `@MockitoSettings(strictness = Strictness.LENIENT)`. Alternatively, you could either remove the unnecessary stubbings from `@BeforeEach` and only put them where they needed or use `Mockito.lenient().when(......` for `Mockito.when(......` to bypass the `stubbing check`. 12. Global search in your module and make sure all `org.junit.xxxx` has been migrated to `org.junit.jupiter.api.xxx` ### PR Example * #12299 ### Sub-Tasks We hope to complete all the following sub-tasks ***before Oct. 25th*** because DSIP-10 depends on this issue and all UT cases are supposed to be migrated to jUnit 5 before the start of UT refactoring. - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `task-plugin` module: #12299 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `alert` and `api` module: #12313 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `dao` module: #12319 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `data-quality`, `datasource-plugin` and `registry` module: #12322 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `master`, `worker` and `remote` module: #12316 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `common`, `service` and `spi` module: #12317 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `microbench` and `e2e` module: #12333 - [x] Block explicit imports of jUnit 4 library. #12395 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12301
https://github.com/apache/dolphinscheduler/pull/12450
0eef2e3e10ca8d20d8a0ad59b0f0674f90ee321c
0a6e8af864423dac2aff279bf56f6f1ee95e95b9
2022-10-10T12:48:52Z
java
2022-10-20T04:12:17Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
} if (taskDefinitionLog.equals(definitionCodeAndVersion)) { continue; } taskDefinitionLog.setUserId(definitionCodeAndVersion.getUserId()); Integer version = taskDefinitionLogMapper.queryMaxVersionForDefinition(taskDefinitionLog.getCode()); taskDefinitionLog.setVersion(version + 1); taskDefinitionLog.setCreateTime(definitionCodeAndVersion.getCreateTime()); updateTaskDefinitionLogs.add(taskDefinitionLog); } if (CollectionUtils.isNotEmpty(updateTaskDefinitionLogs)) { List<Long> taskDefinitionCodes = updateTaskDefinitionLogs .stream() .map(TaskDefinition::getCode) .distinct() .collect(Collectors.toList()); Map<Long, TaskDefinition> taskDefinitionMap = taskDefinitionMapper.queryByCodeList(taskDefinitionCodes) .stream() .collect(Collectors.toMap(TaskDefinition::getCode, Function.identity())); for (TaskDefinitionLog taskDefinitionToUpdate : updateTaskDefinitionLogs) { TaskDefinition task = taskDefinitionMap.get(taskDefinitionToUpdate.getCode()); if (task == null) { newTaskDefinitionLogs.add(taskDefinitionToUpdate); } } } int updateResult = 0;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,301
[Migration][Test] jUnit4 -> jUnit5 UT cases migration
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * This is part of DSIP-10 #10573 * By this moment, we have added jUnit 5 dependencies #11332 and removed all `Powermock` related code #11405. It is high time that we migrate all the UT cases from jUnit 4 to jUnit 5 and remove the dependency of `junit-vintage-engine` so that there will be one and only one version of unit test cases, which is jUnit5, in the whole project. ### SOP These two following articles are recommended for you to understand the whole process. In order to keep the instructions brief and concise, I summarize some key points of these two articles as well as add a few extra operations based on practice for your reference: * https://blogs.oracle.com/javamagazine/post/migrating-from-junit-4-to-junit-5-important-differences-and-benefits * https://blog.jetbrains.com/idea/2020/08/migrating-from-junit-4-to-junit-5/ BTW, I suggest you perform this SOP below by module or by file, instead of doing it for the whole project. This helps you increase efficiency. 1. Perform basic migration through `Intellij IDE` for the module you choose. ![screenshot1](https://user-images.githubusercontent.com/34905992/194875626-6560812b-c776-4601-9425-4eafea3288bb.png) 2. Replace `@RunWith(MockitoJUnitRunner.class)` with `@ExtendWith(MockitoExtension.class)` if necessary. 3. Replace `Assert` with `Assertions`. 4. Fix expected exception if necessary. ```java // jUnit 4 @Test(expected = Exception.class) public void testThrowsException() throws Exception { // ... } // jUnit 5 @Test public void testThrowsException() throws Exception { Assertions.assertThrows(Exception.class, () -> { //... }); } ``` 6. Fix timeout if necessary. ```java // jUnit 4 @Test(timeout = 10) public void testFailWithTimeout() throws InterruptedException { Thread.sleep(100); } // jUnit 5 @Test void testFailWithTimeout() throws InterruptedException { Assertions.assertTimeout(Duration.ofMillis(10), () -> Thread.sleep(100)); } Assertions.assertTimeout(Duration.ofMillis(60000), () -> {}); ``` 8. Replace `@Ignore` with `@Disable` if necessary. 9. Replace `org.junit.rules.TemporaryFolder` with `org.junit.jupiter.api.io.TempDir` and use `@TempDir` if necessary. 10. Run the UT file you changed to see whether all cases pass successfully. 11. Fix unnecessary stubbings if necessary. This is caused by changing `@Before` into `@BeforeEach`. The recommend method is to use `@MockitoSettings(strictness = Strictness.LENIENT)`. Alternatively, you could either remove the unnecessary stubbings from `@BeforeEach` and only put them where they needed or use `Mockito.lenient().when(......` for `Mockito.when(......` to bypass the `stubbing check`. 12. Global search in your module and make sure all `org.junit.xxxx` has been migrated to `org.junit.jupiter.api.xxx` ### PR Example * #12299 ### Sub-Tasks We hope to complete all the following sub-tasks ***before Oct. 25th*** because DSIP-10 depends on this issue and all UT cases are supposed to be migrated to jUnit 5 before the start of UT refactoring. - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `task-plugin` module: #12299 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `alert` and `api` module: #12313 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `dao` module: #12319 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `data-quality`, `datasource-plugin` and `registry` module: #12322 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `master`, `worker` and `remote` module: #12316 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `common`, `service` and `spi` module: #12317 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `microbench` and `e2e` module: #12333 - [x] Block explicit imports of jUnit 4 library. #12395 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12301
https://github.com/apache/dolphinscheduler/pull/12450
0eef2e3e10ca8d20d8a0ad59b0f0674f90ee321c
0a6e8af864423dac2aff279bf56f6f1ee95e95b9
2022-10-10T12:48:52Z
java
2022-10-20T04:12:17Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
int insertResult = 0; if (CollectionUtils.isNotEmpty(newTaskDefinitionLogs)) { insertResult += taskDefinitionLogMapper.batchInsert(newTaskDefinitionLogs); } if (CollectionUtils.isNotEmpty(updateTaskDefinitionLogs)) { insertResult += taskDefinitionLogMapper.batchInsert(updateTaskDefinitionLogs); } if (CollectionUtils.isNotEmpty(newTaskDefinitionLogs) && Boolean.TRUE.equals(syncDefine)) { updateResult += taskDefinitionMapper.batchInsert(newTaskDefinitionLogs); } if (CollectionUtils.isNotEmpty(updateTaskDefinitionLogs) && Boolean.TRUE.equals(syncDefine)) { for (TaskDefinitionLog taskDefinitionLog : updateTaskDefinitionLogs) { updateResult += taskDefinitionMapper.updateById(taskDefinitionLog); } } return (insertResult & updateResult) > 0 ? 1 : Constants.EXIT_CODE_SUCCESS; } /** * save processDefinition (including create or update processDefinition) */ @Override public int saveProcessDefine(User operator, ProcessDefinition processDefinition, Boolean syncDefine, Boolean isFromProcessDefine) { ProcessDefinitionLog processDefinitionLog = new ProcessDefinitionLog(processDefinition); Integer version = processDefineLogMapper.queryMaxVersionForDefinition(processDefinition.getCode()); int insertVersion = version == null || version == 0 ? Constants.VERSION_FIRST : version + 1; processDefinitionLog.setVersion(insertVersion); processDefinitionLog .setReleaseState(!isFromProcessDefine || processDefinitionLog.getReleaseState() == ReleaseState.ONLINE ? ReleaseState.ONLINE
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,301
[Migration][Test] jUnit4 -> jUnit5 UT cases migration
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * This is part of DSIP-10 #10573 * By this moment, we have added jUnit 5 dependencies #11332 and removed all `Powermock` related code #11405. It is high time that we migrate all the UT cases from jUnit 4 to jUnit 5 and remove the dependency of `junit-vintage-engine` so that there will be one and only one version of unit test cases, which is jUnit5, in the whole project. ### SOP These two following articles are recommended for you to understand the whole process. In order to keep the instructions brief and concise, I summarize some key points of these two articles as well as add a few extra operations based on practice for your reference: * https://blogs.oracle.com/javamagazine/post/migrating-from-junit-4-to-junit-5-important-differences-and-benefits * https://blog.jetbrains.com/idea/2020/08/migrating-from-junit-4-to-junit-5/ BTW, I suggest you perform this SOP below by module or by file, instead of doing it for the whole project. This helps you increase efficiency. 1. Perform basic migration through `Intellij IDE` for the module you choose. ![screenshot1](https://user-images.githubusercontent.com/34905992/194875626-6560812b-c776-4601-9425-4eafea3288bb.png) 2. Replace `@RunWith(MockitoJUnitRunner.class)` with `@ExtendWith(MockitoExtension.class)` if necessary. 3. Replace `Assert` with `Assertions`. 4. Fix expected exception if necessary. ```java // jUnit 4 @Test(expected = Exception.class) public void testThrowsException() throws Exception { // ... } // jUnit 5 @Test public void testThrowsException() throws Exception { Assertions.assertThrows(Exception.class, () -> { //... }); } ``` 6. Fix timeout if necessary. ```java // jUnit 4 @Test(timeout = 10) public void testFailWithTimeout() throws InterruptedException { Thread.sleep(100); } // jUnit 5 @Test void testFailWithTimeout() throws InterruptedException { Assertions.assertTimeout(Duration.ofMillis(10), () -> Thread.sleep(100)); } Assertions.assertTimeout(Duration.ofMillis(60000), () -> {}); ``` 8. Replace `@Ignore` with `@Disable` if necessary. 9. Replace `org.junit.rules.TemporaryFolder` with `org.junit.jupiter.api.io.TempDir` and use `@TempDir` if necessary. 10. Run the UT file you changed to see whether all cases pass successfully. 11. Fix unnecessary stubbings if necessary. This is caused by changing `@Before` into `@BeforeEach`. The recommend method is to use `@MockitoSettings(strictness = Strictness.LENIENT)`. Alternatively, you could either remove the unnecessary stubbings from `@BeforeEach` and only put them where they needed or use `Mockito.lenient().when(......` for `Mockito.when(......` to bypass the `stubbing check`. 12. Global search in your module and make sure all `org.junit.xxxx` has been migrated to `org.junit.jupiter.api.xxx` ### PR Example * #12299 ### Sub-Tasks We hope to complete all the following sub-tasks ***before Oct. 25th*** because DSIP-10 depends on this issue and all UT cases are supposed to be migrated to jUnit 5 before the start of UT refactoring. - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `task-plugin` module: #12299 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `alert` and `api` module: #12313 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `dao` module: #12319 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `data-quality`, `datasource-plugin` and `registry` module: #12322 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `master`, `worker` and `remote` module: #12316 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `common`, `service` and `spi` module: #12317 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `microbench` and `e2e` module: #12333 - [x] Block explicit imports of jUnit 4 library. #12395 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12301
https://github.com/apache/dolphinscheduler/pull/12450
0eef2e3e10ca8d20d8a0ad59b0f0674f90ee321c
0a6e8af864423dac2aff279bf56f6f1ee95e95b9
2022-10-10T12:48:52Z
java
2022-10-20T04:12:17Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
: ReleaseState.OFFLINE); processDefinitionLog.setOperator(operator.getId()); processDefinitionLog.setOperateTime(processDefinition.getUpdateTime()); processDefinitionLog.setId(null); int insertLog = processDefineLogMapper.insert(processDefinitionLog); int result = 1; if (Boolean.TRUE.equals(syncDefine)) { if (processDefinition.getId() == null) { result = processDefineMapper.insert(processDefinitionLog); } else { processDefinitionLog.setId(processDefinition.getId()); result = processDefineMapper.updateById(processDefinitionLog); } } return (insertLog & result) > 0 ? insertVersion : 0; } /** * save task relations */ @Override public int saveTaskRelation(User operator, long projectCode, long processDefinitionCode, int processDefinitionVersion, List<ProcessTaskRelationLog> taskRelationList, List<TaskDefinitionLog> taskDefinitionLogs, Boolean syncDefine) { if (taskRelationList.isEmpty()) { return Constants.EXIT_CODE_SUCCESS; } Map<Long, TaskDefinitionLog> taskDefinitionLogMap = null; if (CollectionUtils.isNotEmpty(taskDefinitionLogs)) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,301
[Migration][Test] jUnit4 -> jUnit5 UT cases migration
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * This is part of DSIP-10 #10573 * By this moment, we have added jUnit 5 dependencies #11332 and removed all `Powermock` related code #11405. It is high time that we migrate all the UT cases from jUnit 4 to jUnit 5 and remove the dependency of `junit-vintage-engine` so that there will be one and only one version of unit test cases, which is jUnit5, in the whole project. ### SOP These two following articles are recommended for you to understand the whole process. In order to keep the instructions brief and concise, I summarize some key points of these two articles as well as add a few extra operations based on practice for your reference: * https://blogs.oracle.com/javamagazine/post/migrating-from-junit-4-to-junit-5-important-differences-and-benefits * https://blog.jetbrains.com/idea/2020/08/migrating-from-junit-4-to-junit-5/ BTW, I suggest you perform this SOP below by module or by file, instead of doing it for the whole project. This helps you increase efficiency. 1. Perform basic migration through `Intellij IDE` for the module you choose. ![screenshot1](https://user-images.githubusercontent.com/34905992/194875626-6560812b-c776-4601-9425-4eafea3288bb.png) 2. Replace `@RunWith(MockitoJUnitRunner.class)` with `@ExtendWith(MockitoExtension.class)` if necessary. 3. Replace `Assert` with `Assertions`. 4. Fix expected exception if necessary. ```java // jUnit 4 @Test(expected = Exception.class) public void testThrowsException() throws Exception { // ... } // jUnit 5 @Test public void testThrowsException() throws Exception { Assertions.assertThrows(Exception.class, () -> { //... }); } ``` 6. Fix timeout if necessary. ```java // jUnit 4 @Test(timeout = 10) public void testFailWithTimeout() throws InterruptedException { Thread.sleep(100); } // jUnit 5 @Test void testFailWithTimeout() throws InterruptedException { Assertions.assertTimeout(Duration.ofMillis(10), () -> Thread.sleep(100)); } Assertions.assertTimeout(Duration.ofMillis(60000), () -> {}); ``` 8. Replace `@Ignore` with `@Disable` if necessary. 9. Replace `org.junit.rules.TemporaryFolder` with `org.junit.jupiter.api.io.TempDir` and use `@TempDir` if necessary. 10. Run the UT file you changed to see whether all cases pass successfully. 11. Fix unnecessary stubbings if necessary. This is caused by changing `@Before` into `@BeforeEach`. The recommend method is to use `@MockitoSettings(strictness = Strictness.LENIENT)`. Alternatively, you could either remove the unnecessary stubbings from `@BeforeEach` and only put them where they needed or use `Mockito.lenient().when(......` for `Mockito.when(......` to bypass the `stubbing check`. 12. Global search in your module and make sure all `org.junit.xxxx` has been migrated to `org.junit.jupiter.api.xxx` ### PR Example * #12299 ### Sub-Tasks We hope to complete all the following sub-tasks ***before Oct. 25th*** because DSIP-10 depends on this issue and all UT cases are supposed to be migrated to jUnit 5 before the start of UT refactoring. - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `task-plugin` module: #12299 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `alert` and `api` module: #12313 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `dao` module: #12319 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `data-quality`, `datasource-plugin` and `registry` module: #12322 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `master`, `worker` and `remote` module: #12316 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `common`, `service` and `spi` module: #12317 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `microbench` and `e2e` module: #12333 - [x] Block explicit imports of jUnit 4 library. #12395 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12301
https://github.com/apache/dolphinscheduler/pull/12450
0eef2e3e10ca8d20d8a0ad59b0f0674f90ee321c
0a6e8af864423dac2aff279bf56f6f1ee95e95b9
2022-10-10T12:48:52Z
java
2022-10-20T04:12:17Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
taskDefinitionLogMap = taskDefinitionLogs .stream() .collect(Collectors.toMap(TaskDefinition::getCode, taskDefinitionLog -> taskDefinitionLog)); } Date now = new Date(); for (ProcessTaskRelationLog processTaskRelationLog : taskRelationList) { processTaskRelationLog.setProjectCode(projectCode); processTaskRelationLog.setProcessDefinitionCode(processDefinitionCode); processTaskRelationLog.setProcessDefinitionVersion(processDefinitionVersion); if (taskDefinitionLogMap != null) { TaskDefinitionLog preTaskDefinitionLog = taskDefinitionLogMap.get(processTaskRelationLog.getPreTaskCode()); if (preTaskDefinitionLog != null) { processTaskRelationLog.setPreTaskVersion(preTaskDefinitionLog.getVersion()); } TaskDefinitionLog postTaskDefinitionLog = taskDefinitionLogMap.get(processTaskRelationLog.getPostTaskCode()); if (postTaskDefinitionLog != null) { processTaskRelationLog.setPostTaskVersion(postTaskDefinitionLog.getVersion()); } } processTaskRelationLog.setCreateTime(now); processTaskRelationLog.setUpdateTime(now); processTaskRelationLog.setOperator(operator.getId()); processTaskRelationLog.setOperateTime(now); } int insert = taskRelationList.size(); if (Boolean.TRUE.equals(syncDefine)) { List<ProcessTaskRelation> processTaskRelationList = processTaskRelationMapper.queryByProcessCode(projectCode, processDefinitionCode);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,301
[Migration][Test] jUnit4 -> jUnit5 UT cases migration
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * This is part of DSIP-10 #10573 * By this moment, we have added jUnit 5 dependencies #11332 and removed all `Powermock` related code #11405. It is high time that we migrate all the UT cases from jUnit 4 to jUnit 5 and remove the dependency of `junit-vintage-engine` so that there will be one and only one version of unit test cases, which is jUnit5, in the whole project. ### SOP These two following articles are recommended for you to understand the whole process. In order to keep the instructions brief and concise, I summarize some key points of these two articles as well as add a few extra operations based on practice for your reference: * https://blogs.oracle.com/javamagazine/post/migrating-from-junit-4-to-junit-5-important-differences-and-benefits * https://blog.jetbrains.com/idea/2020/08/migrating-from-junit-4-to-junit-5/ BTW, I suggest you perform this SOP below by module or by file, instead of doing it for the whole project. This helps you increase efficiency. 1. Perform basic migration through `Intellij IDE` for the module you choose. ![screenshot1](https://user-images.githubusercontent.com/34905992/194875626-6560812b-c776-4601-9425-4eafea3288bb.png) 2. Replace `@RunWith(MockitoJUnitRunner.class)` with `@ExtendWith(MockitoExtension.class)` if necessary. 3. Replace `Assert` with `Assertions`. 4. Fix expected exception if necessary. ```java // jUnit 4 @Test(expected = Exception.class) public void testThrowsException() throws Exception { // ... } // jUnit 5 @Test public void testThrowsException() throws Exception { Assertions.assertThrows(Exception.class, () -> { //... }); } ``` 6. Fix timeout if necessary. ```java // jUnit 4 @Test(timeout = 10) public void testFailWithTimeout() throws InterruptedException { Thread.sleep(100); } // jUnit 5 @Test void testFailWithTimeout() throws InterruptedException { Assertions.assertTimeout(Duration.ofMillis(10), () -> Thread.sleep(100)); } Assertions.assertTimeout(Duration.ofMillis(60000), () -> {}); ``` 8. Replace `@Ignore` with `@Disable` if necessary. 9. Replace `org.junit.rules.TemporaryFolder` with `org.junit.jupiter.api.io.TempDir` and use `@TempDir` if necessary. 10. Run the UT file you changed to see whether all cases pass successfully. 11. Fix unnecessary stubbings if necessary. This is caused by changing `@Before` into `@BeforeEach`. The recommend method is to use `@MockitoSettings(strictness = Strictness.LENIENT)`. Alternatively, you could either remove the unnecessary stubbings from `@BeforeEach` and only put them where they needed or use `Mockito.lenient().when(......` for `Mockito.when(......` to bypass the `stubbing check`. 12. Global search in your module and make sure all `org.junit.xxxx` has been migrated to `org.junit.jupiter.api.xxx` ### PR Example * #12299 ### Sub-Tasks We hope to complete all the following sub-tasks ***before Oct. 25th*** because DSIP-10 depends on this issue and all UT cases are supposed to be migrated to jUnit 5 before the start of UT refactoring. - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `task-plugin` module: #12299 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `alert` and `api` module: #12313 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `dao` module: #12319 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `data-quality`, `datasource-plugin` and `registry` module: #12322 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `master`, `worker` and `remote` module: #12316 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `common`, `service` and `spi` module: #12317 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `microbench` and `e2e` module: #12333 - [x] Block explicit imports of jUnit 4 library. #12395 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12301
https://github.com/apache/dolphinscheduler/pull/12450
0eef2e3e10ca8d20d8a0ad59b0f0674f90ee321c
0a6e8af864423dac2aff279bf56f6f1ee95e95b9
2022-10-10T12:48:52Z
java
2022-10-20T04:12:17Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
if (!processTaskRelationList.isEmpty()) { Set<Integer> processTaskRelationSet = processTaskRelationList.stream().map(ProcessTaskRelation::hashCode).collect(toSet()); Set<Integer> taskRelationSet = taskRelationList.stream().map(ProcessTaskRelationLog::hashCode).collect(toSet()); boolean result = CollectionUtils.isEqualCollection(processTaskRelationSet, taskRelationSet); if (result) { return Constants.EXIT_CODE_SUCCESS; } processTaskRelationMapper.deleteByCode(projectCode, processDefinitionCode); } List<ProcessTaskRelation> processTaskRelations = taskRelationList.stream().map(ProcessTaskRelation::new).collect(Collectors.toList()); insert = processTaskRelationMapper.batchInsert(processTaskRelations); } int resultLog = processTaskRelationLogMapper.batchInsert(taskRelationList); return (insert & resultLog) > 0 ? Constants.EXIT_CODE_SUCCESS : Constants.EXIT_CODE_FAILURE; } @Override public boolean isTaskOnline(long taskCode) { List<ProcessTaskRelation> processTaskRelationList = processTaskRelationMapper.queryByTaskCode(taskCode); if (!processTaskRelationList.isEmpty()) { Set<Long> processDefinitionCodes = processTaskRelationList .stream() .map(ProcessTaskRelation::getProcessDefinitionCode) .collect(toSet()); List<ProcessDefinition> processDefinitionList = processDefineMapper.queryByCodes(processDefinitionCodes); for (ProcessDefinition processDefinition : processDefinitionList) { if (processDefinition.getReleaseState() == ReleaseState.ONLINE) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,301
[Migration][Test] jUnit4 -> jUnit5 UT cases migration
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * This is part of DSIP-10 #10573 * By this moment, we have added jUnit 5 dependencies #11332 and removed all `Powermock` related code #11405. It is high time that we migrate all the UT cases from jUnit 4 to jUnit 5 and remove the dependency of `junit-vintage-engine` so that there will be one and only one version of unit test cases, which is jUnit5, in the whole project. ### SOP These two following articles are recommended for you to understand the whole process. In order to keep the instructions brief and concise, I summarize some key points of these two articles as well as add a few extra operations based on practice for your reference: * https://blogs.oracle.com/javamagazine/post/migrating-from-junit-4-to-junit-5-important-differences-and-benefits * https://blog.jetbrains.com/idea/2020/08/migrating-from-junit-4-to-junit-5/ BTW, I suggest you perform this SOP below by module or by file, instead of doing it for the whole project. This helps you increase efficiency. 1. Perform basic migration through `Intellij IDE` for the module you choose. ![screenshot1](https://user-images.githubusercontent.com/34905992/194875626-6560812b-c776-4601-9425-4eafea3288bb.png) 2. Replace `@RunWith(MockitoJUnitRunner.class)` with `@ExtendWith(MockitoExtension.class)` if necessary. 3. Replace `Assert` with `Assertions`. 4. Fix expected exception if necessary. ```java // jUnit 4 @Test(expected = Exception.class) public void testThrowsException() throws Exception { // ... } // jUnit 5 @Test public void testThrowsException() throws Exception { Assertions.assertThrows(Exception.class, () -> { //... }); } ``` 6. Fix timeout if necessary. ```java // jUnit 4 @Test(timeout = 10) public void testFailWithTimeout() throws InterruptedException { Thread.sleep(100); } // jUnit 5 @Test void testFailWithTimeout() throws InterruptedException { Assertions.assertTimeout(Duration.ofMillis(10), () -> Thread.sleep(100)); } Assertions.assertTimeout(Duration.ofMillis(60000), () -> {}); ``` 8. Replace `@Ignore` with `@Disable` if necessary. 9. Replace `org.junit.rules.TemporaryFolder` with `org.junit.jupiter.api.io.TempDir` and use `@TempDir` if necessary. 10. Run the UT file you changed to see whether all cases pass successfully. 11. Fix unnecessary stubbings if necessary. This is caused by changing `@Before` into `@BeforeEach`. The recommend method is to use `@MockitoSettings(strictness = Strictness.LENIENT)`. Alternatively, you could either remove the unnecessary stubbings from `@BeforeEach` and only put them where they needed or use `Mockito.lenient().when(......` for `Mockito.when(......` to bypass the `stubbing check`. 12. Global search in your module and make sure all `org.junit.xxxx` has been migrated to `org.junit.jupiter.api.xxx` ### PR Example * #12299 ### Sub-Tasks We hope to complete all the following sub-tasks ***before Oct. 25th*** because DSIP-10 depends on this issue and all UT cases are supposed to be migrated to jUnit 5 before the start of UT refactoring. - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `task-plugin` module: #12299 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `alert` and `api` module: #12313 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `dao` module: #12319 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `data-quality`, `datasource-plugin` and `registry` module: #12322 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `master`, `worker` and `remote` module: #12316 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `common`, `service` and `spi` module: #12317 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `microbench` and `e2e` module: #12333 - [x] Block explicit imports of jUnit 4 library. #12395 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12301
https://github.com/apache/dolphinscheduler/pull/12450
0eef2e3e10ca8d20d8a0ad59b0f0674f90ee321c
0a6e8af864423dac2aff279bf56f6f1ee95e95b9
2022-10-10T12:48:52Z
java
2022-10-20T04:12:17Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
return true; } } } return false; } /** * Generate the DAG Graph based on the process definition id * Use temporarily before refactoring taskNode * * @param processDefinition process definition * @return dag graph */ @Override public DAG<String, TaskNode, TaskNodeRelation> genDagGraph(ProcessDefinition processDefinition) { List<ProcessTaskRelation> taskRelations = this.findRelationByCode(processDefinition.getCode(), processDefinition.getVersion()); List<TaskNode> taskNodeList = transformTask(taskRelations, Lists.newArrayList()); ProcessDag processDag = DagHelper.getProcessDag(taskNodeList, new ArrayList<>(taskRelations)); return DagHelper.buildDagGraph(processDag); } /** * generate DagData */ @Override public DagData genDagData(ProcessDefinition processDefinition) { List<ProcessTaskRelation> taskRelations = this.findRelationByCode(processDefinition.getCode(), processDefinition.getVersion()); List<TaskDefinitionLog> taskDefinitionLogList = genTaskDefineList(taskRelations);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,301
[Migration][Test] jUnit4 -> jUnit5 UT cases migration
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * This is part of DSIP-10 #10573 * By this moment, we have added jUnit 5 dependencies #11332 and removed all `Powermock` related code #11405. It is high time that we migrate all the UT cases from jUnit 4 to jUnit 5 and remove the dependency of `junit-vintage-engine` so that there will be one and only one version of unit test cases, which is jUnit5, in the whole project. ### SOP These two following articles are recommended for you to understand the whole process. In order to keep the instructions brief and concise, I summarize some key points of these two articles as well as add a few extra operations based on practice for your reference: * https://blogs.oracle.com/javamagazine/post/migrating-from-junit-4-to-junit-5-important-differences-and-benefits * https://blog.jetbrains.com/idea/2020/08/migrating-from-junit-4-to-junit-5/ BTW, I suggest you perform this SOP below by module or by file, instead of doing it for the whole project. This helps you increase efficiency. 1. Perform basic migration through `Intellij IDE` for the module you choose. ![screenshot1](https://user-images.githubusercontent.com/34905992/194875626-6560812b-c776-4601-9425-4eafea3288bb.png) 2. Replace `@RunWith(MockitoJUnitRunner.class)` with `@ExtendWith(MockitoExtension.class)` if necessary. 3. Replace `Assert` with `Assertions`. 4. Fix expected exception if necessary. ```java // jUnit 4 @Test(expected = Exception.class) public void testThrowsException() throws Exception { // ... } // jUnit 5 @Test public void testThrowsException() throws Exception { Assertions.assertThrows(Exception.class, () -> { //... }); } ``` 6. Fix timeout if necessary. ```java // jUnit 4 @Test(timeout = 10) public void testFailWithTimeout() throws InterruptedException { Thread.sleep(100); } // jUnit 5 @Test void testFailWithTimeout() throws InterruptedException { Assertions.assertTimeout(Duration.ofMillis(10), () -> Thread.sleep(100)); } Assertions.assertTimeout(Duration.ofMillis(60000), () -> {}); ``` 8. Replace `@Ignore` with `@Disable` if necessary. 9. Replace `org.junit.rules.TemporaryFolder` with `org.junit.jupiter.api.io.TempDir` and use `@TempDir` if necessary. 10. Run the UT file you changed to see whether all cases pass successfully. 11. Fix unnecessary stubbings if necessary. This is caused by changing `@Before` into `@BeforeEach`. The recommend method is to use `@MockitoSettings(strictness = Strictness.LENIENT)`. Alternatively, you could either remove the unnecessary stubbings from `@BeforeEach` and only put them where they needed or use `Mockito.lenient().when(......` for `Mockito.when(......` to bypass the `stubbing check`. 12. Global search in your module and make sure all `org.junit.xxxx` has been migrated to `org.junit.jupiter.api.xxx` ### PR Example * #12299 ### Sub-Tasks We hope to complete all the following sub-tasks ***before Oct. 25th*** because DSIP-10 depends on this issue and all UT cases are supposed to be migrated to jUnit 5 before the start of UT refactoring. - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `task-plugin` module: #12299 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `alert` and `api` module: #12313 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `dao` module: #12319 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `data-quality`, `datasource-plugin` and `registry` module: #12322 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `master`, `worker` and `remote` module: #12316 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `common`, `service` and `spi` module: #12317 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `microbench` and `e2e` module: #12333 - [x] Block explicit imports of jUnit 4 library. #12395 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12301
https://github.com/apache/dolphinscheduler/pull/12450
0eef2e3e10ca8d20d8a0ad59b0f0674f90ee321c
0a6e8af864423dac2aff279bf56f6f1ee95e95b9
2022-10-10T12:48:52Z
java
2022-10-20T04:12:17Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
List<TaskDefinition> taskDefinitions = taskDefinitionLogList.stream().map(t -> (TaskDefinition) t).collect(Collectors.toList()); return new DagData(processDefinition, taskRelations, taskDefinitions); } @Override public List<TaskDefinitionLog> genTaskDefineList(List<ProcessTaskRelation> processTaskRelations) { Set<TaskDefinition> taskDefinitionSet = new HashSet<>(); for (ProcessTaskRelation processTaskRelation : processTaskRelations) { if (processTaskRelation.getPreTaskCode() > 0) { taskDefinitionSet.add(new TaskDefinition(processTaskRelation.getPreTaskCode(), processTaskRelation.getPreTaskVersion())); } if (processTaskRelation.getPostTaskCode() > 0) { taskDefinitionSet.add(new TaskDefinition(processTaskRelation.getPostTaskCode(), processTaskRelation.getPostTaskVersion())); } } if (taskDefinitionSet.isEmpty()) { return Lists.newArrayList(); } return taskDefinitionLogMapper.queryByTaskDefinitions(taskDefinitionSet); } @Override public List<TaskDefinitionLog> getTaskDefineLogListByRelation(List<ProcessTaskRelation> processTaskRelations) { List<TaskDefinitionLog> taskDefinitionLogs = new ArrayList<>(); Map<Long, Integer> taskCodeVersionMap = new HashMap<>(); for (ProcessTaskRelation processTaskRelation : processTaskRelations) { if (processTaskRelation.getPreTaskCode() > 0) { taskCodeVersionMap.put(processTaskRelation.getPreTaskCode(), processTaskRelation.getPreTaskVersion()); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,301
[Migration][Test] jUnit4 -> jUnit5 UT cases migration
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * This is part of DSIP-10 #10573 * By this moment, we have added jUnit 5 dependencies #11332 and removed all `Powermock` related code #11405. It is high time that we migrate all the UT cases from jUnit 4 to jUnit 5 and remove the dependency of `junit-vintage-engine` so that there will be one and only one version of unit test cases, which is jUnit5, in the whole project. ### SOP These two following articles are recommended for you to understand the whole process. In order to keep the instructions brief and concise, I summarize some key points of these two articles as well as add a few extra operations based on practice for your reference: * https://blogs.oracle.com/javamagazine/post/migrating-from-junit-4-to-junit-5-important-differences-and-benefits * https://blog.jetbrains.com/idea/2020/08/migrating-from-junit-4-to-junit-5/ BTW, I suggest you perform this SOP below by module or by file, instead of doing it for the whole project. This helps you increase efficiency. 1. Perform basic migration through `Intellij IDE` for the module you choose. ![screenshot1](https://user-images.githubusercontent.com/34905992/194875626-6560812b-c776-4601-9425-4eafea3288bb.png) 2. Replace `@RunWith(MockitoJUnitRunner.class)` with `@ExtendWith(MockitoExtension.class)` if necessary. 3. Replace `Assert` with `Assertions`. 4. Fix expected exception if necessary. ```java // jUnit 4 @Test(expected = Exception.class) public void testThrowsException() throws Exception { // ... } // jUnit 5 @Test public void testThrowsException() throws Exception { Assertions.assertThrows(Exception.class, () -> { //... }); } ``` 6. Fix timeout if necessary. ```java // jUnit 4 @Test(timeout = 10) public void testFailWithTimeout() throws InterruptedException { Thread.sleep(100); } // jUnit 5 @Test void testFailWithTimeout() throws InterruptedException { Assertions.assertTimeout(Duration.ofMillis(10), () -> Thread.sleep(100)); } Assertions.assertTimeout(Duration.ofMillis(60000), () -> {}); ``` 8. Replace `@Ignore` with `@Disable` if necessary. 9. Replace `org.junit.rules.TemporaryFolder` with `org.junit.jupiter.api.io.TempDir` and use `@TempDir` if necessary. 10. Run the UT file you changed to see whether all cases pass successfully. 11. Fix unnecessary stubbings if necessary. This is caused by changing `@Before` into `@BeforeEach`. The recommend method is to use `@MockitoSettings(strictness = Strictness.LENIENT)`. Alternatively, you could either remove the unnecessary stubbings from `@BeforeEach` and only put them where they needed or use `Mockito.lenient().when(......` for `Mockito.when(......` to bypass the `stubbing check`. 12. Global search in your module and make sure all `org.junit.xxxx` has been migrated to `org.junit.jupiter.api.xxx` ### PR Example * #12299 ### Sub-Tasks We hope to complete all the following sub-tasks ***before Oct. 25th*** because DSIP-10 depends on this issue and all UT cases are supposed to be migrated to jUnit 5 before the start of UT refactoring. - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `task-plugin` module: #12299 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `alert` and `api` module: #12313 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `dao` module: #12319 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `data-quality`, `datasource-plugin` and `registry` module: #12322 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `master`, `worker` and `remote` module: #12316 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `common`, `service` and `spi` module: #12317 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `microbench` and `e2e` module: #12333 - [x] Block explicit imports of jUnit 4 library. #12395 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12301
https://github.com/apache/dolphinscheduler/pull/12450
0eef2e3e10ca8d20d8a0ad59b0f0674f90ee321c
0a6e8af864423dac2aff279bf56f6f1ee95e95b9
2022-10-10T12:48:52Z
java
2022-10-20T04:12:17Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
if (processTaskRelation.getPostTaskCode() > 0) { taskCodeVersionMap.put(processTaskRelation.getPostTaskCode(), processTaskRelation.getPostTaskVersion()); } } taskCodeVersionMap.forEach((code, version) -> { taskDefinitionLogs.add((TaskDefinitionLog) this.findTaskDefinition(code, version)); }); return taskDefinitionLogs; } /** * find task definition by code and version */ @Override public TaskDefinition findTaskDefinition(long taskCode, int taskDefinitionVersion) { return taskDefinitionLogMapper.queryByDefinitionCodeAndVersion(taskCode, taskDefinitionVersion); } /** * find process task relation list by process */ @Override public List<ProcessTaskRelation> findRelationByCode(long processDefinitionCode, int processDefinitionVersion) { List<ProcessTaskRelationLog> processTaskRelationLogList = processTaskRelationLogMapper .queryByProcessCodeAndVersion(processDefinitionCode, processDefinitionVersion); return processTaskRelationLogList.stream().map(r -> (ProcessTaskRelation) r).collect(Collectors.toList()); } /** * add authorized resources * * @param ownResources own resources * @param userId userId
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,301
[Migration][Test] jUnit4 -> jUnit5 UT cases migration
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * This is part of DSIP-10 #10573 * By this moment, we have added jUnit 5 dependencies #11332 and removed all `Powermock` related code #11405. It is high time that we migrate all the UT cases from jUnit 4 to jUnit 5 and remove the dependency of `junit-vintage-engine` so that there will be one and only one version of unit test cases, which is jUnit5, in the whole project. ### SOP These two following articles are recommended for you to understand the whole process. In order to keep the instructions brief and concise, I summarize some key points of these two articles as well as add a few extra operations based on practice for your reference: * https://blogs.oracle.com/javamagazine/post/migrating-from-junit-4-to-junit-5-important-differences-and-benefits * https://blog.jetbrains.com/idea/2020/08/migrating-from-junit-4-to-junit-5/ BTW, I suggest you perform this SOP below by module or by file, instead of doing it for the whole project. This helps you increase efficiency. 1. Perform basic migration through `Intellij IDE` for the module you choose. ![screenshot1](https://user-images.githubusercontent.com/34905992/194875626-6560812b-c776-4601-9425-4eafea3288bb.png) 2. Replace `@RunWith(MockitoJUnitRunner.class)` with `@ExtendWith(MockitoExtension.class)` if necessary. 3. Replace `Assert` with `Assertions`. 4. Fix expected exception if necessary. ```java // jUnit 4 @Test(expected = Exception.class) public void testThrowsException() throws Exception { // ... } // jUnit 5 @Test public void testThrowsException() throws Exception { Assertions.assertThrows(Exception.class, () -> { //... }); } ``` 6. Fix timeout if necessary. ```java // jUnit 4 @Test(timeout = 10) public void testFailWithTimeout() throws InterruptedException { Thread.sleep(100); } // jUnit 5 @Test void testFailWithTimeout() throws InterruptedException { Assertions.assertTimeout(Duration.ofMillis(10), () -> Thread.sleep(100)); } Assertions.assertTimeout(Duration.ofMillis(60000), () -> {}); ``` 8. Replace `@Ignore` with `@Disable` if necessary. 9. Replace `org.junit.rules.TemporaryFolder` with `org.junit.jupiter.api.io.TempDir` and use `@TempDir` if necessary. 10. Run the UT file you changed to see whether all cases pass successfully. 11. Fix unnecessary stubbings if necessary. This is caused by changing `@Before` into `@BeforeEach`. The recommend method is to use `@MockitoSettings(strictness = Strictness.LENIENT)`. Alternatively, you could either remove the unnecessary stubbings from `@BeforeEach` and only put them where they needed or use `Mockito.lenient().when(......` for `Mockito.when(......` to bypass the `stubbing check`. 12. Global search in your module and make sure all `org.junit.xxxx` has been migrated to `org.junit.jupiter.api.xxx` ### PR Example * #12299 ### Sub-Tasks We hope to complete all the following sub-tasks ***before Oct. 25th*** because DSIP-10 depends on this issue and all UT cases are supposed to be migrated to jUnit 5 before the start of UT refactoring. - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `task-plugin` module: #12299 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `alert` and `api` module: #12313 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `dao` module: #12319 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `data-quality`, `datasource-plugin` and `registry` module: #12322 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `master`, `worker` and `remote` module: #12316 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `common`, `service` and `spi` module: #12317 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `microbench` and `e2e` module: #12333 - [x] Block explicit imports of jUnit 4 library. #12395 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12301
https://github.com/apache/dolphinscheduler/pull/12450
0eef2e3e10ca8d20d8a0ad59b0f0674f90ee321c
0a6e8af864423dac2aff279bf56f6f1ee95e95b9
2022-10-10T12:48:52Z
java
2022-10-20T04:12:17Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
*/ private void addAuthorizedResources(List<Resource> ownResources, int userId) { List<Integer> relationResourceIds = resourceUserMapper.queryResourcesIdListByUserIdAndPerm(userId, 7); List<Resource> relationResources = CollectionUtils.isNotEmpty(relationResourceIds) ? resourceMapper.queryResourceListById(relationResourceIds) : new ArrayList<>(); ownResources.addAll(relationResources); } /** * Use temporarily before refactoring taskNode */ @Override public List<TaskNode> transformTask(List<ProcessTaskRelation> taskRelationList, List<TaskDefinitionLog> taskDefinitionLogs) { Map<Long, List<Long>> taskCodeMap = new HashMap<>(); for (ProcessTaskRelation processTaskRelation : taskRelationList) { taskCodeMap.compute(processTaskRelation.getPostTaskCode(), (k, v) -> { if (v == null) { v = new ArrayList<>(); } if (processTaskRelation.getPreTaskCode() != 0L) { v.add(processTaskRelation.getPreTaskCode()); } return v; }); } if (CollectionUtils.isEmpty(taskDefinitionLogs)) { taskDefinitionLogs = genTaskDefineList(taskRelationList); } Map<Long, TaskDefinitionLog> taskDefinitionLogMap = taskDefinitionLogs.stream()
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,301
[Migration][Test] jUnit4 -> jUnit5 UT cases migration
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * This is part of DSIP-10 #10573 * By this moment, we have added jUnit 5 dependencies #11332 and removed all `Powermock` related code #11405. It is high time that we migrate all the UT cases from jUnit 4 to jUnit 5 and remove the dependency of `junit-vintage-engine` so that there will be one and only one version of unit test cases, which is jUnit5, in the whole project. ### SOP These two following articles are recommended for you to understand the whole process. In order to keep the instructions brief and concise, I summarize some key points of these two articles as well as add a few extra operations based on practice for your reference: * https://blogs.oracle.com/javamagazine/post/migrating-from-junit-4-to-junit-5-important-differences-and-benefits * https://blog.jetbrains.com/idea/2020/08/migrating-from-junit-4-to-junit-5/ BTW, I suggest you perform this SOP below by module or by file, instead of doing it for the whole project. This helps you increase efficiency. 1. Perform basic migration through `Intellij IDE` for the module you choose. ![screenshot1](https://user-images.githubusercontent.com/34905992/194875626-6560812b-c776-4601-9425-4eafea3288bb.png) 2. Replace `@RunWith(MockitoJUnitRunner.class)` with `@ExtendWith(MockitoExtension.class)` if necessary. 3. Replace `Assert` with `Assertions`. 4. Fix expected exception if necessary. ```java // jUnit 4 @Test(expected = Exception.class) public void testThrowsException() throws Exception { // ... } // jUnit 5 @Test public void testThrowsException() throws Exception { Assertions.assertThrows(Exception.class, () -> { //... }); } ``` 6. Fix timeout if necessary. ```java // jUnit 4 @Test(timeout = 10) public void testFailWithTimeout() throws InterruptedException { Thread.sleep(100); } // jUnit 5 @Test void testFailWithTimeout() throws InterruptedException { Assertions.assertTimeout(Duration.ofMillis(10), () -> Thread.sleep(100)); } Assertions.assertTimeout(Duration.ofMillis(60000), () -> {}); ``` 8. Replace `@Ignore` with `@Disable` if necessary. 9. Replace `org.junit.rules.TemporaryFolder` with `org.junit.jupiter.api.io.TempDir` and use `@TempDir` if necessary. 10. Run the UT file you changed to see whether all cases pass successfully. 11. Fix unnecessary stubbings if necessary. This is caused by changing `@Before` into `@BeforeEach`. The recommend method is to use `@MockitoSettings(strictness = Strictness.LENIENT)`. Alternatively, you could either remove the unnecessary stubbings from `@BeforeEach` and only put them where they needed or use `Mockito.lenient().when(......` for `Mockito.when(......` to bypass the `stubbing check`. 12. Global search in your module and make sure all `org.junit.xxxx` has been migrated to `org.junit.jupiter.api.xxx` ### PR Example * #12299 ### Sub-Tasks We hope to complete all the following sub-tasks ***before Oct. 25th*** because DSIP-10 depends on this issue and all UT cases are supposed to be migrated to jUnit 5 before the start of UT refactoring. - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `task-plugin` module: #12299 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `alert` and `api` module: #12313 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `dao` module: #12319 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `data-quality`, `datasource-plugin` and `registry` module: #12322 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `master`, `worker` and `remote` module: #12316 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `common`, `service` and `spi` module: #12317 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `microbench` and `e2e` module: #12333 - [x] Block explicit imports of jUnit 4 library. #12395 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12301
https://github.com/apache/dolphinscheduler/pull/12450
0eef2e3e10ca8d20d8a0ad59b0f0674f90ee321c
0a6e8af864423dac2aff279bf56f6f1ee95e95b9
2022-10-10T12:48:52Z
java
2022-10-20T04:12:17Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
.collect(Collectors.toMap(TaskDefinitionLog::getCode, taskDefinitionLog -> taskDefinitionLog)); List<TaskNode> taskNodeList = new ArrayList<>(); for (Entry<Long, List<Long>> code : taskCodeMap.entrySet()) { TaskDefinitionLog taskDefinitionLog = taskDefinitionLogMap.get(code.getKey()); if (taskDefinitionLog != null) { TaskNode taskNode = new TaskNode(); taskNode.setCode(taskDefinitionLog.getCode()); taskNode.setVersion(taskDefinitionLog.getVersion()); taskNode.setName(taskDefinitionLog.getName()); taskNode.setDesc(taskDefinitionLog.getDescription()); taskNode.setType(taskDefinitionLog.getTaskType().toUpperCase()); taskNode.setRunFlag(taskDefinitionLog.getFlag() == Flag.YES ? Constants.FLOWNODE_RUN_FLAG_NORMAL : Constants.FLOWNODE_RUN_FLAG_FORBIDDEN); taskNode.setMaxRetryTimes(taskDefinitionLog.getFailRetryTimes()); taskNode.setRetryInterval(taskDefinitionLog.getFailRetryInterval()); Map<String, Object> taskParamsMap = taskNode.taskParamsToJsonObj(taskDefinitionLog.getTaskParams()); taskNode.setConditionResult(JSONUtils.toJsonString(taskParamsMap.get(Constants.CONDITION_RESULT))); taskNode.setSwitchResult(JSONUtils.toJsonString(taskParamsMap.get(Constants.SWITCH_RESULT))); taskNode.setDependence(JSONUtils.toJsonString(taskParamsMap.get(Constants.DEPENDENCE))); taskParamsMap.remove(Constants.CONDITION_RESULT); taskParamsMap.remove(Constants.DEPENDENCE); taskNode.setParams(JSONUtils.toJsonString(taskParamsMap)); taskNode.setTaskInstancePriority(taskDefinitionLog.getTaskPriority()); taskNode.setWorkerGroup(taskDefinitionLog.getWorkerGroup()); taskNode.setEnvironmentCode(taskDefinitionLog.getEnvironmentCode()); taskNode.setTimeout(JSONUtils .toJsonString(new TaskTimeoutParameter(taskDefinitionLog.getTimeoutFlag() == TimeoutFlag.OPEN, taskDefinitionLog.getTimeoutNotifyStrategy(), taskDefinitionLog.getTimeout()))); taskNode.setDelayTime(taskDefinitionLog.getDelayTime());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,301
[Migration][Test] jUnit4 -> jUnit5 UT cases migration
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * This is part of DSIP-10 #10573 * By this moment, we have added jUnit 5 dependencies #11332 and removed all `Powermock` related code #11405. It is high time that we migrate all the UT cases from jUnit 4 to jUnit 5 and remove the dependency of `junit-vintage-engine` so that there will be one and only one version of unit test cases, which is jUnit5, in the whole project. ### SOP These two following articles are recommended for you to understand the whole process. In order to keep the instructions brief and concise, I summarize some key points of these two articles as well as add a few extra operations based on practice for your reference: * https://blogs.oracle.com/javamagazine/post/migrating-from-junit-4-to-junit-5-important-differences-and-benefits * https://blog.jetbrains.com/idea/2020/08/migrating-from-junit-4-to-junit-5/ BTW, I suggest you perform this SOP below by module or by file, instead of doing it for the whole project. This helps you increase efficiency. 1. Perform basic migration through `Intellij IDE` for the module you choose. ![screenshot1](https://user-images.githubusercontent.com/34905992/194875626-6560812b-c776-4601-9425-4eafea3288bb.png) 2. Replace `@RunWith(MockitoJUnitRunner.class)` with `@ExtendWith(MockitoExtension.class)` if necessary. 3. Replace `Assert` with `Assertions`. 4. Fix expected exception if necessary. ```java // jUnit 4 @Test(expected = Exception.class) public void testThrowsException() throws Exception { // ... } // jUnit 5 @Test public void testThrowsException() throws Exception { Assertions.assertThrows(Exception.class, () -> { //... }); } ``` 6. Fix timeout if necessary. ```java // jUnit 4 @Test(timeout = 10) public void testFailWithTimeout() throws InterruptedException { Thread.sleep(100); } // jUnit 5 @Test void testFailWithTimeout() throws InterruptedException { Assertions.assertTimeout(Duration.ofMillis(10), () -> Thread.sleep(100)); } Assertions.assertTimeout(Duration.ofMillis(60000), () -> {}); ``` 8. Replace `@Ignore` with `@Disable` if necessary. 9. Replace `org.junit.rules.TemporaryFolder` with `org.junit.jupiter.api.io.TempDir` and use `@TempDir` if necessary. 10. Run the UT file you changed to see whether all cases pass successfully. 11. Fix unnecessary stubbings if necessary. This is caused by changing `@Before` into `@BeforeEach`. The recommend method is to use `@MockitoSettings(strictness = Strictness.LENIENT)`. Alternatively, you could either remove the unnecessary stubbings from `@BeforeEach` and only put them where they needed or use `Mockito.lenient().when(......` for `Mockito.when(......` to bypass the `stubbing check`. 12. Global search in your module and make sure all `org.junit.xxxx` has been migrated to `org.junit.jupiter.api.xxx` ### PR Example * #12299 ### Sub-Tasks We hope to complete all the following sub-tasks ***before Oct. 25th*** because DSIP-10 depends on this issue and all UT cases are supposed to be migrated to jUnit 5 before the start of UT refactoring. - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `task-plugin` module: #12299 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `alert` and `api` module: #12313 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `dao` module: #12319 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `data-quality`, `datasource-plugin` and `registry` module: #12322 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `master`, `worker` and `remote` module: #12316 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `common`, `service` and `spi` module: #12317 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `microbench` and `e2e` module: #12333 - [x] Block explicit imports of jUnit 4 library. #12395 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12301
https://github.com/apache/dolphinscheduler/pull/12450
0eef2e3e10ca8d20d8a0ad59b0f0674f90ee321c
0a6e8af864423dac2aff279bf56f6f1ee95e95b9
2022-10-10T12:48:52Z
java
2022-10-20T04:12:17Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
taskNode.setPreTasks(JSONUtils.toJsonString(code.getValue().stream().map(taskDefinitionLogMap::get) .map(TaskDefinition::getCode).collect(Collectors.toList()))); taskNode.setTaskGroupId(taskDefinitionLog.getTaskGroupId()); taskNode.setTaskGroupPriority(taskDefinitionLog.getTaskGroupPriority()); taskNode.setCpuQuota(taskDefinitionLog.getCpuQuota()); taskNode.setMemoryMax(taskDefinitionLog.getMemoryMax()); taskNode.setTaskExecuteType(taskDefinitionLog.getTaskExecuteType()); taskNodeList.add(taskNode); } } return taskNodeList; } @Override public Map<ProcessInstance, TaskInstance> notifyProcessList(int processId) { HashMap<ProcessInstance, TaskInstance> processTaskMap = new HashMap<>(); ProcessInstanceMap processInstanceMap = processInstanceMapMapper.queryBySubProcessId(processId); if (processInstanceMap == null) { return processTaskMap; } ProcessInstance fatherProcess = this.findProcessInstanceById(processInstanceMap.getParentProcessInstanceId()); TaskInstance fatherTask = this.findTaskInstanceById(processInstanceMap.getParentTaskInstanceId()); if (fatherProcess != null) { processTaskMap.put(fatherProcess, fatherTask); } return processTaskMap; } @Override public DqExecuteResult getDqExecuteResultByTaskInstanceId(int taskInstanceId) { return dqExecuteResultMapper.getExecuteResultById(taskInstanceId);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,301
[Migration][Test] jUnit4 -> jUnit5 UT cases migration
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * This is part of DSIP-10 #10573 * By this moment, we have added jUnit 5 dependencies #11332 and removed all `Powermock` related code #11405. It is high time that we migrate all the UT cases from jUnit 4 to jUnit 5 and remove the dependency of `junit-vintage-engine` so that there will be one and only one version of unit test cases, which is jUnit5, in the whole project. ### SOP These two following articles are recommended for you to understand the whole process. In order to keep the instructions brief and concise, I summarize some key points of these two articles as well as add a few extra operations based on practice for your reference: * https://blogs.oracle.com/javamagazine/post/migrating-from-junit-4-to-junit-5-important-differences-and-benefits * https://blog.jetbrains.com/idea/2020/08/migrating-from-junit-4-to-junit-5/ BTW, I suggest you perform this SOP below by module or by file, instead of doing it for the whole project. This helps you increase efficiency. 1. Perform basic migration through `Intellij IDE` for the module you choose. ![screenshot1](https://user-images.githubusercontent.com/34905992/194875626-6560812b-c776-4601-9425-4eafea3288bb.png) 2. Replace `@RunWith(MockitoJUnitRunner.class)` with `@ExtendWith(MockitoExtension.class)` if necessary. 3. Replace `Assert` with `Assertions`. 4. Fix expected exception if necessary. ```java // jUnit 4 @Test(expected = Exception.class) public void testThrowsException() throws Exception { // ... } // jUnit 5 @Test public void testThrowsException() throws Exception { Assertions.assertThrows(Exception.class, () -> { //... }); } ``` 6. Fix timeout if necessary. ```java // jUnit 4 @Test(timeout = 10) public void testFailWithTimeout() throws InterruptedException { Thread.sleep(100); } // jUnit 5 @Test void testFailWithTimeout() throws InterruptedException { Assertions.assertTimeout(Duration.ofMillis(10), () -> Thread.sleep(100)); } Assertions.assertTimeout(Duration.ofMillis(60000), () -> {}); ``` 8. Replace `@Ignore` with `@Disable` if necessary. 9. Replace `org.junit.rules.TemporaryFolder` with `org.junit.jupiter.api.io.TempDir` and use `@TempDir` if necessary. 10. Run the UT file you changed to see whether all cases pass successfully. 11. Fix unnecessary stubbings if necessary. This is caused by changing `@Before` into `@BeforeEach`. The recommend method is to use `@MockitoSettings(strictness = Strictness.LENIENT)`. Alternatively, you could either remove the unnecessary stubbings from `@BeforeEach` and only put them where they needed or use `Mockito.lenient().when(......` for `Mockito.when(......` to bypass the `stubbing check`. 12. Global search in your module and make sure all `org.junit.xxxx` has been migrated to `org.junit.jupiter.api.xxx` ### PR Example * #12299 ### Sub-Tasks We hope to complete all the following sub-tasks ***before Oct. 25th*** because DSIP-10 depends on this issue and all UT cases are supposed to be migrated to jUnit 5 before the start of UT refactoring. - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `task-plugin` module: #12299 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `alert` and `api` module: #12313 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `dao` module: #12319 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `data-quality`, `datasource-plugin` and `registry` module: #12322 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `master`, `worker` and `remote` module: #12316 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `common`, `service` and `spi` module: #12317 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `microbench` and `e2e` module: #12333 - [x] Block explicit imports of jUnit 4 library. #12395 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12301
https://github.com/apache/dolphinscheduler/pull/12450
0eef2e3e10ca8d20d8a0ad59b0f0674f90ee321c
0a6e8af864423dac2aff279bf56f6f1ee95e95b9
2022-10-10T12:48:52Z
java
2022-10-20T04:12:17Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
} @Override public int updateDqExecuteResultUserId(int taskInstanceId) { DqExecuteResult dqExecuteResult = dqExecuteResultMapper .selectOne(new QueryWrapper<DqExecuteResult>().eq(TASK_INSTANCE_ID, taskInstanceId)); if (dqExecuteResult == null) { return -1; } ProcessInstance processInstance = processInstanceMapper.selectById(dqExecuteResult.getProcessInstanceId()); if (processInstance == null) { return -1; } ProcessDefinition processDefinition = processDefineMapper.queryByCode(processInstance.getProcessDefinitionCode()); if (processDefinition == null) { return -1; } dqExecuteResult.setProcessDefinitionId(processDefinition.getId()); dqExecuteResult.setUserId(processDefinition.getUserId()); dqExecuteResult.setState(DqTaskState.DEFAULT.getCode()); return dqExecuteResultMapper.updateById(dqExecuteResult); } @Override public int updateDqExecuteResultState(DqExecuteResult dqExecuteResult) { return dqExecuteResultMapper.updateById(dqExecuteResult); } @Override public int deleteDqExecuteResultByTaskInstanceId(int taskInstanceId) { return dqExecuteResultMapper.delete(
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,301
[Migration][Test] jUnit4 -> jUnit5 UT cases migration
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * This is part of DSIP-10 #10573 * By this moment, we have added jUnit 5 dependencies #11332 and removed all `Powermock` related code #11405. It is high time that we migrate all the UT cases from jUnit 4 to jUnit 5 and remove the dependency of `junit-vintage-engine` so that there will be one and only one version of unit test cases, which is jUnit5, in the whole project. ### SOP These two following articles are recommended for you to understand the whole process. In order to keep the instructions brief and concise, I summarize some key points of these two articles as well as add a few extra operations based on practice for your reference: * https://blogs.oracle.com/javamagazine/post/migrating-from-junit-4-to-junit-5-important-differences-and-benefits * https://blog.jetbrains.com/idea/2020/08/migrating-from-junit-4-to-junit-5/ BTW, I suggest you perform this SOP below by module or by file, instead of doing it for the whole project. This helps you increase efficiency. 1. Perform basic migration through `Intellij IDE` for the module you choose. ![screenshot1](https://user-images.githubusercontent.com/34905992/194875626-6560812b-c776-4601-9425-4eafea3288bb.png) 2. Replace `@RunWith(MockitoJUnitRunner.class)` with `@ExtendWith(MockitoExtension.class)` if necessary. 3. Replace `Assert` with `Assertions`. 4. Fix expected exception if necessary. ```java // jUnit 4 @Test(expected = Exception.class) public void testThrowsException() throws Exception { // ... } // jUnit 5 @Test public void testThrowsException() throws Exception { Assertions.assertThrows(Exception.class, () -> { //... }); } ``` 6. Fix timeout if necessary. ```java // jUnit 4 @Test(timeout = 10) public void testFailWithTimeout() throws InterruptedException { Thread.sleep(100); } // jUnit 5 @Test void testFailWithTimeout() throws InterruptedException { Assertions.assertTimeout(Duration.ofMillis(10), () -> Thread.sleep(100)); } Assertions.assertTimeout(Duration.ofMillis(60000), () -> {}); ``` 8. Replace `@Ignore` with `@Disable` if necessary. 9. Replace `org.junit.rules.TemporaryFolder` with `org.junit.jupiter.api.io.TempDir` and use `@TempDir` if necessary. 10. Run the UT file you changed to see whether all cases pass successfully. 11. Fix unnecessary stubbings if necessary. This is caused by changing `@Before` into `@BeforeEach`. The recommend method is to use `@MockitoSettings(strictness = Strictness.LENIENT)`. Alternatively, you could either remove the unnecessary stubbings from `@BeforeEach` and only put them where they needed or use `Mockito.lenient().when(......` for `Mockito.when(......` to bypass the `stubbing check`. 12. Global search in your module and make sure all `org.junit.xxxx` has been migrated to `org.junit.jupiter.api.xxx` ### PR Example * #12299 ### Sub-Tasks We hope to complete all the following sub-tasks ***before Oct. 25th*** because DSIP-10 depends on this issue and all UT cases are supposed to be migrated to jUnit 5 before the start of UT refactoring. - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `task-plugin` module: #12299 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `alert` and `api` module: #12313 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `dao` module: #12319 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `data-quality`, `datasource-plugin` and `registry` module: #12322 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `master`, `worker` and `remote` module: #12316 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `common`, `service` and `spi` module: #12317 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `microbench` and `e2e` module: #12333 - [x] Block explicit imports of jUnit 4 library. #12395 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12301
https://github.com/apache/dolphinscheduler/pull/12450
0eef2e3e10ca8d20d8a0ad59b0f0674f90ee321c
0a6e8af864423dac2aff279bf56f6f1ee95e95b9
2022-10-10T12:48:52Z
java
2022-10-20T04:12:17Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
new QueryWrapper<DqExecuteResult>() .eq(TASK_INSTANCE_ID, taskInstanceId)); } @Override public int deleteTaskStatisticsValueByTaskInstanceId(int taskInstanceId) { return dqTaskStatisticsValueMapper.delete( new QueryWrapper<DqTaskStatisticsValue>() .eq(TASK_INSTANCE_ID, taskInstanceId)); } @Override public DqRule getDqRule(int ruleId) { return dqRuleMapper.selectById(ruleId); } @Override public List<DqRuleInputEntry> getRuleInputEntry(int ruleId) { return DqRuleUtils.transformInputEntry(dqRuleInputEntryMapper.getRuleInputEntryList(ruleId)); } @Override public List<DqRuleExecuteSql> getDqExecuteSql(int ruleId) { return dqRuleExecuteSqlMapper.getExecuteSqlList(ruleId); } @Override public DqComparisonType getComparisonTypeById(int id) { return dqComparisonTypeMapper.selectById(id); } /** * the first time (when submit the task ) get the resource of the task group * * @param taskId task id */
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,301
[Migration][Test] jUnit4 -> jUnit5 UT cases migration
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * This is part of DSIP-10 #10573 * By this moment, we have added jUnit 5 dependencies #11332 and removed all `Powermock` related code #11405. It is high time that we migrate all the UT cases from jUnit 4 to jUnit 5 and remove the dependency of `junit-vintage-engine` so that there will be one and only one version of unit test cases, which is jUnit5, in the whole project. ### SOP These two following articles are recommended for you to understand the whole process. In order to keep the instructions brief and concise, I summarize some key points of these two articles as well as add a few extra operations based on practice for your reference: * https://blogs.oracle.com/javamagazine/post/migrating-from-junit-4-to-junit-5-important-differences-and-benefits * https://blog.jetbrains.com/idea/2020/08/migrating-from-junit-4-to-junit-5/ BTW, I suggest you perform this SOP below by module or by file, instead of doing it for the whole project. This helps you increase efficiency. 1. Perform basic migration through `Intellij IDE` for the module you choose. ![screenshot1](https://user-images.githubusercontent.com/34905992/194875626-6560812b-c776-4601-9425-4eafea3288bb.png) 2. Replace `@RunWith(MockitoJUnitRunner.class)` with `@ExtendWith(MockitoExtension.class)` if necessary. 3. Replace `Assert` with `Assertions`. 4. Fix expected exception if necessary. ```java // jUnit 4 @Test(expected = Exception.class) public void testThrowsException() throws Exception { // ... } // jUnit 5 @Test public void testThrowsException() throws Exception { Assertions.assertThrows(Exception.class, () -> { //... }); } ``` 6. Fix timeout if necessary. ```java // jUnit 4 @Test(timeout = 10) public void testFailWithTimeout() throws InterruptedException { Thread.sleep(100); } // jUnit 5 @Test void testFailWithTimeout() throws InterruptedException { Assertions.assertTimeout(Duration.ofMillis(10), () -> Thread.sleep(100)); } Assertions.assertTimeout(Duration.ofMillis(60000), () -> {}); ``` 8. Replace `@Ignore` with `@Disable` if necessary. 9. Replace `org.junit.rules.TemporaryFolder` with `org.junit.jupiter.api.io.TempDir` and use `@TempDir` if necessary. 10. Run the UT file you changed to see whether all cases pass successfully. 11. Fix unnecessary stubbings if necessary. This is caused by changing `@Before` into `@BeforeEach`. The recommend method is to use `@MockitoSettings(strictness = Strictness.LENIENT)`. Alternatively, you could either remove the unnecessary stubbings from `@BeforeEach` and only put them where they needed or use `Mockito.lenient().when(......` for `Mockito.when(......` to bypass the `stubbing check`. 12. Global search in your module and make sure all `org.junit.xxxx` has been migrated to `org.junit.jupiter.api.xxx` ### PR Example * #12299 ### Sub-Tasks We hope to complete all the following sub-tasks ***before Oct. 25th*** because DSIP-10 depends on this issue and all UT cases are supposed to be migrated to jUnit 5 before the start of UT refactoring. - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `task-plugin` module: #12299 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `alert` and `api` module: #12313 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `dao` module: #12319 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `data-quality`, `datasource-plugin` and `registry` module: #12322 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `master`, `worker` and `remote` module: #12316 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `common`, `service` and `spi` module: #12317 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `microbench` and `e2e` module: #12333 - [x] Block explicit imports of jUnit 4 library. #12395 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12301
https://github.com/apache/dolphinscheduler/pull/12450
0eef2e3e10ca8d20d8a0ad59b0f0674f90ee321c
0a6e8af864423dac2aff279bf56f6f1ee95e95b9
2022-10-10T12:48:52Z
java
2022-10-20T04:12:17Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
@Override public boolean acquireTaskGroup(int taskId, String taskName, int groupId, int processId, int priority) { TaskGroup taskGroup = taskGroupMapper.selectById(groupId); if (taskGroup == null) { return true; } if (taskGroup.getStatus() == Flag.NO.getCode()) { return true; } TaskGroupQueue taskGroupQueue = this.taskGroupQueueMapper.queryByTaskId(taskId); if (taskGroupQueue == null) { taskGroupQueue = insertIntoTaskGroupQueue(taskId, taskName, groupId, processId, priority, TaskGroupQueueStatus.WAIT_QUEUE); } else { logger.info("The task queue is already exist, taskId: {}", taskId); if (taskGroupQueue.getStatus() == TaskGroupQueueStatus.ACQUIRE_SUCCESS) { return true; } taskGroupQueue.setInQueue(Flag.NO.getCode()); taskGroupQueue.setStatus(TaskGroupQueueStatus.WAIT_QUEUE); this.taskGroupQueueMapper.updateById(taskGroupQueue); } List<TaskGroupQueue> highPriorityTasks = taskGroupQueueMapper.queryHighPriorityTasks(groupId, priority, TaskGroupQueueStatus.WAIT_QUEUE.getCode()); if (CollectionUtils.isNotEmpty(highPriorityTasks)) { return false;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,301
[Migration][Test] jUnit4 -> jUnit5 UT cases migration
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * This is part of DSIP-10 #10573 * By this moment, we have added jUnit 5 dependencies #11332 and removed all `Powermock` related code #11405. It is high time that we migrate all the UT cases from jUnit 4 to jUnit 5 and remove the dependency of `junit-vintage-engine` so that there will be one and only one version of unit test cases, which is jUnit5, in the whole project. ### SOP These two following articles are recommended for you to understand the whole process. In order to keep the instructions brief and concise, I summarize some key points of these two articles as well as add a few extra operations based on practice for your reference: * https://blogs.oracle.com/javamagazine/post/migrating-from-junit-4-to-junit-5-important-differences-and-benefits * https://blog.jetbrains.com/idea/2020/08/migrating-from-junit-4-to-junit-5/ BTW, I suggest you perform this SOP below by module or by file, instead of doing it for the whole project. This helps you increase efficiency. 1. Perform basic migration through `Intellij IDE` for the module you choose. ![screenshot1](https://user-images.githubusercontent.com/34905992/194875626-6560812b-c776-4601-9425-4eafea3288bb.png) 2. Replace `@RunWith(MockitoJUnitRunner.class)` with `@ExtendWith(MockitoExtension.class)` if necessary. 3. Replace `Assert` with `Assertions`. 4. Fix expected exception if necessary. ```java // jUnit 4 @Test(expected = Exception.class) public void testThrowsException() throws Exception { // ... } // jUnit 5 @Test public void testThrowsException() throws Exception { Assertions.assertThrows(Exception.class, () -> { //... }); } ``` 6. Fix timeout if necessary. ```java // jUnit 4 @Test(timeout = 10) public void testFailWithTimeout() throws InterruptedException { Thread.sleep(100); } // jUnit 5 @Test void testFailWithTimeout() throws InterruptedException { Assertions.assertTimeout(Duration.ofMillis(10), () -> Thread.sleep(100)); } Assertions.assertTimeout(Duration.ofMillis(60000), () -> {}); ``` 8. Replace `@Ignore` with `@Disable` if necessary. 9. Replace `org.junit.rules.TemporaryFolder` with `org.junit.jupiter.api.io.TempDir` and use `@TempDir` if necessary. 10. Run the UT file you changed to see whether all cases pass successfully. 11. Fix unnecessary stubbings if necessary. This is caused by changing `@Before` into `@BeforeEach`. The recommend method is to use `@MockitoSettings(strictness = Strictness.LENIENT)`. Alternatively, you could either remove the unnecessary stubbings from `@BeforeEach` and only put them where they needed or use `Mockito.lenient().when(......` for `Mockito.when(......` to bypass the `stubbing check`. 12. Global search in your module and make sure all `org.junit.xxxx` has been migrated to `org.junit.jupiter.api.xxx` ### PR Example * #12299 ### Sub-Tasks We hope to complete all the following sub-tasks ***before Oct. 25th*** because DSIP-10 depends on this issue and all UT cases are supposed to be migrated to jUnit 5 before the start of UT refactoring. - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `task-plugin` module: #12299 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `alert` and `api` module: #12313 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `dao` module: #12319 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `data-quality`, `datasource-plugin` and `registry` module: #12322 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `master`, `worker` and `remote` module: #12316 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `common`, `service` and `spi` module: #12317 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `microbench` and `e2e` module: #12333 - [x] Block explicit imports of jUnit 4 library. #12395 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12301
https://github.com/apache/dolphinscheduler/pull/12450
0eef2e3e10ca8d20d8a0ad59b0f0674f90ee321c
0a6e8af864423dac2aff279bf56f6f1ee95e95b9
2022-10-10T12:48:52Z
java
2022-10-20T04:12:17Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
} int count = taskGroupMapper.selectAvailableCountById(groupId); if (count == 1 && robTaskGroupResource(taskGroupQueue)) { logger.info("Success acquire taskGroup, taskInstanceId: {}, taskGroupId: {}", taskId, groupId); return true; } logger.info("Failed to acquire taskGroup, taskInstanceId: {}, taskGroupId: {}", taskId, groupId); this.taskGroupQueueMapper.updateInQueue(Flag.NO.getCode(), taskGroupQueue.getId()); return false; } /** * try to get the task group resource(when other task release the resource) */ @Override public boolean robTaskGroupResource(TaskGroupQueue taskGroupQueue) { TaskGroup taskGroup = taskGroupMapper.selectById(taskGroupQueue.getGroupId()); int affectedCount = taskGroupMapper.updateTaskGroupResource(taskGroup.getId(), taskGroupQueue.getId(), TaskGroupQueueStatus.WAIT_QUEUE.getCode()); if (affectedCount > 0) { logger.info("Success rob taskGroup, taskInstanceId: {}, taskGroupId: {}", taskGroupQueue.getTaskId(), taskGroupQueue.getId()); taskGroupQueue.setStatus(TaskGroupQueueStatus.ACQUIRE_SUCCESS); this.taskGroupQueueMapper.updateById(taskGroupQueue); this.taskGroupQueueMapper.updateInQueue(Flag.NO.getCode(), taskGroupQueue.getId()); return true; } logger.info("Failed to rob taskGroup, taskInstanceId: {}, taskGroupId: {}", taskGroupQueue.getTaskId(), taskGroupQueue.getId());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,301
[Migration][Test] jUnit4 -> jUnit5 UT cases migration
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * This is part of DSIP-10 #10573 * By this moment, we have added jUnit 5 dependencies #11332 and removed all `Powermock` related code #11405. It is high time that we migrate all the UT cases from jUnit 4 to jUnit 5 and remove the dependency of `junit-vintage-engine` so that there will be one and only one version of unit test cases, which is jUnit5, in the whole project. ### SOP These two following articles are recommended for you to understand the whole process. In order to keep the instructions brief and concise, I summarize some key points of these two articles as well as add a few extra operations based on practice for your reference: * https://blogs.oracle.com/javamagazine/post/migrating-from-junit-4-to-junit-5-important-differences-and-benefits * https://blog.jetbrains.com/idea/2020/08/migrating-from-junit-4-to-junit-5/ BTW, I suggest you perform this SOP below by module or by file, instead of doing it for the whole project. This helps you increase efficiency. 1. Perform basic migration through `Intellij IDE` for the module you choose. ![screenshot1](https://user-images.githubusercontent.com/34905992/194875626-6560812b-c776-4601-9425-4eafea3288bb.png) 2. Replace `@RunWith(MockitoJUnitRunner.class)` with `@ExtendWith(MockitoExtension.class)` if necessary. 3. Replace `Assert` with `Assertions`. 4. Fix expected exception if necessary. ```java // jUnit 4 @Test(expected = Exception.class) public void testThrowsException() throws Exception { // ... } // jUnit 5 @Test public void testThrowsException() throws Exception { Assertions.assertThrows(Exception.class, () -> { //... }); } ``` 6. Fix timeout if necessary. ```java // jUnit 4 @Test(timeout = 10) public void testFailWithTimeout() throws InterruptedException { Thread.sleep(100); } // jUnit 5 @Test void testFailWithTimeout() throws InterruptedException { Assertions.assertTimeout(Duration.ofMillis(10), () -> Thread.sleep(100)); } Assertions.assertTimeout(Duration.ofMillis(60000), () -> {}); ``` 8. Replace `@Ignore` with `@Disable` if necessary. 9. Replace `org.junit.rules.TemporaryFolder` with `org.junit.jupiter.api.io.TempDir` and use `@TempDir` if necessary. 10. Run the UT file you changed to see whether all cases pass successfully. 11. Fix unnecessary stubbings if necessary. This is caused by changing `@Before` into `@BeforeEach`. The recommend method is to use `@MockitoSettings(strictness = Strictness.LENIENT)`. Alternatively, you could either remove the unnecessary stubbings from `@BeforeEach` and only put them where they needed or use `Mockito.lenient().when(......` for `Mockito.when(......` to bypass the `stubbing check`. 12. Global search in your module and make sure all `org.junit.xxxx` has been migrated to `org.junit.jupiter.api.xxx` ### PR Example * #12299 ### Sub-Tasks We hope to complete all the following sub-tasks ***before Oct. 25th*** because DSIP-10 depends on this issue and all UT cases are supposed to be migrated to jUnit 5 before the start of UT refactoring. - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `task-plugin` module: #12299 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `alert` and `api` module: #12313 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `dao` module: #12319 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `data-quality`, `datasource-plugin` and `registry` module: #12322 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `master`, `worker` and `remote` module: #12316 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `common`, `service` and `spi` module: #12317 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `microbench` and `e2e` module: #12333 - [x] Block explicit imports of jUnit 4 library. #12395 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12301
https://github.com/apache/dolphinscheduler/pull/12450
0eef2e3e10ca8d20d8a0ad59b0f0674f90ee321c
0a6e8af864423dac2aff279bf56f6f1ee95e95b9
2022-10-10T12:48:52Z
java
2022-10-20T04:12:17Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
return false; } @Override public void releaseAllTaskGroup(int processInstanceId) { List<TaskInstance> taskInstances = this.taskInstanceMapper.loadAllInfosNoRelease(processInstanceId, TaskGroupQueueStatus.ACQUIRE_SUCCESS.getCode()); for (TaskInstance info : taskInstances) { releaseTaskGroup(info); } } /** * release the TGQ resource when the corresponding task is finished. * * @return the result code and msg */ @Override public TaskInstance releaseTaskGroup(TaskInstance taskInstance) { TaskGroup taskGroup; TaskGroupQueue thisTaskGroupQueue; logger.info("Begin to release task group: {}", taskInstance.getTaskGroupId()); try { do { taskGroup = taskGroupMapper.selectById(taskInstance.getTaskGroupId()); if (taskGroup == null) { logger.error("The taskGroup is null, taskGroupId: {}", taskInstance.getTaskGroupId()); return null; } thisTaskGroupQueue = this.taskGroupQueueMapper.queryByTaskId(taskInstance.getId()); if (thisTaskGroupQueue.getStatus() == TaskGroupQueueStatus.RELEASE) { logger.info("The taskGroupQueue's status is release, taskInstanceId: {}", taskInstance.getId());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,301
[Migration][Test] jUnit4 -> jUnit5 UT cases migration
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * This is part of DSIP-10 #10573 * By this moment, we have added jUnit 5 dependencies #11332 and removed all `Powermock` related code #11405. It is high time that we migrate all the UT cases from jUnit 4 to jUnit 5 and remove the dependency of `junit-vintage-engine` so that there will be one and only one version of unit test cases, which is jUnit5, in the whole project. ### SOP These two following articles are recommended for you to understand the whole process. In order to keep the instructions brief and concise, I summarize some key points of these two articles as well as add a few extra operations based on practice for your reference: * https://blogs.oracle.com/javamagazine/post/migrating-from-junit-4-to-junit-5-important-differences-and-benefits * https://blog.jetbrains.com/idea/2020/08/migrating-from-junit-4-to-junit-5/ BTW, I suggest you perform this SOP below by module or by file, instead of doing it for the whole project. This helps you increase efficiency. 1. Perform basic migration through `Intellij IDE` for the module you choose. ![screenshot1](https://user-images.githubusercontent.com/34905992/194875626-6560812b-c776-4601-9425-4eafea3288bb.png) 2. Replace `@RunWith(MockitoJUnitRunner.class)` with `@ExtendWith(MockitoExtension.class)` if necessary. 3. Replace `Assert` with `Assertions`. 4. Fix expected exception if necessary. ```java // jUnit 4 @Test(expected = Exception.class) public void testThrowsException() throws Exception { // ... } // jUnit 5 @Test public void testThrowsException() throws Exception { Assertions.assertThrows(Exception.class, () -> { //... }); } ``` 6. Fix timeout if necessary. ```java // jUnit 4 @Test(timeout = 10) public void testFailWithTimeout() throws InterruptedException { Thread.sleep(100); } // jUnit 5 @Test void testFailWithTimeout() throws InterruptedException { Assertions.assertTimeout(Duration.ofMillis(10), () -> Thread.sleep(100)); } Assertions.assertTimeout(Duration.ofMillis(60000), () -> {}); ``` 8. Replace `@Ignore` with `@Disable` if necessary. 9. Replace `org.junit.rules.TemporaryFolder` with `org.junit.jupiter.api.io.TempDir` and use `@TempDir` if necessary. 10. Run the UT file you changed to see whether all cases pass successfully. 11. Fix unnecessary stubbings if necessary. This is caused by changing `@Before` into `@BeforeEach`. The recommend method is to use `@MockitoSettings(strictness = Strictness.LENIENT)`. Alternatively, you could either remove the unnecessary stubbings from `@BeforeEach` and only put them where they needed or use `Mockito.lenient().when(......` for `Mockito.when(......` to bypass the `stubbing check`. 12. Global search in your module and make sure all `org.junit.xxxx` has been migrated to `org.junit.jupiter.api.xxx` ### PR Example * #12299 ### Sub-Tasks We hope to complete all the following sub-tasks ***before Oct. 25th*** because DSIP-10 depends on this issue and all UT cases are supposed to be migrated to jUnit 5 before the start of UT refactoring. - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `task-plugin` module: #12299 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `alert` and `api` module: #12313 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `dao` module: #12319 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `data-quality`, `datasource-plugin` and `registry` module: #12322 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `master`, `worker` and `remote` module: #12316 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `common`, `service` and `spi` module: #12317 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `microbench` and `e2e` module: #12333 - [x] Block explicit imports of jUnit 4 library. #12395 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12301
https://github.com/apache/dolphinscheduler/pull/12450
0eef2e3e10ca8d20d8a0ad59b0f0674f90ee321c
0a6e8af864423dac2aff279bf56f6f1ee95e95b9
2022-10-10T12:48:52Z
java
2022-10-20T04:12:17Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
return null; } } while (thisTaskGroupQueue.getForceStart() == Flag.NO.getCode() && taskGroupMapper.releaseTaskGroupResource(taskGroup.getId(), taskGroup.getUseSize(), thisTaskGroupQueue.getId(), TaskGroupQueueStatus.ACQUIRE_SUCCESS.getCode()) != 1); } catch (Exception e) { logger.error("release the task group error", e); return null; } logger.info("Finished to release task group, taskGroupId: {}", taskInstance.getTaskGroupId()); logger.info("Begin to release task group queue, taskGroupId: {}", taskInstance.getTaskGroupId()); changeTaskGroupQueueStatus(taskInstance.getId(), TaskGroupQueueStatus.RELEASE); TaskGroupQueue taskGroupQueue; do { taskGroupQueue = this.taskGroupQueueMapper.queryTheHighestPriorityTasks(taskGroup.getId(), TaskGroupQueueStatus.WAIT_QUEUE.getCode(), Flag.NO.getCode(), Flag.NO.getCode()); if (taskGroupQueue == null) { logger.info("The taskGroupQueue is null, taskGroup: {}", taskGroup.getId()); return null; } } while (this.taskGroupQueueMapper.updateInQueueCAS(Flag.NO.getCode(), Flag.YES.getCode(), taskGroupQueue.getId()) != 1); logger.info("Finished to release task group queue: taskGroupId: {}", taskInstance.getTaskGroupId()); return this.taskInstanceMapper.selectById(taskGroupQueue.getTaskId()); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,301
[Migration][Test] jUnit4 -> jUnit5 UT cases migration
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * This is part of DSIP-10 #10573 * By this moment, we have added jUnit 5 dependencies #11332 and removed all `Powermock` related code #11405. It is high time that we migrate all the UT cases from jUnit 4 to jUnit 5 and remove the dependency of `junit-vintage-engine` so that there will be one and only one version of unit test cases, which is jUnit5, in the whole project. ### SOP These two following articles are recommended for you to understand the whole process. In order to keep the instructions brief and concise, I summarize some key points of these two articles as well as add a few extra operations based on practice for your reference: * https://blogs.oracle.com/javamagazine/post/migrating-from-junit-4-to-junit-5-important-differences-and-benefits * https://blog.jetbrains.com/idea/2020/08/migrating-from-junit-4-to-junit-5/ BTW, I suggest you perform this SOP below by module or by file, instead of doing it for the whole project. This helps you increase efficiency. 1. Perform basic migration through `Intellij IDE` for the module you choose. ![screenshot1](https://user-images.githubusercontent.com/34905992/194875626-6560812b-c776-4601-9425-4eafea3288bb.png) 2. Replace `@RunWith(MockitoJUnitRunner.class)` with `@ExtendWith(MockitoExtension.class)` if necessary. 3. Replace `Assert` with `Assertions`. 4. Fix expected exception if necessary. ```java // jUnit 4 @Test(expected = Exception.class) public void testThrowsException() throws Exception { // ... } // jUnit 5 @Test public void testThrowsException() throws Exception { Assertions.assertThrows(Exception.class, () -> { //... }); } ``` 6. Fix timeout if necessary. ```java // jUnit 4 @Test(timeout = 10) public void testFailWithTimeout() throws InterruptedException { Thread.sleep(100); } // jUnit 5 @Test void testFailWithTimeout() throws InterruptedException { Assertions.assertTimeout(Duration.ofMillis(10), () -> Thread.sleep(100)); } Assertions.assertTimeout(Duration.ofMillis(60000), () -> {}); ``` 8. Replace `@Ignore` with `@Disable` if necessary. 9. Replace `org.junit.rules.TemporaryFolder` with `org.junit.jupiter.api.io.TempDir` and use `@TempDir` if necessary. 10. Run the UT file you changed to see whether all cases pass successfully. 11. Fix unnecessary stubbings if necessary. This is caused by changing `@Before` into `@BeforeEach`. The recommend method is to use `@MockitoSettings(strictness = Strictness.LENIENT)`. Alternatively, you could either remove the unnecessary stubbings from `@BeforeEach` and only put them where they needed or use `Mockito.lenient().when(......` for `Mockito.when(......` to bypass the `stubbing check`. 12. Global search in your module and make sure all `org.junit.xxxx` has been migrated to `org.junit.jupiter.api.xxx` ### PR Example * #12299 ### Sub-Tasks We hope to complete all the following sub-tasks ***before Oct. 25th*** because DSIP-10 depends on this issue and all UT cases are supposed to be migrated to jUnit 5 before the start of UT refactoring. - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `task-plugin` module: #12299 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `alert` and `api` module: #12313 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `dao` module: #12319 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `data-quality`, `datasource-plugin` and `registry` module: #12322 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `master`, `worker` and `remote` module: #12316 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `common`, `service` and `spi` module: #12317 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `microbench` and `e2e` module: #12333 - [x] Block explicit imports of jUnit 4 library. #12395 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12301
https://github.com/apache/dolphinscheduler/pull/12450
0eef2e3e10ca8d20d8a0ad59b0f0674f90ee321c
0a6e8af864423dac2aff279bf56f6f1ee95e95b9
2022-10-10T12:48:52Z
java
2022-10-20T04:12:17Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
/** * release the TGQ resource when the corresponding task is finished. * * @param taskId task id * @return the result code and msg */ @Override public void changeTaskGroupQueueStatus(int taskId, TaskGroupQueueStatus status) { TaskGroupQueue taskGroupQueue = taskGroupQueueMapper.queryByTaskId(taskId); taskGroupQueue.setStatus(status); taskGroupQueue.setUpdateTime(new Date(System.currentTimeMillis())); taskGroupQueueMapper.updateById(taskGroupQueue); } /** * insert into task group queue * * @param taskId task id * @param taskName task name * @param groupId group id * @param processId process id * @param priority priority * @return inserted task group queue */ @Override public TaskGroupQueue insertIntoTaskGroupQueue(Integer taskId, String taskName, Integer groupId, Integer processId, Integer priority, TaskGroupQueueStatus status) { TaskGroupQueue taskGroupQueue = new TaskGroupQueue(taskId, taskName, groupId, processId, priority, status); taskGroupQueue.setCreateTime(new Date()); taskGroupQueue.setUpdateTime(new Date());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,301
[Migration][Test] jUnit4 -> jUnit5 UT cases migration
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * This is part of DSIP-10 #10573 * By this moment, we have added jUnit 5 dependencies #11332 and removed all `Powermock` related code #11405. It is high time that we migrate all the UT cases from jUnit 4 to jUnit 5 and remove the dependency of `junit-vintage-engine` so that there will be one and only one version of unit test cases, which is jUnit5, in the whole project. ### SOP These two following articles are recommended for you to understand the whole process. In order to keep the instructions brief and concise, I summarize some key points of these two articles as well as add a few extra operations based on practice for your reference: * https://blogs.oracle.com/javamagazine/post/migrating-from-junit-4-to-junit-5-important-differences-and-benefits * https://blog.jetbrains.com/idea/2020/08/migrating-from-junit-4-to-junit-5/ BTW, I suggest you perform this SOP below by module or by file, instead of doing it for the whole project. This helps you increase efficiency. 1. Perform basic migration through `Intellij IDE` for the module you choose. ![screenshot1](https://user-images.githubusercontent.com/34905992/194875626-6560812b-c776-4601-9425-4eafea3288bb.png) 2. Replace `@RunWith(MockitoJUnitRunner.class)` with `@ExtendWith(MockitoExtension.class)` if necessary. 3. Replace `Assert` with `Assertions`. 4. Fix expected exception if necessary. ```java // jUnit 4 @Test(expected = Exception.class) public void testThrowsException() throws Exception { // ... } // jUnit 5 @Test public void testThrowsException() throws Exception { Assertions.assertThrows(Exception.class, () -> { //... }); } ``` 6. Fix timeout if necessary. ```java // jUnit 4 @Test(timeout = 10) public void testFailWithTimeout() throws InterruptedException { Thread.sleep(100); } // jUnit 5 @Test void testFailWithTimeout() throws InterruptedException { Assertions.assertTimeout(Duration.ofMillis(10), () -> Thread.sleep(100)); } Assertions.assertTimeout(Duration.ofMillis(60000), () -> {}); ``` 8. Replace `@Ignore` with `@Disable` if necessary. 9. Replace `org.junit.rules.TemporaryFolder` with `org.junit.jupiter.api.io.TempDir` and use `@TempDir` if necessary. 10. Run the UT file you changed to see whether all cases pass successfully. 11. Fix unnecessary stubbings if necessary. This is caused by changing `@Before` into `@BeforeEach`. The recommend method is to use `@MockitoSettings(strictness = Strictness.LENIENT)`. Alternatively, you could either remove the unnecessary stubbings from `@BeforeEach` and only put them where they needed or use `Mockito.lenient().when(......` for `Mockito.when(......` to bypass the `stubbing check`. 12. Global search in your module and make sure all `org.junit.xxxx` has been migrated to `org.junit.jupiter.api.xxx` ### PR Example * #12299 ### Sub-Tasks We hope to complete all the following sub-tasks ***before Oct. 25th*** because DSIP-10 depends on this issue and all UT cases are supposed to be migrated to jUnit 5 before the start of UT refactoring. - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `task-plugin` module: #12299 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `alert` and `api` module: #12313 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `dao` module: #12319 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `data-quality`, `datasource-plugin` and `registry` module: #12322 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `master`, `worker` and `remote` module: #12316 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `common`, `service` and `spi` module: #12317 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `microbench` and `e2e` module: #12333 - [x] Block explicit imports of jUnit 4 library. #12395 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12301
https://github.com/apache/dolphinscheduler/pull/12450
0eef2e3e10ca8d20d8a0ad59b0f0674f90ee321c
0a6e8af864423dac2aff279bf56f6f1ee95e95b9
2022-10-10T12:48:52Z
java
2022-10-20T04:12:17Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
taskGroupQueueMapper.insert(taskGroupQueue); return taskGroupQueue; } @Override public int updateTaskGroupQueueStatus(Integer taskId, int status) { return taskGroupQueueMapper.updateStatusByTaskId(taskId, status); } @Override public int updateTaskGroupQueue(TaskGroupQueue taskGroupQueue) { return taskGroupQueueMapper.updateById(taskGroupQueue); } @Override public TaskGroupQueue loadTaskGroupQueue(int taskId) { return this.taskGroupQueueMapper.queryByTaskId(taskId); } @Override public void sendStartTask2Master(ProcessInstance processInstance, int taskId, org.apache.dolphinscheduler.remote.command.CommandType taskType) { TaskEventChangeCommand taskEventChangeCommand = new TaskEventChangeCommand( processInstance.getId(), taskId); Host host = new Host(processInstance.getHost()); stateEventCallbackService.sendResult(host, taskEventChangeCommand.convert2Command(taskType)); } @Override public ProcessInstance loadNextProcess4Serial(long code, int state, int id) { return this.processInstanceMapper.loadNextProcess4Serial(code, state, id); } protected void deleteCommandWithCheck(int commandId) { int delete = this.commandMapper.deleteById(commandId); if (delete != 1) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,301
[Migration][Test] jUnit4 -> jUnit5 UT cases migration
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * This is part of DSIP-10 #10573 * By this moment, we have added jUnit 5 dependencies #11332 and removed all `Powermock` related code #11405. It is high time that we migrate all the UT cases from jUnit 4 to jUnit 5 and remove the dependency of `junit-vintage-engine` so that there will be one and only one version of unit test cases, which is jUnit5, in the whole project. ### SOP These two following articles are recommended for you to understand the whole process. In order to keep the instructions brief and concise, I summarize some key points of these two articles as well as add a few extra operations based on practice for your reference: * https://blogs.oracle.com/javamagazine/post/migrating-from-junit-4-to-junit-5-important-differences-and-benefits * https://blog.jetbrains.com/idea/2020/08/migrating-from-junit-4-to-junit-5/ BTW, I suggest you perform this SOP below by module or by file, instead of doing it for the whole project. This helps you increase efficiency. 1. Perform basic migration through `Intellij IDE` for the module you choose. ![screenshot1](https://user-images.githubusercontent.com/34905992/194875626-6560812b-c776-4601-9425-4eafea3288bb.png) 2. Replace `@RunWith(MockitoJUnitRunner.class)` with `@ExtendWith(MockitoExtension.class)` if necessary. 3. Replace `Assert` with `Assertions`. 4. Fix expected exception if necessary. ```java // jUnit 4 @Test(expected = Exception.class) public void testThrowsException() throws Exception { // ... } // jUnit 5 @Test public void testThrowsException() throws Exception { Assertions.assertThrows(Exception.class, () -> { //... }); } ``` 6. Fix timeout if necessary. ```java // jUnit 4 @Test(timeout = 10) public void testFailWithTimeout() throws InterruptedException { Thread.sleep(100); } // jUnit 5 @Test void testFailWithTimeout() throws InterruptedException { Assertions.assertTimeout(Duration.ofMillis(10), () -> Thread.sleep(100)); } Assertions.assertTimeout(Duration.ofMillis(60000), () -> {}); ``` 8. Replace `@Ignore` with `@Disable` if necessary. 9. Replace `org.junit.rules.TemporaryFolder` with `org.junit.jupiter.api.io.TempDir` and use `@TempDir` if necessary. 10. Run the UT file you changed to see whether all cases pass successfully. 11. Fix unnecessary stubbings if necessary. This is caused by changing `@Before` into `@BeforeEach`. The recommend method is to use `@MockitoSettings(strictness = Strictness.LENIENT)`. Alternatively, you could either remove the unnecessary stubbings from `@BeforeEach` and only put them where they needed or use `Mockito.lenient().when(......` for `Mockito.when(......` to bypass the `stubbing check`. 12. Global search in your module and make sure all `org.junit.xxxx` has been migrated to `org.junit.jupiter.api.xxx` ### PR Example * #12299 ### Sub-Tasks We hope to complete all the following sub-tasks ***before Oct. 25th*** because DSIP-10 depends on this issue and all UT cases are supposed to be migrated to jUnit 5 before the start of UT refactoring. - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `task-plugin` module: #12299 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `alert` and `api` module: #12313 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `dao` module: #12319 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `data-quality`, `datasource-plugin` and `registry` module: #12322 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `master`, `worker` and `remote` module: #12316 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `common`, `service` and `spi` module: #12317 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `microbench` and `e2e` module: #12333 - [x] Block explicit imports of jUnit 4 library. #12395 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12301
https://github.com/apache/dolphinscheduler/pull/12450
0eef2e3e10ca8d20d8a0ad59b0f0674f90ee321c
0a6e8af864423dac2aff279bf56f6f1ee95e95b9
2022-10-10T12:48:52Z
java
2022-10-20T04:12:17Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
throw new ServiceException("delete command fail, id:" + commandId); } } /** * find k8s config yaml by clusterName * * @param clusterName clusterName * @return datasource */ @Override public String findConfigYamlByName(String clusterName) { if (Strings.isNullOrEmpty(clusterName)) { return null; } QueryWrapper<Cluster> nodeWrapper = new QueryWrapper<>(); nodeWrapper.eq("name", clusterName); Cluster cluster = clusterMapper.selectOne(nodeWrapper); return cluster == null ? null : cluster.getConfig(); } @Override public void forceProcessInstanceSuccessByTaskInstanceId(Integer taskInstanceId) { TaskInstance task = taskInstanceMapper.selectById(taskInstanceId); if (task == null) { return; } ProcessInstance processInstance = findProcessInstanceDetailById(task.getProcessInstanceId()).orElse(null); if (processInstance != null && (processInstance.getState().isFailure() || processInstance.getState().isStop())) { List<TaskInstance> validTaskList = findValidTaskListByProcessId(processInstance.getId(), processInstance.getTestFlag());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,301
[Migration][Test] jUnit4 -> jUnit5 UT cases migration
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * This is part of DSIP-10 #10573 * By this moment, we have added jUnit 5 dependencies #11332 and removed all `Powermock` related code #11405. It is high time that we migrate all the UT cases from jUnit 4 to jUnit 5 and remove the dependency of `junit-vintage-engine` so that there will be one and only one version of unit test cases, which is jUnit5, in the whole project. ### SOP These two following articles are recommended for you to understand the whole process. In order to keep the instructions brief and concise, I summarize some key points of these two articles as well as add a few extra operations based on practice for your reference: * https://blogs.oracle.com/javamagazine/post/migrating-from-junit-4-to-junit-5-important-differences-and-benefits * https://blog.jetbrains.com/idea/2020/08/migrating-from-junit-4-to-junit-5/ BTW, I suggest you perform this SOP below by module or by file, instead of doing it for the whole project. This helps you increase efficiency. 1. Perform basic migration through `Intellij IDE` for the module you choose. ![screenshot1](https://user-images.githubusercontent.com/34905992/194875626-6560812b-c776-4601-9425-4eafea3288bb.png) 2. Replace `@RunWith(MockitoJUnitRunner.class)` with `@ExtendWith(MockitoExtension.class)` if necessary. 3. Replace `Assert` with `Assertions`. 4. Fix expected exception if necessary. ```java // jUnit 4 @Test(expected = Exception.class) public void testThrowsException() throws Exception { // ... } // jUnit 5 @Test public void testThrowsException() throws Exception { Assertions.assertThrows(Exception.class, () -> { //... }); } ``` 6. Fix timeout if necessary. ```java // jUnit 4 @Test(timeout = 10) public void testFailWithTimeout() throws InterruptedException { Thread.sleep(100); } // jUnit 5 @Test void testFailWithTimeout() throws InterruptedException { Assertions.assertTimeout(Duration.ofMillis(10), () -> Thread.sleep(100)); } Assertions.assertTimeout(Duration.ofMillis(60000), () -> {}); ``` 8. Replace `@Ignore` with `@Disable` if necessary. 9. Replace `org.junit.rules.TemporaryFolder` with `org.junit.jupiter.api.io.TempDir` and use `@TempDir` if necessary. 10. Run the UT file you changed to see whether all cases pass successfully. 11. Fix unnecessary stubbings if necessary. This is caused by changing `@Before` into `@BeforeEach`. The recommend method is to use `@MockitoSettings(strictness = Strictness.LENIENT)`. Alternatively, you could either remove the unnecessary stubbings from `@BeforeEach` and only put them where they needed or use `Mockito.lenient().when(......` for `Mockito.when(......` to bypass the `stubbing check`. 12. Global search in your module and make sure all `org.junit.xxxx` has been migrated to `org.junit.jupiter.api.xxx` ### PR Example * #12299 ### Sub-Tasks We hope to complete all the following sub-tasks ***before Oct. 25th*** because DSIP-10 depends on this issue and all UT cases are supposed to be migrated to jUnit 5 before the start of UT refactoring. - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `task-plugin` module: #12299 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `alert` and `api` module: #12313 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `dao` module: #12319 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `data-quality`, `datasource-plugin` and `registry` module: #12322 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `master`, `worker` and `remote` module: #12316 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `common`, `service` and `spi` module: #12317 - [x] Migrate all UT cases from jUnit 4 to jUnit 5 in `microbench` and `e2e` module: #12333 - [x] Block explicit imports of jUnit 4 library. #12395 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12301
https://github.com/apache/dolphinscheduler/pull/12450
0eef2e3e10ca8d20d8a0ad59b0f0674f90ee321c
0a6e8af864423dac2aff279bf56f6f1ee95e95b9
2022-10-10T12:48:52Z
java
2022-10-20T04:12:17Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
List<Long> instanceTaskCodeList = validTaskList.stream().map(TaskInstance::getTaskCode).collect(Collectors.toList()); List<ProcessTaskRelation> taskRelations = findRelationByCode(processInstance.getProcessDefinitionCode(), processInstance.getProcessDefinitionVersion()); List<TaskDefinitionLog> taskDefinitionLogs = genTaskDefineList(taskRelations); List<Long> definiteTaskCodeList = taskDefinitionLogs.stream().filter(definitionLog -> definitionLog.getFlag() == Flag.YES) .map(TaskDefinitionLog::getCode).collect(Collectors.toList()); if (org.apache.dolphinscheduler.common.utils.CollectionUtils.equalLists(instanceTaskCodeList, definiteTaskCodeList)) { List<Integer> failTaskList = validTaskList.stream() .filter(instance -> instance.getState().isFailure() || instance.getState().isKill()) .map(TaskInstance::getId).collect(Collectors.toList()); if (failTaskList.size() == 1 && failTaskList.contains(taskInstanceId)) { processInstance.setStateWithDesc(WorkflowExecutionStatus.SUCCESS, "success by task force success"); processInstanceDao.updateProcessInstance(processInstance); } } } } @Override public Integer queryTestDataSourceId(Integer onlineDataSourceId) { Integer testDataSourceId = dataSourceMapper.queryTestDataSourceId(onlineDataSourceId); if (testDataSourceId != null) return testDataSourceId; return null; } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,410
[Bug] [API] In the workflow definition, the result of the worker list is only default
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In the workflow definition, the result of the worker list is only default ### What you expected to happen In the workflow definition, the result of the worker list is only default ### How to reproduce In the workflow definition, the list of workers appears fine ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12410
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-18T04:17:51Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership.
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,410
[Bug] [API] In the workflow definition, the result of the worker list is only default
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In the workflow definition, the result of the worker list is only default ### What you expected to happen In the workflow definition, the result of the worker list is only default ### How to reproduce In the workflow definition, the list of workers appears fine ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12410
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-18T04:17:51Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java
* The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.dolphinscheduler.api.permission; import static java.util.stream.Collectors.toSet; import org.apache.dolphinscheduler.common.enums.AuthorizationType; import org.apache.dolphinscheduler.common.enums.UserType; import org.apache.dolphinscheduler.dao.entity.AccessToken; import org.apache.dolphinscheduler.dao.entity.AlertGroup; import org.apache.dolphinscheduler.dao.entity.DataSource; import org.apache.dolphinscheduler.dao.entity.Environment; import org.apache.dolphinscheduler.dao.entity.Project; import org.apache.dolphinscheduler.dao.entity.Queue; import org.apache.dolphinscheduler.dao.entity.Resource; import org.apache.dolphinscheduler.dao.entity.TaskGroup; import org.apache.dolphinscheduler.dao.entity.Tenant; import org.apache.dolphinscheduler.dao.entity.UdfFunc; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.mapper.AccessTokenMapper; import org.apache.dolphinscheduler.dao.mapper.AlertGroupMapper; import org.apache.dolphinscheduler.dao.mapper.AlertPluginInstanceMapper;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,410
[Bug] [API] In the workflow definition, the result of the worker list is only default
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In the workflow definition, the result of the worker list is only default ### What you expected to happen In the workflow definition, the result of the worker list is only default ### How to reproduce In the workflow definition, the list of workers appears fine ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12410
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-18T04:17:51Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java
import org.apache.dolphinscheduler.dao.mapper.DataSourceMapper; import org.apache.dolphinscheduler.dao.mapper.EnvironmentMapper; import org.apache.dolphinscheduler.dao.mapper.K8sNamespaceMapper; import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; import org.apache.dolphinscheduler.dao.mapper.QueueMapper; import org.apache.dolphinscheduler.dao.mapper.ResourceMapper; import org.apache.dolphinscheduler.dao.mapper.ResourceUserMapper; import org.apache.dolphinscheduler.dao.mapper.TaskGroupMapper; import org.apache.dolphinscheduler.dao.mapper.TenantMapper; import org.apache.dolphinscheduler.dao.mapper.UdfFuncMapper; import org.apache.dolphinscheduler.dao.mapper.WorkerGroupMapper; import org.apache.dolphinscheduler.service.process.ProcessService; import org.apache.commons.collections.CollectionUtils; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; import org.slf4j.Logger; import org.springframework.beans.BeansException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.stereotype.Component; @Component
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,410
[Bug] [API] In the workflow definition, the result of the worker list is only default
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In the workflow definition, the result of the worker list is only default ### What you expected to happen In the workflow definition, the result of the worker list is only default ### How to reproduce In the workflow definition, the list of workers appears fine ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12410
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-18T04:17:51Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java
public class ResourcePermissionCheckServiceImpl implements ResourcePermissionCheckService<Object>, ApplicationContextAware { @Autowired private ProcessService processService; public static final Map<AuthorizationType, ResourceAcquisitionAndPermissionCheck<?>> RESOURCE_LIST_MAP = new ConcurrentHashMap<>(); @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { for (ResourceAcquisitionAndPermissionCheck<?> authorizedResourceList : applicationContext .getBeansOfType(ResourceAcquisitionAndPermissionCheck.class).values()) { List<AuthorizationType> authorizationTypes = authorizedResourceList.authorizationTypes(); authorizationTypes.forEach(auth -> RESOURCE_LIST_MAP.put(auth, authorizedResourceList)); } } @Override public boolean resourcePermissionCheck(Object authorizationType, Object[] needChecks, Integer userId, Logger logger) { if (Objects.nonNull(needChecks) && needChecks.length > 0) { Set<?> originResSet = new HashSet<>(Arrays.asList(needChecks)); Set<?> ownResSets = RESOURCE_LIST_MAP.get(authorizationType).listAuthorizedResource(userId, logger); originResSet.removeAll(ownResSets); if (CollectionUtils.isNotEmpty(originResSet)) logger.warn("User does not have resource permission on associated resources, userId:{}", userId); return CollectionUtils.isEmpty(originResSet);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,410
[Bug] [API] In the workflow definition, the result of the worker list is only default
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In the workflow definition, the result of the worker list is only default ### What you expected to happen In the workflow definition, the result of the worker list is only default ### How to reproduce In the workflow definition, the list of workers appears fine ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12410
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-18T04:17:51Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java
} return true; } @Override public boolean operationPermissionCheck(Object authorizationType, Object[] projectIds, Integer userId, String permissionKey, Logger logger) { User user = processService.getUserById(userId); if (user == null) { logger.error("User does not exist, userId:{}.", userId); return false; } if (user.getUserType().equals(UserType.ADMIN_USER)) { return true; } return RESOURCE_LIST_MAP.get(authorizationType).permissionCheck(userId, permissionKey, logger); } @Override public boolean functionDisabled() { return false; } @Override public void postHandle(Object authorizationType, Integer userId, List<Integer> ids, Logger logger) { logger.debug("no post handle"); } @Override public Set<Object> userOwnedResourceIdsAcquisition(Object authorizationType, Integer userId, Logger logger) { User user = processService.getUserById(userId); if (user == null) { logger.error("User does not exist, userId:{}.", userId); return Collections.emptySet();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,410
[Bug] [API] In the workflow definition, the result of the worker list is only default
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In the workflow definition, the result of the worker list is only default ### What you expected to happen In the workflow definition, the result of the worker list is only default ### How to reproduce In the workflow definition, the list of workers appears fine ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12410
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-18T04:17:51Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java
} return (Set<Object>) RESOURCE_LIST_MAP.get(authorizationType).listAuthorizedResource( user.getUserType().equals(UserType.ADMIN_USER) ? 0 : userId, logger); } @Component public static class QueueResourcePermissionCheck implements ResourceAcquisitionAndPermissionCheck<Integer> { private final QueueMapper queueMapper; public QueueResourcePermissionCheck(QueueMapper queueMapper) { this.queueMapper = queueMapper; } @Override public List<AuthorizationType> authorizationTypes() { return Collections.singletonList(AuthorizationType.QUEUE); } @Override public boolean permissionCheck(int userId, String permissionKey, Logger logger) { return false; } @Override public Set<Integer> listAuthorizedResource(int userId, Logger logger) { if (userId != 0) { return Collections.emptySet(); } List<Queue> queues = queueMapper.selectList(null); return CollectionUtils.isEmpty(queues) ? Collections.emptySet() : queues.stream().map(Queue::getId).collect(toSet()); } } @Component
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,410
[Bug] [API] In the workflow definition, the result of the worker list is only default
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In the workflow definition, the result of the worker list is only default ### What you expected to happen In the workflow definition, the result of the worker list is only default ### How to reproduce In the workflow definition, the list of workers appears fine ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12410
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-18T04:17:51Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java
public static class ProjectsResourcePermissionCheck implements ResourceAcquisitionAndPermissionCheck<Integer> { private final ProjectMapper projectMapper; public ProjectsResourcePermissionCheck(ProjectMapper projectMapper) { this.projectMapper = projectMapper; } @Override public List<AuthorizationType> authorizationTypes() { return Collections.singletonList(AuthorizationType.PROJECTS); } @Override public boolean permissionCheck(int userId, String permissionKey, Logger logger) { return true; } @Override public Set<Integer> listAuthorizedResource(int userId, Logger logger) { return projectMapper.listAuthorizedProjects(userId, null).stream().map(Project::getId).collect(toSet()); } } @Component
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,410
[Bug] [API] In the workflow definition, the result of the worker list is only default
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In the workflow definition, the result of the worker list is only default ### What you expected to happen In the workflow definition, the result of the worker list is only default ### How to reproduce In the workflow definition, the list of workers appears fine ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12410
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-18T04:17:51Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java
public static class FilePermissionCheck implements ResourceAcquisitionAndPermissionCheck<Integer> { private final ResourceMapper resourceMapper; private final ResourceUserMapper resourceUserMapper; public FilePermissionCheck(ResourceMapper resourceMapper, ResourceUserMapper resourceUserMapper) { this.resourceMapper = resourceMapper; this.resourceUserMapper = resourceUserMapper; } @Override public List<AuthorizationType> authorizationTypes() { return Arrays.asList(AuthorizationType.RESOURCE_FILE_ID, AuthorizationType.UDF_FILE); } @Override public Set<Integer> listAuthorizedResource(int userId, Logger logger) { List<Resource> relationResources; if (userId == 0) { relationResources = new ArrayList<>(); } else { List<Integer> resIds = resourceUserMapper.queryResourcesIdListByUserIdAndPerm(userId, 0); relationResources = CollectionUtils.isEmpty(resIds) ? new ArrayList<>() : resourceMapper.queryResourceListById(resIds); } List<Resource> ownResourceList = resourceMapper.queryResourceListAuthored(userId, -1); relationResources.addAll(ownResourceList); return ownResourceList.stream().map(Resource::getId).collect(toSet());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,410
[Bug] [API] In the workflow definition, the result of the worker list is only default
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In the workflow definition, the result of the worker list is only default ### What you expected to happen In the workflow definition, the result of the worker list is only default ### How to reproduce In the workflow definition, the list of workers appears fine ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12410
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-18T04:17:51Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java
} @Override public boolean permissionCheck(int userId, String permissionKey, Logger logger) { return true; } } @Component public static class UdfFuncPermissionCheck implements ResourceAcquisitionAndPermissionCheck<Integer> { private final UdfFuncMapper udfFuncMapper; public UdfFuncPermissionCheck(UdfFuncMapper udfFuncMapper) { this.udfFuncMapper = udfFuncMapper; } @Override public List<AuthorizationType> authorizationTypes() { return Collections.singletonList(AuthorizationType.UDF); } @Override public Set<Integer> listAuthorizedResource(int userId, Logger logger) { List<UdfFunc> udfFuncList = udfFuncMapper.listAuthorizedUdfByUserId(userId); if (CollectionUtils.isEmpty(udfFuncList)) { return Collections.emptySet(); } return udfFuncList.stream().map(UdfFunc::getId).collect(toSet()); } @Override public boolean permissionCheck(int userId, String permissionKey, Logger logger) { return true; } } @Component
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,410
[Bug] [API] In the workflow definition, the result of the worker list is only default
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In the workflow definition, the result of the worker list is only default ### What you expected to happen In the workflow definition, the result of the worker list is only default ### How to reproduce In the workflow definition, the list of workers appears fine ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12410
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-18T04:17:51Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java
public static class TaskGroupPermissionCheck implements ResourceAcquisitionAndPermissionCheck<Integer> { private final TaskGroupMapper taskGroupMapper; public TaskGroupPermissionCheck(TaskGroupMapper taskGroupMapper) { this.taskGroupMapper = taskGroupMapper; } @Override public List<AuthorizationType> authorizationTypes() { return Collections.singletonList(AuthorizationType.TASK_GROUP); } @Override public Set<Integer> listAuthorizedResource(int userId, Logger logger) { List<TaskGroup> taskGroupList = taskGroupMapper.listAuthorizedResource(userId); if (CollectionUtils.isEmpty(taskGroupList)) { return Collections.emptySet(); } return taskGroupList.stream().map(TaskGroup::getId).collect(Collectors.toSet()); } @Override public boolean permissionCheck(int userId, String permissionKey, Logger logger) { return true; } } @Component
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,410
[Bug] [API] In the workflow definition, the result of the worker list is only default
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In the workflow definition, the result of the worker list is only default ### What you expected to happen In the workflow definition, the result of the worker list is only default ### How to reproduce In the workflow definition, the list of workers appears fine ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12410
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-18T04:17:51Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java
public static class K8sNamespaceResourceList implements ResourceAcquisitionAndPermissionCheck<Integer> { private final K8sNamespaceMapper k8sNamespaceMapper; public K8sNamespaceResourceList(K8sNamespaceMapper k8sNamespaceMapper) { this.k8sNamespaceMapper = k8sNamespaceMapper; } @Override public List<AuthorizationType> authorizationTypes() { return Collections.singletonList(AuthorizationType.K8S_NAMESPACE); } @Override public boolean permissionCheck(int userId, String url, Logger logger) { return false; } @Override public Set<Integer> listAuthorizedResource(int userId, Logger logger) { return Collections.emptySet(); } } @Component
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,410
[Bug] [API] In the workflow definition, the result of the worker list is only default
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In the workflow definition, the result of the worker list is only default ### What you expected to happen In the workflow definition, the result of the worker list is only default ### How to reproduce In the workflow definition, the list of workers appears fine ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12410
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-18T04:17:51Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java
public static class EnvironmentResourceList implements ResourceAcquisitionAndPermissionCheck<Integer> { private final EnvironmentMapper environmentMapper; public EnvironmentResourceList(EnvironmentMapper environmentMapper) { this.environmentMapper = environmentMapper; } @Override public List<AuthorizationType> authorizationTypes() { return Collections.singletonList(AuthorizationType.ENVIRONMENT); } @Override public boolean permissionCheck(int userId, String url, Logger logger) { return true; } @Override public Set<Integer> listAuthorizedResource(int userId, Logger logger) { List<Environment> environments = environmentMapper.queryAllEnvironmentList(); if (CollectionUtils.isEmpty(environments)) { return Collections.emptySet(); } return environments.stream().map(Environment::getId).collect(Collectors.toSet()); } } @Component
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,410
[Bug] [API] In the workflow definition, the result of the worker list is only default
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In the workflow definition, the result of the worker list is only default ### What you expected to happen In the workflow definition, the result of the worker list is only default ### How to reproduce In the workflow definition, the list of workers appears fine ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12410
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-18T04:17:51Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java
public static class WorkerGroupResourceList implements ResourceAcquisitionAndPermissionCheck<Integer> { private final WorkerGroupMapper workerGroupMapper; public WorkerGroupResourceList(WorkerGroupMapper workerGroupMapper) { this.workerGroupMapper = workerGroupMapper; } @Override public List<AuthorizationType> authorizationTypes() { return Collections.singletonList(AuthorizationType.WORKER_GROUP); } @Override public boolean permissionCheck(int userId, String url, Logger logger) { return false; } @Override public Set<Integer> listAuthorizedResource(int userId, Logger logger) { return Collections.emptySet(); } } /** * AlertPluginInstance Resource */ @Component
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,410
[Bug] [API] In the workflow definition, the result of the worker list is only default
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In the workflow definition, the result of the worker list is only default ### What you expected to happen In the workflow definition, the result of the worker list is only default ### How to reproduce In the workflow definition, the list of workers appears fine ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12410
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-18T04:17:51Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java
public static class AlertPluginInstanceResourceList implements ResourceAcquisitionAndPermissionCheck<Integer> { private final AlertPluginInstanceMapper alertPluginInstanceMapper; public AlertPluginInstanceResourceList(AlertPluginInstanceMapper alertPluginInstanceMapper) { this.alertPluginInstanceMapper = alertPluginInstanceMapper; } @Override public List<AuthorizationType> authorizationTypes() { return Collections.singletonList(AuthorizationType.ALERT_PLUGIN_INSTANCE); } @Override public boolean permissionCheck(int userId, String url, Logger logger) { return false; } @Override public Set<Integer> listAuthorizedResource(int userId, Logger logger) { return Collections.emptySet(); } } /** * AlertPluginInstance Resource */ @Component
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,410
[Bug] [API] In the workflow definition, the result of the worker list is only default
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In the workflow definition, the result of the worker list is only default ### What you expected to happen In the workflow definition, the result of the worker list is only default ### How to reproduce In the workflow definition, the list of workers appears fine ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12410
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-18T04:17:51Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java
public static class AlertGroupResourceList implements ResourceAcquisitionAndPermissionCheck<Integer> { private final AlertGroupMapper alertGroupMapper; public AlertGroupResourceList(AlertGroupMapper alertGroupMapper) { this.alertGroupMapper = alertGroupMapper; } @Override public List<AuthorizationType> authorizationTypes() { return Collections.singletonList(AuthorizationType.ALERT_GROUP); } @Override public boolean permissionCheck(int userId, String url, Logger logger) { return false; } @Override public Set<Integer> listAuthorizedResource(int userId, Logger logger) { List<AlertGroup> alertGroupList = alertGroupMapper.queryAllGroupList(); return alertGroupList.stream().map(AlertGroup::getId).collect(toSet()); } } /** * Tenant Resource */ @Component
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,410
[Bug] [API] In the workflow definition, the result of the worker list is only default
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In the workflow definition, the result of the worker list is only default ### What you expected to happen In the workflow definition, the result of the worker list is only default ### How to reproduce In the workflow definition, the list of workers appears fine ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12410
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-18T04:17:51Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java
public static class TenantResourceList implements ResourceAcquisitionAndPermissionCheck<Integer> { private final TenantMapper tenantMapper; public TenantResourceList(TenantMapper tenantMapper) { this.tenantMapper = tenantMapper; } @Override public List<AuthorizationType> authorizationTypes() { return Collections.singletonList(AuthorizationType.TENANT); } @Override public boolean permissionCheck(int userId, String url, Logger logger) { return false; } @Override public Set<Integer> listAuthorizedResource(int userId, Logger logger) { if (userId != 0) { return Collections.emptySet(); } List<Tenant> tenantList = tenantMapper.queryAll(); return tenantList.stream().map(Tenant::getId).collect(Collectors.toSet()); } } /** * DataSource Resource */ @Component
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,410
[Bug] [API] In the workflow definition, the result of the worker list is only default
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In the workflow definition, the result of the worker list is only default ### What you expected to happen In the workflow definition, the result of the worker list is only default ### How to reproduce In the workflow definition, the list of workers appears fine ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12410
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-18T04:17:51Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java
public static class DataSourceResourceList implements ResourceAcquisitionAndPermissionCheck<Integer> { private final DataSourceMapper dataSourceMapper; public DataSourceResourceList(DataSourceMapper dataSourceMapper) { this.dataSourceMapper = dataSourceMapper; } @Override public List<AuthorizationType> authorizationTypes() { return Collections.singletonList(AuthorizationType.DATASOURCE); } @Override public boolean permissionCheck(int userId, String url, Logger logger) { return true; } @Override public Set<Integer> listAuthorizedResource(int userId, Logger logger) { return dataSourceMapper.listAuthorizedDataSource(userId, null).stream().map(DataSource::getId) .collect(toSet()); } } /** * AccessToken Resource */ @Component
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,410
[Bug] [API] In the workflow definition, the result of the worker list is only default
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In the workflow definition, the result of the worker list is only default ### What you expected to happen In the workflow definition, the result of the worker list is only default ### How to reproduce In the workflow definition, the list of workers appears fine ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12410
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-18T04:17:51Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java
public static class AccessTokenList implements ResourceAcquisitionAndPermissionCheck<Integer> { private final AccessTokenMapper accessTokenMapper; public AccessTokenList(AccessTokenMapper accessTokenMapper) { this.accessTokenMapper = accessTokenMapper; } @Override public List<AuthorizationType> authorizationTypes() { return Collections.singletonList(AuthorizationType.ACCESS_TOKEN); } @Override public boolean permissionCheck(int userId, String url, Logger logger) { return false; } @Override public Set<Integer> listAuthorizedResource(int userId, Logger logger) { return accessTokenMapper.listAuthorizedAccessToken(userId, null).stream().map(AccessToken::getId) .collect(toSet()); } } interface ResourceAcquisitionAndPermissionCheck<T> {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,410
[Bug] [API] In the workflow definition, the result of the worker list is only default
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In the workflow definition, the result of the worker list is only default ### What you expected to happen In the workflow definition, the result of the worker list is only default ### How to reproduce In the workflow definition, the list of workers appears fine ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12410
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-18T04:17:51Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java
/** * authorization types * @return */ List<AuthorizationType> authorizationTypes(); /** * get all resources under the user (no admin) * * @param userId * @return */ Set<T> listAuthorizedResource(int userId, Logger logger); /** * permission check * @param userId * @return */ boolean permissionCheck(int userId, String permissionKey, Logger logger); } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,410
[Bug] [API] In the workflow definition, the result of the worker list is only default
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In the workflow definition, the result of the worker list is only default ### What you expected to happen In the workflow definition, the result of the worker list is only default ### How to reproduce In the workflow definition, the list of workers appears fine ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12410
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-18T04:17:51Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/K8SNamespaceServiceImpl.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.dolphinscheduler.api.service.impl; import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.k8s.K8sClientService; import org.apache.dolphinscheduler.api.service.K8sNamespaceService; import org.apache.dolphinscheduler.api.utils.PageInfo; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.Constants;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,410
[Bug] [API] In the workflow definition, the result of the worker list is only default
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In the workflow definition, the result of the worker list is only default ### What you expected to happen In the workflow definition, the result of the worker list is only default ### How to reproduce In the workflow definition, the list of workers appears fine ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12410
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-18T04:17:51Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/K8SNamespaceServiceImpl.java
import org.apache.dolphinscheduler.common.utils.CodeGenerateUtils; import org.apache.dolphinscheduler.dao.entity.Cluster; import org.apache.dolphinscheduler.dao.entity.K8sNamespace; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.mapper.ClusterMapper; import org.apache.dolphinscheduler.dao.mapper.K8sNamespaceMapper; import org.apache.dolphinscheduler.remote.exceptions.RemotingException; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; /** * k8s namespace service impl */ @Service public class K8SNamespaceServiceImpl extends BaseServiceImpl implements K8sNamespaceService { private static final Logger logger = LoggerFactory.getLogger(K8SNamespaceServiceImpl.class); private static String resourceYaml = "apiVersion: v1\n"
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,410
[Bug] [API] In the workflow definition, the result of the worker list is only default
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In the workflow definition, the result of the worker list is only default ### What you expected to happen In the workflow definition, the result of the worker list is only default ### How to reproduce In the workflow definition, the list of workers appears fine ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12410
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-18T04:17:51Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/K8SNamespaceServiceImpl.java
+ "kind: ResourceQuota\n" + "metadata:\n" + " name: ${name}\n" + " namespace: ${namespace}\n" + "spec:\n" + " hard:\n" + " ${limitCpu}\n" + " ${limitMemory}\n"; @Autowired private K8sNamespaceMapper k8sNamespaceMapper; @Autowired private K8sClientService k8sClientService; @Autowired private ClusterMapper clusterMapper; /** * query namespace list paging * * @param loginUser login user * @param pageNo page number * @param searchVal search value * @param pageSize page size * @return k8s namespace list */ @Override public Result queryListPaging(User loginUser, String searchVal, Integer pageNo, Integer pageSize) { Result result = new Result(); if (!isAdmin(loginUser)) { logger.warn("Only admin can query namespace list, current login user name:{}.", loginUser.getUserName()); putMsg(result, Status.USER_NO_OPERATION_PERM); return result;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,410
[Bug] [API] In the workflow definition, the result of the worker list is only default
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In the workflow definition, the result of the worker list is only default ### What you expected to happen In the workflow definition, the result of the worker list is only default ### How to reproduce In the workflow definition, the list of workers appears fine ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12410
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-18T04:17:51Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/K8SNamespaceServiceImpl.java
} Page<K8sNamespace> page = new Page<>(pageNo, pageSize); IPage<K8sNamespace> k8sNamespaceList = k8sNamespaceMapper.queryK8sNamespacePaging(page, searchVal); Integer count = (int) k8sNamespaceList.getTotal(); PageInfo<K8sNamespace> pageInfo = new PageInfo<>(pageNo, pageSize); pageInfo.setTotal(count); pageInfo.setTotalList(k8sNamespaceList.getRecords()); result.setData(pageInfo); putMsg(result, Status.SUCCESS); return result; } /** * create namespace,if not exist on k8s,will create,if exist only register in db * * @param loginUser login user * @param namespace namespace * @param clusterCode k8s not null * @param limitsCpu limits cpu, can null means not limit * @param limitsMemory limits memory, can null means not limit * @return */ @Override public Map<String, Object> createK8sNamespace(User loginUser, String namespace, Long clusterCode, Double limitsCpu, Integer limitsMemory) { Map<String, Object> result = new HashMap<>(); if (isNotAdmin(loginUser, result)) { logger.warn("Only admin can create K8s namespace, current login user name:{}.", loginUser.getUserName()); return result; } if (StringUtils.isEmpty(namespace)) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,410
[Bug] [API] In the workflow definition, the result of the worker list is only default
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In the workflow definition, the result of the worker list is only default ### What you expected to happen In the workflow definition, the result of the worker list is only default ### How to reproduce In the workflow definition, the list of workers appears fine ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12410
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-18T04:17:51Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/K8SNamespaceServiceImpl.java
logger.warn("Parameter namespace is empty."); putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, Constants.NAMESPACE); return result; } if (clusterCode == null) { logger.warn("Parameter clusterCode is null."); putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, Constants.CLUSTER); return result; } if (limitsCpu != null && limitsCpu < 0.0) { logger.warn("Parameter limitsCpu is invalid."); putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, Constants.LIMITS_CPU); return result; } if (limitsMemory != null && limitsMemory < 0) { logger.warn("Parameter limitsMemory is invalid."); putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, Constants.LIMITS_MEMORY); return result; } if (checkNamespaceExistInDb(namespace, clusterCode)) { logger.warn("K8S namespace already exists."); putMsg(result, Status.K8S_NAMESPACE_EXIST, namespace, clusterCode); return result; } Cluster cluster = clusterMapper.queryByClusterCode(clusterCode); if (cluster == null) { logger.error("Cluster does not exist, clusterCode:{}", clusterCode); putMsg(result, Status.CLUSTER_NOT_EXISTS, namespace, clusterCode); return result; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,410
[Bug] [API] In the workflow definition, the result of the worker list is only default
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In the workflow definition, the result of the worker list is only default ### What you expected to happen In the workflow definition, the result of the worker list is only default ### How to reproduce In the workflow definition, the list of workers appears fine ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12410
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-18T04:17:51Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/K8SNamespaceServiceImpl.java
long code = 0L; try { code = CodeGenerateUtils.getInstance().genCode(); cluster.setCode(code); } catch (CodeGenerateUtils.CodeGenerateException e) { logger.error("Generate cluster code error.", e); } if (code == 0L) { putMsg(result, Status.INTERNAL_SERVER_ERROR_ARGS, "Error generating cluster code"); return result; } K8sNamespace k8sNamespaceObj = new K8sNamespace(); Date now = new Date(); k8sNamespaceObj.setCode(code); k8sNamespaceObj.setNamespace(namespace); k8sNamespaceObj.setClusterCode(clusterCode); k8sNamespaceObj.setUserId(loginUser.getId()); k8sNamespaceObj.setLimitsCpu(limitsCpu); k8sNamespaceObj.setLimitsMemory(limitsMemory); k8sNamespaceObj.setPodReplicas(0); k8sNamespaceObj.setPodRequestCpu(0.0); k8sNamespaceObj.setPodRequestMemory(0); k8sNamespaceObj.setCreateTime(now); k8sNamespaceObj.setUpdateTime(now); if (!Constants.K8S_LOCAL_TEST_CLUSTER_CODE.equals(k8sNamespaceObj.getClusterCode())) { try { String yamlStr = genDefaultResourceYaml(k8sNamespaceObj); k8sClientService.upsertNamespaceAndResourceToK8s(k8sNamespaceObj, yamlStr); } catch (Exception e) { logger.error("Namespace create to k8s error", e);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,410
[Bug] [API] In the workflow definition, the result of the worker list is only default
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In the workflow definition, the result of the worker list is only default ### What you expected to happen In the workflow definition, the result of the worker list is only default ### How to reproduce In the workflow definition, the list of workers appears fine ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12410
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-18T04:17:51Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/K8SNamespaceServiceImpl.java
putMsg(result, Status.K8S_CLIENT_OPS_ERROR, e.getMessage()); return result; } } k8sNamespaceMapper.insert(k8sNamespaceObj); logger.info("K8s namespace create complete, namespace:{}.", k8sNamespaceObj.getNamespace()); putMsg(result, Status.SUCCESS); return result; } /** * update K8s Namespace tag and resource limit * * @param loginUser login user * @param userName owner * @param limitsCpu max cpu * @param limitsMemory max memory * @return */ @Override public Map<String, Object> updateK8sNamespace(User loginUser, int id, String userName, Double limitsCpu, Integer limitsMemory) { Map<String, Object> result = new HashMap<>(); if (isNotAdmin(loginUser, result)) { logger.warn("Only admin can update K8s namespace, current login user name:{}.", loginUser.getUserName()); return result; } if (limitsCpu != null && limitsCpu < 0.0) { logger.warn("Parameter limitsCpu is invalid."); putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, Constants.LIMITS_CPU); return result;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,410
[Bug] [API] In the workflow definition, the result of the worker list is only default
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In the workflow definition, the result of the worker list is only default ### What you expected to happen In the workflow definition, the result of the worker list is only default ### How to reproduce In the workflow definition, the list of workers appears fine ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12410
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-18T04:17:51Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/K8SNamespaceServiceImpl.java
} if (limitsMemory != null && limitsMemory < 0) { logger.warn("Parameter limitsMemory is invalid."); putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, Constants.LIMITS_MEMORY); return result; } K8sNamespace k8sNamespaceObj = k8sNamespaceMapper.selectById(id); if (k8sNamespaceObj == null) { logger.error("K8s namespace does not exist, namespaceId:{}.", id); putMsg(result, Status.K8S_NAMESPACE_NOT_EXIST, id); return result; } Date now = new Date(); k8sNamespaceObj.setLimitsCpu(limitsCpu); k8sNamespaceObj.setLimitsMemory(limitsMemory); k8sNamespaceObj.setUpdateTime(now); if (!Constants.K8S_LOCAL_TEST_CLUSTER_CODE.equals(k8sNamespaceObj.getClusterCode())) { try { String yamlStr = genDefaultResourceYaml(k8sNamespaceObj); k8sClientService.upsertNamespaceAndResourceToK8s(k8sNamespaceObj, yamlStr); } catch (Exception e) { logger.error("Namespace update to k8s error", e); putMsg(result, Status.K8S_CLIENT_OPS_ERROR, e.getMessage()); return result; } } k8sNamespaceMapper.updateById(k8sNamespaceObj); logger.info("K8s namespace update complete, namespace:{}.", k8sNamespaceObj.getNamespace()); putMsg(result, Status.SUCCESS);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,410
[Bug] [API] In the workflow definition, the result of the worker list is only default
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In the workflow definition, the result of the worker list is only default ### What you expected to happen In the workflow definition, the result of the worker list is only default ### How to reproduce In the workflow definition, the list of workers appears fine ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12410
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-18T04:17:51Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/K8SNamespaceServiceImpl.java
return result; } /** * verify namespace and k8s * * @param namespace namespace * @param clusterCode cluster code * @return true if the k8s and namespace not exists, otherwise return false */ @Override public Result<Object> verifyNamespaceK8s(String namespace, Long clusterCode) { Result<Object> result = new Result<>(); if (StringUtils.isEmpty(namespace)) { logger.warn("Parameter namespace is empty."); putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, Constants.NAMESPACE); return result; } if (clusterCode == null) { logger.warn("Parameter clusterCode is null."); putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, Constants.CLUSTER); return result; } if (checkNamespaceExistInDb(namespace, clusterCode)) { logger.warn("K8S namespace already exists."); putMsg(result, Status.K8S_NAMESPACE_EXIST, namespace, clusterCode); return result; } putMsg(result, Status.SUCCESS); return result; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,410
[Bug] [API] In the workflow definition, the result of the worker list is only default
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In the workflow definition, the result of the worker list is only default ### What you expected to happen In the workflow definition, the result of the worker list is only default ### How to reproduce In the workflow definition, the list of workers appears fine ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12410
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-18T04:17:51Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/K8SNamespaceServiceImpl.java
/** * delete namespace by id * * @param loginUser login user * @param id namespace id * @return */ @Override public Map<String, Object> deleteNamespaceById(User loginUser, int id) { Map<String, Object> result = new HashMap<>(); if (isNotAdmin(loginUser, result)) { logger.warn("Only admin can delete K8s namespace, current login user name:{}.", loginUser.getUserName()); return result; } K8sNamespace k8sNamespaceObj = k8sNamespaceMapper.selectById(id); if (k8sNamespaceObj == null) { logger.error("K8s namespace does not exist, namespaceId:{}.", id); putMsg(result, Status.K8S_NAMESPACE_NOT_EXIST, id); return result; } if (!Constants.K8S_LOCAL_TEST_CLUSTER_CODE.equals(k8sNamespaceObj.getClusterCode())) { try { k8sClientService.deleteNamespaceToK8s(k8sNamespaceObj.getNamespace(), k8sNamespaceObj.getClusterCode()); } catch (RemotingException e) { logger.error("Namespace delete in k8s error, namespaceId:{}.", id, e); putMsg(result, Status.K8S_CLIENT_OPS_ERROR, id); return result; } } k8sNamespaceMapper.deleteById(id);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,410
[Bug] [API] In the workflow definition, the result of the worker list is only default
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In the workflow definition, the result of the worker list is only default ### What you expected to happen In the workflow definition, the result of the worker list is only default ### How to reproduce In the workflow definition, the list of workers appears fine ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12410
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-18T04:17:51Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/K8SNamespaceServiceImpl.java
logger.info("K8s namespace delete complete, namespace:{}.", k8sNamespaceObj.getNamespace()); putMsg(result, Status.SUCCESS); return result; } /** * check namespace name exist * * @param namespace namespace * @return true if the k8s and namespace not exists, otherwise return false */ private boolean checkNamespaceExistInDb(String namespace, Long clusterCode) { return k8sNamespaceMapper.existNamespace(namespace, clusterCode) == Boolean.TRUE; } /** * use cpu memory create yaml * * @param k8sNamespace * @return yaml file */ private String genDefaultResourceYaml(K8sNamespace k8sNamespace) { String name = k8sNamespace.getNamespace(); String namespace = k8sNamespace.getNamespace(); String cpuStr = null; if (k8sNamespace.getLimitsCpu() != null) { cpuStr = k8sNamespace.getLimitsCpu() + ""; } String memoryStr = null; if (k8sNamespace.getLimitsMemory() != null) { memoryStr = k8sNamespace.getLimitsMemory() + "Gi";
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,410
[Bug] [API] In the workflow definition, the result of the worker list is only default
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In the workflow definition, the result of the worker list is only default ### What you expected to happen In the workflow definition, the result of the worker list is only default ### How to reproduce In the workflow definition, the list of workers appears fine ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12410
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-18T04:17:51Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/K8SNamespaceServiceImpl.java
} String result = resourceYaml.replace("${name}", name) .replace("${namespace}", namespace); if (cpuStr == null) { result = result.replace("${limitCpu}", ""); } else { result = result.replace("${limitCpu}", "limits.cpu: '" + cpuStr + "'"); } if (memoryStr == null) { result = result.replace("${limitMemory}", ""); } else { result = result.replace("${limitMemory}", "limits.memory: " + memoryStr); } return result; } /** * query unauthorized namespace * * @param loginUser login user * @param userId user id * @return the namespaces which user have not permission to see */ @Override public Map<String, Object> queryUnauthorizedNamespace(User loginUser, Integer userId) { Map<String, Object> result = new HashMap<>(); if (loginUser.getId() != userId && isNotAdmin(loginUser, result)) { return result; } List<K8sNamespace> namespaceList = k8sNamespaceMapper.selectList(null);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,410
[Bug] [API] In the workflow definition, the result of the worker list is only default
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In the workflow definition, the result of the worker list is only default ### What you expected to happen In the workflow definition, the result of the worker list is only default ### How to reproduce In the workflow definition, the list of workers appears fine ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12410
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-18T04:17:51Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/K8SNamespaceServiceImpl.java
List<K8sNamespace> resultList = new ArrayList<>(); Set<K8sNamespace> namespaceSet; if (namespaceList != null && !namespaceList.isEmpty()) { namespaceSet = new HashSet<>(namespaceList); List<K8sNamespace> authedProjectList = k8sNamespaceMapper.queryAuthedNamespaceListByUserId(userId); resultList = getUnauthorizedNamespaces(namespaceSet, authedProjectList); } result.put(Constants.DATA_LIST, resultList); putMsg(result, Status.SUCCESS); return result; } /** * query authorized namespace * * @param loginUser login user * @param userId user id * @return namespaces which the user have permission to see */ @Override public Map<String, Object> queryAuthorizedNamespace(User loginUser, Integer userId) { Map<String, Object> result = new HashMap<>(); if (loginUser.getId() != userId && isNotAdmin(loginUser, result)) { return result; } List<K8sNamespace> namespaces = k8sNamespaceMapper.queryAuthedNamespaceListByUserId(userId); result.put(Constants.DATA_LIST, namespaces); putMsg(result, Status.SUCCESS); return result; } /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,410
[Bug] [API] In the workflow definition, the result of the worker list is only default
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In the workflow definition, the result of the worker list is only default ### What you expected to happen In the workflow definition, the result of the worker list is only default ### How to reproduce In the workflow definition, the list of workers appears fine ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12410
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-18T04:17:51Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/K8SNamespaceServiceImpl.java
* query namespace can use * * @param loginUser login user * @return namespace list */ @Override public List<K8sNamespace> queryNamespaceAvailable(User loginUser) { List<K8sNamespace> k8sNamespaces; if (isAdmin(loginUser)) { k8sNamespaces = k8sNamespaceMapper.selectList(null); } else { k8sNamespaces = k8sNamespaceMapper.queryNamespaceAvailable(loginUser.getId()); } setClusterName(k8sNamespaces); return k8sNamespaces; } /** * set cluster_name * @param k8sNamespaces source data */ private void setClusterName(List<K8sNamespace> k8sNamespaces) { if (CollectionUtils.isNotEmpty(k8sNamespaces)) { List<Cluster> clusters = clusterMapper.queryAllClusterList(); if (CollectionUtils.isNotEmpty(clusters)) { Map<Long, String> codeNameMap = clusters.stream() .collect(Collectors.toMap(Cluster::getCode, Cluster::getName, (a, b) -> a)); for (K8sNamespace k8sNamespace : k8sNamespaces) { String clusterName = codeNameMap.get(k8sNamespace.getClusterCode()); k8sNamespace.setClusterName(clusterName); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,410
[Bug] [API] In the workflow definition, the result of the worker list is only default
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In the workflow definition, the result of the worker list is only default ### What you expected to happen In the workflow definition, the result of the worker list is only default ### How to reproduce In the workflow definition, the list of workers appears fine ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12410
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-18T04:17:51Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/K8SNamespaceServiceImpl.java
} } } /** * get unauthorized namespace * * @param namespaceSet namespace set * @param authedNamespaceList authed namespace list * @return namespace list that authorization */ private List<K8sNamespace> getUnauthorizedNamespaces(Set<K8sNamespace> namespaceSet, List<K8sNamespace> authedNamespaceList) { List<K8sNamespace> resultList = new ArrayList<>(); for (K8sNamespace k8sNamespace : namespaceSet) { boolean existAuth = false; if (authedNamespaceList != null && !authedNamespaceList.isEmpty()) { for (K8sNamespace k8sNamespaceAuth : authedNamespaceList) { if (k8sNamespace.equals(k8sNamespaceAuth)) { existAuth = true; } } } if (!existAuth) { resultList.add(k8sNamespace); } } return resultList; } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,410
[Bug] [API] In the workflow definition, the result of the worker list is only default
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In the workflow definition, the result of the worker list is only default ### What you expected to happen In the workflow definition, the result of the worker list is only default ### How to reproduce In the workflow definition, the list of workers appears fine ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12410
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-18T04:17:51Z
java
2022-10-21T05:54:28Z
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/K8sNamespaceMapper.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.dolphinscheduler.dao.mapper; import org.apache.dolphinscheduler.dao.entity.K8sNamespace; import org.apache.ibatis.annotations.Param; import java.util.List; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; /** * namespace interface */ public interface K8sNamespaceMapper extends BaseMapper<K8sNamespace> {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,410
[Bug] [API] In the workflow definition, the result of the worker list is only default
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In the workflow definition, the result of the worker list is only default ### What you expected to happen In the workflow definition, the result of the worker list is only default ### How to reproduce In the workflow definition, the list of workers appears fine ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12410
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-18T04:17:51Z
java
2022-10-21T05:54:28Z
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/K8sNamespaceMapper.java
/** * k8s namespace page * * @param page page * @param searchVal searchVal * @return k8s namespace IPage */ IPage<K8sNamespace> queryK8sNamespacePaging(IPage<K8sNamespace> page, @Param("searchVal") String searchVal); /** * check the target namespace exist * * @param namespace namespace * @param clusterCode clusterCode * @return true if exist else return null */ Boolean existNamespace(@Param("namespace") String namespace, @Param("clusterCode") Long clusterCode);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,410
[Bug] [API] In the workflow definition, the result of the worker list is only default
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened In the workflow definition, the result of the worker list is only default ### What you expected to happen In the workflow definition, the result of the worker list is only default ### How to reproduce In the workflow definition, the list of workers appears fine ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12410
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-18T04:17:51Z
java
2022-10-21T05:54:28Z
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/K8sNamespaceMapper.java
/** * query namespace except userId * * @param userId userId * @return namespace list */ List<K8sNamespace> queryNamespaceExceptUserId(@Param("userId") int userId); /** * query authed namespace list by userId * * @param userId userId * @return namespace list */ List<K8sNamespace> queryAuthedNamespaceListByUserId(@Param("userId") int userId); /** * query namespace can use * * @param userId userId * @return namespace list */ List<K8sNamespace> queryNamespaceAvailable(@Param("userId") Integer userId); /** * check the target namespace * * @param namespaceCode namespaceCode * @return true if exist else return null */ K8sNamespace queryByNamespaceCode(@Param("clusterCode") Long namespaceCode); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,377
[Bug] [api-service] Tenant user run Workflow WorkerGroups can't find admin add other Worker Group list
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened version :3.1.0 admin add new Workflow ![image](https://user-images.githubusercontent.com/10162958/195767028-077eacf9-6f67-468e-9d18-7fa77b2edf1f.png) tenant user hadoop run Workflow ![image](https://user-images.githubusercontent.com/10162958/195767111-983adf37-4911-4dba-9bfa-5b1635755099.png) ### What you expected to happen i can Read the The source code find use this api `dolphinscheduler/worker-groups/all` WorkerGroupServiceImpl.queryAllGroup ![image](https://user-images.githubusercontent.com/10162958/195767390-71ab1801-8c56-435f-b61e-e06f792124a7.png) ResourceAcquisitionAndPermissionCheck.userOwnedResourceIdsAcquisition ![image](https://user-images.githubusercontent.com/10162958/195767498-3be2a538-5fb6-43d3-ac83-f29dd60c9fa2.png) if use tenant user only return ` Collections.emptySet();` why ??? i can find subsequent worker-groups add ZOOKEEPER `/dolphinscheduler/nodes/worker/` ![image](https://user-images.githubusercontent.com/10162958/195767943-274ccb03-9a44-499a-ba8c-b21d1dced086.png) ### How to reproduce I used to use version 2.0 Tenant user can find admin add new WorkerGroups How can I discover newly added WorkerGroups ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12377
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-14T05:20:24Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership.
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,377
[Bug] [api-service] Tenant user run Workflow WorkerGroups can't find admin add other Worker Group list
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened version :3.1.0 admin add new Workflow ![image](https://user-images.githubusercontent.com/10162958/195767028-077eacf9-6f67-468e-9d18-7fa77b2edf1f.png) tenant user hadoop run Workflow ![image](https://user-images.githubusercontent.com/10162958/195767111-983adf37-4911-4dba-9bfa-5b1635755099.png) ### What you expected to happen i can Read the The source code find use this api `dolphinscheduler/worker-groups/all` WorkerGroupServiceImpl.queryAllGroup ![image](https://user-images.githubusercontent.com/10162958/195767390-71ab1801-8c56-435f-b61e-e06f792124a7.png) ResourceAcquisitionAndPermissionCheck.userOwnedResourceIdsAcquisition ![image](https://user-images.githubusercontent.com/10162958/195767498-3be2a538-5fb6-43d3-ac83-f29dd60c9fa2.png) if use tenant user only return ` Collections.emptySet();` why ??? i can find subsequent worker-groups add ZOOKEEPER `/dolphinscheduler/nodes/worker/` ![image](https://user-images.githubusercontent.com/10162958/195767943-274ccb03-9a44-499a-ba8c-b21d1dced086.png) ### How to reproduce I used to use version 2.0 Tenant user can find admin add new WorkerGroups How can I discover newly added WorkerGroups ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12377
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-14T05:20:24Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java
* The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.dolphinscheduler.api.permission; import static java.util.stream.Collectors.toSet; import org.apache.dolphinscheduler.common.enums.AuthorizationType; import org.apache.dolphinscheduler.common.enums.UserType; import org.apache.dolphinscheduler.dao.entity.AccessToken; import org.apache.dolphinscheduler.dao.entity.AlertGroup; import org.apache.dolphinscheduler.dao.entity.DataSource; import org.apache.dolphinscheduler.dao.entity.Environment; import org.apache.dolphinscheduler.dao.entity.Project; import org.apache.dolphinscheduler.dao.entity.Queue; import org.apache.dolphinscheduler.dao.entity.Resource; import org.apache.dolphinscheduler.dao.entity.TaskGroup; import org.apache.dolphinscheduler.dao.entity.Tenant; import org.apache.dolphinscheduler.dao.entity.UdfFunc; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.mapper.AccessTokenMapper; import org.apache.dolphinscheduler.dao.mapper.AlertGroupMapper; import org.apache.dolphinscheduler.dao.mapper.AlertPluginInstanceMapper;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,377
[Bug] [api-service] Tenant user run Workflow WorkerGroups can't find admin add other Worker Group list
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened version :3.1.0 admin add new Workflow ![image](https://user-images.githubusercontent.com/10162958/195767028-077eacf9-6f67-468e-9d18-7fa77b2edf1f.png) tenant user hadoop run Workflow ![image](https://user-images.githubusercontent.com/10162958/195767111-983adf37-4911-4dba-9bfa-5b1635755099.png) ### What you expected to happen i can Read the The source code find use this api `dolphinscheduler/worker-groups/all` WorkerGroupServiceImpl.queryAllGroup ![image](https://user-images.githubusercontent.com/10162958/195767390-71ab1801-8c56-435f-b61e-e06f792124a7.png) ResourceAcquisitionAndPermissionCheck.userOwnedResourceIdsAcquisition ![image](https://user-images.githubusercontent.com/10162958/195767498-3be2a538-5fb6-43d3-ac83-f29dd60c9fa2.png) if use tenant user only return ` Collections.emptySet();` why ??? i can find subsequent worker-groups add ZOOKEEPER `/dolphinscheduler/nodes/worker/` ![image](https://user-images.githubusercontent.com/10162958/195767943-274ccb03-9a44-499a-ba8c-b21d1dced086.png) ### How to reproduce I used to use version 2.0 Tenant user can find admin add new WorkerGroups How can I discover newly added WorkerGroups ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12377
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-14T05:20:24Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java
import org.apache.dolphinscheduler.dao.mapper.DataSourceMapper; import org.apache.dolphinscheduler.dao.mapper.EnvironmentMapper; import org.apache.dolphinscheduler.dao.mapper.K8sNamespaceMapper; import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; import org.apache.dolphinscheduler.dao.mapper.QueueMapper; import org.apache.dolphinscheduler.dao.mapper.ResourceMapper; import org.apache.dolphinscheduler.dao.mapper.ResourceUserMapper; import org.apache.dolphinscheduler.dao.mapper.TaskGroupMapper; import org.apache.dolphinscheduler.dao.mapper.TenantMapper; import org.apache.dolphinscheduler.dao.mapper.UdfFuncMapper; import org.apache.dolphinscheduler.dao.mapper.WorkerGroupMapper; import org.apache.dolphinscheduler.service.process.ProcessService; import org.apache.commons.collections.CollectionUtils; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; import org.slf4j.Logger; import org.springframework.beans.BeansException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.stereotype.Component; @Component
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,377
[Bug] [api-service] Tenant user run Workflow WorkerGroups can't find admin add other Worker Group list
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened version :3.1.0 admin add new Workflow ![image](https://user-images.githubusercontent.com/10162958/195767028-077eacf9-6f67-468e-9d18-7fa77b2edf1f.png) tenant user hadoop run Workflow ![image](https://user-images.githubusercontent.com/10162958/195767111-983adf37-4911-4dba-9bfa-5b1635755099.png) ### What you expected to happen i can Read the The source code find use this api `dolphinscheduler/worker-groups/all` WorkerGroupServiceImpl.queryAllGroup ![image](https://user-images.githubusercontent.com/10162958/195767390-71ab1801-8c56-435f-b61e-e06f792124a7.png) ResourceAcquisitionAndPermissionCheck.userOwnedResourceIdsAcquisition ![image](https://user-images.githubusercontent.com/10162958/195767498-3be2a538-5fb6-43d3-ac83-f29dd60c9fa2.png) if use tenant user only return ` Collections.emptySet();` why ??? i can find subsequent worker-groups add ZOOKEEPER `/dolphinscheduler/nodes/worker/` ![image](https://user-images.githubusercontent.com/10162958/195767943-274ccb03-9a44-499a-ba8c-b21d1dced086.png) ### How to reproduce I used to use version 2.0 Tenant user can find admin add new WorkerGroups How can I discover newly added WorkerGroups ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12377
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-14T05:20:24Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java
public class ResourcePermissionCheckServiceImpl implements ResourcePermissionCheckService<Object>, ApplicationContextAware { @Autowired private ProcessService processService; public static final Map<AuthorizationType, ResourceAcquisitionAndPermissionCheck<?>> RESOURCE_LIST_MAP = new ConcurrentHashMap<>(); @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { for (ResourceAcquisitionAndPermissionCheck<?> authorizedResourceList : applicationContext .getBeansOfType(ResourceAcquisitionAndPermissionCheck.class).values()) { List<AuthorizationType> authorizationTypes = authorizedResourceList.authorizationTypes(); authorizationTypes.forEach(auth -> RESOURCE_LIST_MAP.put(auth, authorizedResourceList)); } } @Override public boolean resourcePermissionCheck(Object authorizationType, Object[] needChecks, Integer userId, Logger logger) { if (Objects.nonNull(needChecks) && needChecks.length > 0) { Set<?> originResSet = new HashSet<>(Arrays.asList(needChecks)); Set<?> ownResSets = RESOURCE_LIST_MAP.get(authorizationType).listAuthorizedResource(userId, logger); originResSet.removeAll(ownResSets); if (CollectionUtils.isNotEmpty(originResSet)) logger.warn("User does not have resource permission on associated resources, userId:{}", userId); return CollectionUtils.isEmpty(originResSet);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,377
[Bug] [api-service] Tenant user run Workflow WorkerGroups can't find admin add other Worker Group list
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened version :3.1.0 admin add new Workflow ![image](https://user-images.githubusercontent.com/10162958/195767028-077eacf9-6f67-468e-9d18-7fa77b2edf1f.png) tenant user hadoop run Workflow ![image](https://user-images.githubusercontent.com/10162958/195767111-983adf37-4911-4dba-9bfa-5b1635755099.png) ### What you expected to happen i can Read the The source code find use this api `dolphinscheduler/worker-groups/all` WorkerGroupServiceImpl.queryAllGroup ![image](https://user-images.githubusercontent.com/10162958/195767390-71ab1801-8c56-435f-b61e-e06f792124a7.png) ResourceAcquisitionAndPermissionCheck.userOwnedResourceIdsAcquisition ![image](https://user-images.githubusercontent.com/10162958/195767498-3be2a538-5fb6-43d3-ac83-f29dd60c9fa2.png) if use tenant user only return ` Collections.emptySet();` why ??? i can find subsequent worker-groups add ZOOKEEPER `/dolphinscheduler/nodes/worker/` ![image](https://user-images.githubusercontent.com/10162958/195767943-274ccb03-9a44-499a-ba8c-b21d1dced086.png) ### How to reproduce I used to use version 2.0 Tenant user can find admin add new WorkerGroups How can I discover newly added WorkerGroups ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12377
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-14T05:20:24Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java
} return true; } @Override public boolean operationPermissionCheck(Object authorizationType, Object[] projectIds, Integer userId, String permissionKey, Logger logger) { User user = processService.getUserById(userId); if (user == null) { logger.error("User does not exist, userId:{}.", userId); return false; } if (user.getUserType().equals(UserType.ADMIN_USER)) { return true; } return RESOURCE_LIST_MAP.get(authorizationType).permissionCheck(userId, permissionKey, logger); } @Override public boolean functionDisabled() { return false; } @Override public void postHandle(Object authorizationType, Integer userId, List<Integer> ids, Logger logger) { logger.debug("no post handle"); } @Override public Set<Object> userOwnedResourceIdsAcquisition(Object authorizationType, Integer userId, Logger logger) { User user = processService.getUserById(userId); if (user == null) { logger.error("User does not exist, userId:{}.", userId); return Collections.emptySet();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,377
[Bug] [api-service] Tenant user run Workflow WorkerGroups can't find admin add other Worker Group list
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened version :3.1.0 admin add new Workflow ![image](https://user-images.githubusercontent.com/10162958/195767028-077eacf9-6f67-468e-9d18-7fa77b2edf1f.png) tenant user hadoop run Workflow ![image](https://user-images.githubusercontent.com/10162958/195767111-983adf37-4911-4dba-9bfa-5b1635755099.png) ### What you expected to happen i can Read the The source code find use this api `dolphinscheduler/worker-groups/all` WorkerGroupServiceImpl.queryAllGroup ![image](https://user-images.githubusercontent.com/10162958/195767390-71ab1801-8c56-435f-b61e-e06f792124a7.png) ResourceAcquisitionAndPermissionCheck.userOwnedResourceIdsAcquisition ![image](https://user-images.githubusercontent.com/10162958/195767498-3be2a538-5fb6-43d3-ac83-f29dd60c9fa2.png) if use tenant user only return ` Collections.emptySet();` why ??? i can find subsequent worker-groups add ZOOKEEPER `/dolphinscheduler/nodes/worker/` ![image](https://user-images.githubusercontent.com/10162958/195767943-274ccb03-9a44-499a-ba8c-b21d1dced086.png) ### How to reproduce I used to use version 2.0 Tenant user can find admin add new WorkerGroups How can I discover newly added WorkerGroups ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12377
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-14T05:20:24Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java
} return (Set<Object>) RESOURCE_LIST_MAP.get(authorizationType).listAuthorizedResource( user.getUserType().equals(UserType.ADMIN_USER) ? 0 : userId, logger); } @Component public static class QueueResourcePermissionCheck implements ResourceAcquisitionAndPermissionCheck<Integer> { private final QueueMapper queueMapper; public QueueResourcePermissionCheck(QueueMapper queueMapper) { this.queueMapper = queueMapper; } @Override public List<AuthorizationType> authorizationTypes() { return Collections.singletonList(AuthorizationType.QUEUE); } @Override public boolean permissionCheck(int userId, String permissionKey, Logger logger) { return false; } @Override public Set<Integer> listAuthorizedResource(int userId, Logger logger) { if (userId != 0) { return Collections.emptySet(); } List<Queue> queues = queueMapper.selectList(null); return CollectionUtils.isEmpty(queues) ? Collections.emptySet() : queues.stream().map(Queue::getId).collect(toSet()); } } @Component
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,377
[Bug] [api-service] Tenant user run Workflow WorkerGroups can't find admin add other Worker Group list
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened version :3.1.0 admin add new Workflow ![image](https://user-images.githubusercontent.com/10162958/195767028-077eacf9-6f67-468e-9d18-7fa77b2edf1f.png) tenant user hadoop run Workflow ![image](https://user-images.githubusercontent.com/10162958/195767111-983adf37-4911-4dba-9bfa-5b1635755099.png) ### What you expected to happen i can Read the The source code find use this api `dolphinscheduler/worker-groups/all` WorkerGroupServiceImpl.queryAllGroup ![image](https://user-images.githubusercontent.com/10162958/195767390-71ab1801-8c56-435f-b61e-e06f792124a7.png) ResourceAcquisitionAndPermissionCheck.userOwnedResourceIdsAcquisition ![image](https://user-images.githubusercontent.com/10162958/195767498-3be2a538-5fb6-43d3-ac83-f29dd60c9fa2.png) if use tenant user only return ` Collections.emptySet();` why ??? i can find subsequent worker-groups add ZOOKEEPER `/dolphinscheduler/nodes/worker/` ![image](https://user-images.githubusercontent.com/10162958/195767943-274ccb03-9a44-499a-ba8c-b21d1dced086.png) ### How to reproduce I used to use version 2.0 Tenant user can find admin add new WorkerGroups How can I discover newly added WorkerGroups ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12377
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-14T05:20:24Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java
public static class ProjectsResourcePermissionCheck implements ResourceAcquisitionAndPermissionCheck<Integer> { private final ProjectMapper projectMapper; public ProjectsResourcePermissionCheck(ProjectMapper projectMapper) { this.projectMapper = projectMapper; } @Override public List<AuthorizationType> authorizationTypes() { return Collections.singletonList(AuthorizationType.PROJECTS); } @Override public boolean permissionCheck(int userId, String permissionKey, Logger logger) { return true; } @Override public Set<Integer> listAuthorizedResource(int userId, Logger logger) { return projectMapper.listAuthorizedProjects(userId, null).stream().map(Project::getId).collect(toSet()); } } @Component
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,377
[Bug] [api-service] Tenant user run Workflow WorkerGroups can't find admin add other Worker Group list
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened version :3.1.0 admin add new Workflow ![image](https://user-images.githubusercontent.com/10162958/195767028-077eacf9-6f67-468e-9d18-7fa77b2edf1f.png) tenant user hadoop run Workflow ![image](https://user-images.githubusercontent.com/10162958/195767111-983adf37-4911-4dba-9bfa-5b1635755099.png) ### What you expected to happen i can Read the The source code find use this api `dolphinscheduler/worker-groups/all` WorkerGroupServiceImpl.queryAllGroup ![image](https://user-images.githubusercontent.com/10162958/195767390-71ab1801-8c56-435f-b61e-e06f792124a7.png) ResourceAcquisitionAndPermissionCheck.userOwnedResourceIdsAcquisition ![image](https://user-images.githubusercontent.com/10162958/195767498-3be2a538-5fb6-43d3-ac83-f29dd60c9fa2.png) if use tenant user only return ` Collections.emptySet();` why ??? i can find subsequent worker-groups add ZOOKEEPER `/dolphinscheduler/nodes/worker/` ![image](https://user-images.githubusercontent.com/10162958/195767943-274ccb03-9a44-499a-ba8c-b21d1dced086.png) ### How to reproduce I used to use version 2.0 Tenant user can find admin add new WorkerGroups How can I discover newly added WorkerGroups ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12377
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-14T05:20:24Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java
public static class FilePermissionCheck implements ResourceAcquisitionAndPermissionCheck<Integer> { private final ResourceMapper resourceMapper; private final ResourceUserMapper resourceUserMapper; public FilePermissionCheck(ResourceMapper resourceMapper, ResourceUserMapper resourceUserMapper) { this.resourceMapper = resourceMapper; this.resourceUserMapper = resourceUserMapper; } @Override public List<AuthorizationType> authorizationTypes() { return Arrays.asList(AuthorizationType.RESOURCE_FILE_ID, AuthorizationType.UDF_FILE); } @Override public Set<Integer> listAuthorizedResource(int userId, Logger logger) { List<Resource> relationResources; if (userId == 0) { relationResources = new ArrayList<>(); } else { List<Integer> resIds = resourceUserMapper.queryResourcesIdListByUserIdAndPerm(userId, 0); relationResources = CollectionUtils.isEmpty(resIds) ? new ArrayList<>() : resourceMapper.queryResourceListById(resIds); } List<Resource> ownResourceList = resourceMapper.queryResourceListAuthored(userId, -1); relationResources.addAll(ownResourceList); return ownResourceList.stream().map(Resource::getId).collect(toSet());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,377
[Bug] [api-service] Tenant user run Workflow WorkerGroups can't find admin add other Worker Group list
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened version :3.1.0 admin add new Workflow ![image](https://user-images.githubusercontent.com/10162958/195767028-077eacf9-6f67-468e-9d18-7fa77b2edf1f.png) tenant user hadoop run Workflow ![image](https://user-images.githubusercontent.com/10162958/195767111-983adf37-4911-4dba-9bfa-5b1635755099.png) ### What you expected to happen i can Read the The source code find use this api `dolphinscheduler/worker-groups/all` WorkerGroupServiceImpl.queryAllGroup ![image](https://user-images.githubusercontent.com/10162958/195767390-71ab1801-8c56-435f-b61e-e06f792124a7.png) ResourceAcquisitionAndPermissionCheck.userOwnedResourceIdsAcquisition ![image](https://user-images.githubusercontent.com/10162958/195767498-3be2a538-5fb6-43d3-ac83-f29dd60c9fa2.png) if use tenant user only return ` Collections.emptySet();` why ??? i can find subsequent worker-groups add ZOOKEEPER `/dolphinscheduler/nodes/worker/` ![image](https://user-images.githubusercontent.com/10162958/195767943-274ccb03-9a44-499a-ba8c-b21d1dced086.png) ### How to reproduce I used to use version 2.0 Tenant user can find admin add new WorkerGroups How can I discover newly added WorkerGroups ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12377
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-14T05:20:24Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java
} @Override public boolean permissionCheck(int userId, String permissionKey, Logger logger) { return true; } } @Component public static class UdfFuncPermissionCheck implements ResourceAcquisitionAndPermissionCheck<Integer> { private final UdfFuncMapper udfFuncMapper; public UdfFuncPermissionCheck(UdfFuncMapper udfFuncMapper) { this.udfFuncMapper = udfFuncMapper; } @Override public List<AuthorizationType> authorizationTypes() { return Collections.singletonList(AuthorizationType.UDF); } @Override public Set<Integer> listAuthorizedResource(int userId, Logger logger) { List<UdfFunc> udfFuncList = udfFuncMapper.listAuthorizedUdfByUserId(userId); if (CollectionUtils.isEmpty(udfFuncList)) { return Collections.emptySet(); } return udfFuncList.stream().map(UdfFunc::getId).collect(toSet()); } @Override public boolean permissionCheck(int userId, String permissionKey, Logger logger) { return true; } } @Component
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,377
[Bug] [api-service] Tenant user run Workflow WorkerGroups can't find admin add other Worker Group list
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened version :3.1.0 admin add new Workflow ![image](https://user-images.githubusercontent.com/10162958/195767028-077eacf9-6f67-468e-9d18-7fa77b2edf1f.png) tenant user hadoop run Workflow ![image](https://user-images.githubusercontent.com/10162958/195767111-983adf37-4911-4dba-9bfa-5b1635755099.png) ### What you expected to happen i can Read the The source code find use this api `dolphinscheduler/worker-groups/all` WorkerGroupServiceImpl.queryAllGroup ![image](https://user-images.githubusercontent.com/10162958/195767390-71ab1801-8c56-435f-b61e-e06f792124a7.png) ResourceAcquisitionAndPermissionCheck.userOwnedResourceIdsAcquisition ![image](https://user-images.githubusercontent.com/10162958/195767498-3be2a538-5fb6-43d3-ac83-f29dd60c9fa2.png) if use tenant user only return ` Collections.emptySet();` why ??? i can find subsequent worker-groups add ZOOKEEPER `/dolphinscheduler/nodes/worker/` ![image](https://user-images.githubusercontent.com/10162958/195767943-274ccb03-9a44-499a-ba8c-b21d1dced086.png) ### How to reproduce I used to use version 2.0 Tenant user can find admin add new WorkerGroups How can I discover newly added WorkerGroups ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12377
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-14T05:20:24Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java
public static class TaskGroupPermissionCheck implements ResourceAcquisitionAndPermissionCheck<Integer> { private final TaskGroupMapper taskGroupMapper; public TaskGroupPermissionCheck(TaskGroupMapper taskGroupMapper) { this.taskGroupMapper = taskGroupMapper; } @Override public List<AuthorizationType> authorizationTypes() { return Collections.singletonList(AuthorizationType.TASK_GROUP); } @Override public Set<Integer> listAuthorizedResource(int userId, Logger logger) { List<TaskGroup> taskGroupList = taskGroupMapper.listAuthorizedResource(userId); if (CollectionUtils.isEmpty(taskGroupList)) { return Collections.emptySet(); } return taskGroupList.stream().map(TaskGroup::getId).collect(Collectors.toSet()); } @Override public boolean permissionCheck(int userId, String permissionKey, Logger logger) { return true; } } @Component
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,377
[Bug] [api-service] Tenant user run Workflow WorkerGroups can't find admin add other Worker Group list
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened version :3.1.0 admin add new Workflow ![image](https://user-images.githubusercontent.com/10162958/195767028-077eacf9-6f67-468e-9d18-7fa77b2edf1f.png) tenant user hadoop run Workflow ![image](https://user-images.githubusercontent.com/10162958/195767111-983adf37-4911-4dba-9bfa-5b1635755099.png) ### What you expected to happen i can Read the The source code find use this api `dolphinscheduler/worker-groups/all` WorkerGroupServiceImpl.queryAllGroup ![image](https://user-images.githubusercontent.com/10162958/195767390-71ab1801-8c56-435f-b61e-e06f792124a7.png) ResourceAcquisitionAndPermissionCheck.userOwnedResourceIdsAcquisition ![image](https://user-images.githubusercontent.com/10162958/195767498-3be2a538-5fb6-43d3-ac83-f29dd60c9fa2.png) if use tenant user only return ` Collections.emptySet();` why ??? i can find subsequent worker-groups add ZOOKEEPER `/dolphinscheduler/nodes/worker/` ![image](https://user-images.githubusercontent.com/10162958/195767943-274ccb03-9a44-499a-ba8c-b21d1dced086.png) ### How to reproduce I used to use version 2.0 Tenant user can find admin add new WorkerGroups How can I discover newly added WorkerGroups ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12377
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-14T05:20:24Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java
public static class K8sNamespaceResourceList implements ResourceAcquisitionAndPermissionCheck<Integer> { private final K8sNamespaceMapper k8sNamespaceMapper; public K8sNamespaceResourceList(K8sNamespaceMapper k8sNamespaceMapper) { this.k8sNamespaceMapper = k8sNamespaceMapper; } @Override public List<AuthorizationType> authorizationTypes() { return Collections.singletonList(AuthorizationType.K8S_NAMESPACE); } @Override public boolean permissionCheck(int userId, String url, Logger logger) { return false; } @Override public Set<Integer> listAuthorizedResource(int userId, Logger logger) { return Collections.emptySet(); } } @Component
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,377
[Bug] [api-service] Tenant user run Workflow WorkerGroups can't find admin add other Worker Group list
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened version :3.1.0 admin add new Workflow ![image](https://user-images.githubusercontent.com/10162958/195767028-077eacf9-6f67-468e-9d18-7fa77b2edf1f.png) tenant user hadoop run Workflow ![image](https://user-images.githubusercontent.com/10162958/195767111-983adf37-4911-4dba-9bfa-5b1635755099.png) ### What you expected to happen i can Read the The source code find use this api `dolphinscheduler/worker-groups/all` WorkerGroupServiceImpl.queryAllGroup ![image](https://user-images.githubusercontent.com/10162958/195767390-71ab1801-8c56-435f-b61e-e06f792124a7.png) ResourceAcquisitionAndPermissionCheck.userOwnedResourceIdsAcquisition ![image](https://user-images.githubusercontent.com/10162958/195767498-3be2a538-5fb6-43d3-ac83-f29dd60c9fa2.png) if use tenant user only return ` Collections.emptySet();` why ??? i can find subsequent worker-groups add ZOOKEEPER `/dolphinscheduler/nodes/worker/` ![image](https://user-images.githubusercontent.com/10162958/195767943-274ccb03-9a44-499a-ba8c-b21d1dced086.png) ### How to reproduce I used to use version 2.0 Tenant user can find admin add new WorkerGroups How can I discover newly added WorkerGroups ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12377
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-14T05:20:24Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java
public static class EnvironmentResourceList implements ResourceAcquisitionAndPermissionCheck<Integer> { private final EnvironmentMapper environmentMapper; public EnvironmentResourceList(EnvironmentMapper environmentMapper) { this.environmentMapper = environmentMapper; } @Override public List<AuthorizationType> authorizationTypes() { return Collections.singletonList(AuthorizationType.ENVIRONMENT); } @Override public boolean permissionCheck(int userId, String url, Logger logger) { return true; } @Override public Set<Integer> listAuthorizedResource(int userId, Logger logger) { List<Environment> environments = environmentMapper.queryAllEnvironmentList(); if (CollectionUtils.isEmpty(environments)) { return Collections.emptySet(); } return environments.stream().map(Environment::getId).collect(Collectors.toSet()); } } @Component
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,377
[Bug] [api-service] Tenant user run Workflow WorkerGroups can't find admin add other Worker Group list
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened version :3.1.0 admin add new Workflow ![image](https://user-images.githubusercontent.com/10162958/195767028-077eacf9-6f67-468e-9d18-7fa77b2edf1f.png) tenant user hadoop run Workflow ![image](https://user-images.githubusercontent.com/10162958/195767111-983adf37-4911-4dba-9bfa-5b1635755099.png) ### What you expected to happen i can Read the The source code find use this api `dolphinscheduler/worker-groups/all` WorkerGroupServiceImpl.queryAllGroup ![image](https://user-images.githubusercontent.com/10162958/195767390-71ab1801-8c56-435f-b61e-e06f792124a7.png) ResourceAcquisitionAndPermissionCheck.userOwnedResourceIdsAcquisition ![image](https://user-images.githubusercontent.com/10162958/195767498-3be2a538-5fb6-43d3-ac83-f29dd60c9fa2.png) if use tenant user only return ` Collections.emptySet();` why ??? i can find subsequent worker-groups add ZOOKEEPER `/dolphinscheduler/nodes/worker/` ![image](https://user-images.githubusercontent.com/10162958/195767943-274ccb03-9a44-499a-ba8c-b21d1dced086.png) ### How to reproduce I used to use version 2.0 Tenant user can find admin add new WorkerGroups How can I discover newly added WorkerGroups ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12377
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-14T05:20:24Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java
public static class WorkerGroupResourceList implements ResourceAcquisitionAndPermissionCheck<Integer> { private final WorkerGroupMapper workerGroupMapper; public WorkerGroupResourceList(WorkerGroupMapper workerGroupMapper) { this.workerGroupMapper = workerGroupMapper; } @Override public List<AuthorizationType> authorizationTypes() { return Collections.singletonList(AuthorizationType.WORKER_GROUP); } @Override public boolean permissionCheck(int userId, String url, Logger logger) { return false; } @Override public Set<Integer> listAuthorizedResource(int userId, Logger logger) { return Collections.emptySet(); } } /** * AlertPluginInstance Resource */ @Component
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,377
[Bug] [api-service] Tenant user run Workflow WorkerGroups can't find admin add other Worker Group list
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened version :3.1.0 admin add new Workflow ![image](https://user-images.githubusercontent.com/10162958/195767028-077eacf9-6f67-468e-9d18-7fa77b2edf1f.png) tenant user hadoop run Workflow ![image](https://user-images.githubusercontent.com/10162958/195767111-983adf37-4911-4dba-9bfa-5b1635755099.png) ### What you expected to happen i can Read the The source code find use this api `dolphinscheduler/worker-groups/all` WorkerGroupServiceImpl.queryAllGroup ![image](https://user-images.githubusercontent.com/10162958/195767390-71ab1801-8c56-435f-b61e-e06f792124a7.png) ResourceAcquisitionAndPermissionCheck.userOwnedResourceIdsAcquisition ![image](https://user-images.githubusercontent.com/10162958/195767498-3be2a538-5fb6-43d3-ac83-f29dd60c9fa2.png) if use tenant user only return ` Collections.emptySet();` why ??? i can find subsequent worker-groups add ZOOKEEPER `/dolphinscheduler/nodes/worker/` ![image](https://user-images.githubusercontent.com/10162958/195767943-274ccb03-9a44-499a-ba8c-b21d1dced086.png) ### How to reproduce I used to use version 2.0 Tenant user can find admin add new WorkerGroups How can I discover newly added WorkerGroups ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12377
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-14T05:20:24Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java
public static class AlertPluginInstanceResourceList implements ResourceAcquisitionAndPermissionCheck<Integer> { private final AlertPluginInstanceMapper alertPluginInstanceMapper; public AlertPluginInstanceResourceList(AlertPluginInstanceMapper alertPluginInstanceMapper) { this.alertPluginInstanceMapper = alertPluginInstanceMapper; } @Override public List<AuthorizationType> authorizationTypes() { return Collections.singletonList(AuthorizationType.ALERT_PLUGIN_INSTANCE); } @Override public boolean permissionCheck(int userId, String url, Logger logger) { return false; } @Override public Set<Integer> listAuthorizedResource(int userId, Logger logger) { return Collections.emptySet(); } } /** * AlertPluginInstance Resource */ @Component
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,377
[Bug] [api-service] Tenant user run Workflow WorkerGroups can't find admin add other Worker Group list
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened version :3.1.0 admin add new Workflow ![image](https://user-images.githubusercontent.com/10162958/195767028-077eacf9-6f67-468e-9d18-7fa77b2edf1f.png) tenant user hadoop run Workflow ![image](https://user-images.githubusercontent.com/10162958/195767111-983adf37-4911-4dba-9bfa-5b1635755099.png) ### What you expected to happen i can Read the The source code find use this api `dolphinscheduler/worker-groups/all` WorkerGroupServiceImpl.queryAllGroup ![image](https://user-images.githubusercontent.com/10162958/195767390-71ab1801-8c56-435f-b61e-e06f792124a7.png) ResourceAcquisitionAndPermissionCheck.userOwnedResourceIdsAcquisition ![image](https://user-images.githubusercontent.com/10162958/195767498-3be2a538-5fb6-43d3-ac83-f29dd60c9fa2.png) if use tenant user only return ` Collections.emptySet();` why ??? i can find subsequent worker-groups add ZOOKEEPER `/dolphinscheduler/nodes/worker/` ![image](https://user-images.githubusercontent.com/10162958/195767943-274ccb03-9a44-499a-ba8c-b21d1dced086.png) ### How to reproduce I used to use version 2.0 Tenant user can find admin add new WorkerGroups How can I discover newly added WorkerGroups ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12377
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-14T05:20:24Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java
public static class AlertGroupResourceList implements ResourceAcquisitionAndPermissionCheck<Integer> { private final AlertGroupMapper alertGroupMapper; public AlertGroupResourceList(AlertGroupMapper alertGroupMapper) { this.alertGroupMapper = alertGroupMapper; } @Override public List<AuthorizationType> authorizationTypes() { return Collections.singletonList(AuthorizationType.ALERT_GROUP); } @Override public boolean permissionCheck(int userId, String url, Logger logger) { return false; } @Override public Set<Integer> listAuthorizedResource(int userId, Logger logger) { List<AlertGroup> alertGroupList = alertGroupMapper.queryAllGroupList(); return alertGroupList.stream().map(AlertGroup::getId).collect(toSet()); } } /** * Tenant Resource */ @Component
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,377
[Bug] [api-service] Tenant user run Workflow WorkerGroups can't find admin add other Worker Group list
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened version :3.1.0 admin add new Workflow ![image](https://user-images.githubusercontent.com/10162958/195767028-077eacf9-6f67-468e-9d18-7fa77b2edf1f.png) tenant user hadoop run Workflow ![image](https://user-images.githubusercontent.com/10162958/195767111-983adf37-4911-4dba-9bfa-5b1635755099.png) ### What you expected to happen i can Read the The source code find use this api `dolphinscheduler/worker-groups/all` WorkerGroupServiceImpl.queryAllGroup ![image](https://user-images.githubusercontent.com/10162958/195767390-71ab1801-8c56-435f-b61e-e06f792124a7.png) ResourceAcquisitionAndPermissionCheck.userOwnedResourceIdsAcquisition ![image](https://user-images.githubusercontent.com/10162958/195767498-3be2a538-5fb6-43d3-ac83-f29dd60c9fa2.png) if use tenant user only return ` Collections.emptySet();` why ??? i can find subsequent worker-groups add ZOOKEEPER `/dolphinscheduler/nodes/worker/` ![image](https://user-images.githubusercontent.com/10162958/195767943-274ccb03-9a44-499a-ba8c-b21d1dced086.png) ### How to reproduce I used to use version 2.0 Tenant user can find admin add new WorkerGroups How can I discover newly added WorkerGroups ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12377
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-14T05:20:24Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java
public static class TenantResourceList implements ResourceAcquisitionAndPermissionCheck<Integer> { private final TenantMapper tenantMapper; public TenantResourceList(TenantMapper tenantMapper) { this.tenantMapper = tenantMapper; } @Override public List<AuthorizationType> authorizationTypes() { return Collections.singletonList(AuthorizationType.TENANT); } @Override public boolean permissionCheck(int userId, String url, Logger logger) { return false; } @Override public Set<Integer> listAuthorizedResource(int userId, Logger logger) { if (userId != 0) { return Collections.emptySet(); } List<Tenant> tenantList = tenantMapper.queryAll(); return tenantList.stream().map(Tenant::getId).collect(Collectors.toSet()); } } /** * DataSource Resource */ @Component
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,377
[Bug] [api-service] Tenant user run Workflow WorkerGroups can't find admin add other Worker Group list
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened version :3.1.0 admin add new Workflow ![image](https://user-images.githubusercontent.com/10162958/195767028-077eacf9-6f67-468e-9d18-7fa77b2edf1f.png) tenant user hadoop run Workflow ![image](https://user-images.githubusercontent.com/10162958/195767111-983adf37-4911-4dba-9bfa-5b1635755099.png) ### What you expected to happen i can Read the The source code find use this api `dolphinscheduler/worker-groups/all` WorkerGroupServiceImpl.queryAllGroup ![image](https://user-images.githubusercontent.com/10162958/195767390-71ab1801-8c56-435f-b61e-e06f792124a7.png) ResourceAcquisitionAndPermissionCheck.userOwnedResourceIdsAcquisition ![image](https://user-images.githubusercontent.com/10162958/195767498-3be2a538-5fb6-43d3-ac83-f29dd60c9fa2.png) if use tenant user only return ` Collections.emptySet();` why ??? i can find subsequent worker-groups add ZOOKEEPER `/dolphinscheduler/nodes/worker/` ![image](https://user-images.githubusercontent.com/10162958/195767943-274ccb03-9a44-499a-ba8c-b21d1dced086.png) ### How to reproduce I used to use version 2.0 Tenant user can find admin add new WorkerGroups How can I discover newly added WorkerGroups ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12377
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-14T05:20:24Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java
public static class DataSourceResourceList implements ResourceAcquisitionAndPermissionCheck<Integer> { private final DataSourceMapper dataSourceMapper; public DataSourceResourceList(DataSourceMapper dataSourceMapper) { this.dataSourceMapper = dataSourceMapper; } @Override public List<AuthorizationType> authorizationTypes() { return Collections.singletonList(AuthorizationType.DATASOURCE); } @Override public boolean permissionCheck(int userId, String url, Logger logger) { return true; } @Override public Set<Integer> listAuthorizedResource(int userId, Logger logger) { return dataSourceMapper.listAuthorizedDataSource(userId, null).stream().map(DataSource::getId) .collect(toSet()); } } /** * AccessToken Resource */ @Component
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,377
[Bug] [api-service] Tenant user run Workflow WorkerGroups can't find admin add other Worker Group list
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened version :3.1.0 admin add new Workflow ![image](https://user-images.githubusercontent.com/10162958/195767028-077eacf9-6f67-468e-9d18-7fa77b2edf1f.png) tenant user hadoop run Workflow ![image](https://user-images.githubusercontent.com/10162958/195767111-983adf37-4911-4dba-9bfa-5b1635755099.png) ### What you expected to happen i can Read the The source code find use this api `dolphinscheduler/worker-groups/all` WorkerGroupServiceImpl.queryAllGroup ![image](https://user-images.githubusercontent.com/10162958/195767390-71ab1801-8c56-435f-b61e-e06f792124a7.png) ResourceAcquisitionAndPermissionCheck.userOwnedResourceIdsAcquisition ![image](https://user-images.githubusercontent.com/10162958/195767498-3be2a538-5fb6-43d3-ac83-f29dd60c9fa2.png) if use tenant user only return ` Collections.emptySet();` why ??? i can find subsequent worker-groups add ZOOKEEPER `/dolphinscheduler/nodes/worker/` ![image](https://user-images.githubusercontent.com/10162958/195767943-274ccb03-9a44-499a-ba8c-b21d1dced086.png) ### How to reproduce I used to use version 2.0 Tenant user can find admin add new WorkerGroups How can I discover newly added WorkerGroups ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12377
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-14T05:20:24Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java
public static class AccessTokenList implements ResourceAcquisitionAndPermissionCheck<Integer> { private final AccessTokenMapper accessTokenMapper; public AccessTokenList(AccessTokenMapper accessTokenMapper) { this.accessTokenMapper = accessTokenMapper; } @Override public List<AuthorizationType> authorizationTypes() { return Collections.singletonList(AuthorizationType.ACCESS_TOKEN); } @Override public boolean permissionCheck(int userId, String url, Logger logger) { return false; } @Override public Set<Integer> listAuthorizedResource(int userId, Logger logger) { return accessTokenMapper.listAuthorizedAccessToken(userId, null).stream().map(AccessToken::getId) .collect(toSet()); } } interface ResourceAcquisitionAndPermissionCheck<T> {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,377
[Bug] [api-service] Tenant user run Workflow WorkerGroups can't find admin add other Worker Group list
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened version :3.1.0 admin add new Workflow ![image](https://user-images.githubusercontent.com/10162958/195767028-077eacf9-6f67-468e-9d18-7fa77b2edf1f.png) tenant user hadoop run Workflow ![image](https://user-images.githubusercontent.com/10162958/195767111-983adf37-4911-4dba-9bfa-5b1635755099.png) ### What you expected to happen i can Read the The source code find use this api `dolphinscheduler/worker-groups/all` WorkerGroupServiceImpl.queryAllGroup ![image](https://user-images.githubusercontent.com/10162958/195767390-71ab1801-8c56-435f-b61e-e06f792124a7.png) ResourceAcquisitionAndPermissionCheck.userOwnedResourceIdsAcquisition ![image](https://user-images.githubusercontent.com/10162958/195767498-3be2a538-5fb6-43d3-ac83-f29dd60c9fa2.png) if use tenant user only return ` Collections.emptySet();` why ??? i can find subsequent worker-groups add ZOOKEEPER `/dolphinscheduler/nodes/worker/` ![image](https://user-images.githubusercontent.com/10162958/195767943-274ccb03-9a44-499a-ba8c-b21d1dced086.png) ### How to reproduce I used to use version 2.0 Tenant user can find admin add new WorkerGroups How can I discover newly added WorkerGroups ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12377
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-14T05:20:24Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java
/** * authorization types * @return */ List<AuthorizationType> authorizationTypes(); /** * get all resources under the user (no admin) * * @param userId * @return */ Set<T> listAuthorizedResource(int userId, Logger logger); /** * permission check * @param userId * @return */ boolean permissionCheck(int userId, String permissionKey, Logger logger); } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,377
[Bug] [api-service] Tenant user run Workflow WorkerGroups can't find admin add other Worker Group list
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened version :3.1.0 admin add new Workflow ![image](https://user-images.githubusercontent.com/10162958/195767028-077eacf9-6f67-468e-9d18-7fa77b2edf1f.png) tenant user hadoop run Workflow ![image](https://user-images.githubusercontent.com/10162958/195767111-983adf37-4911-4dba-9bfa-5b1635755099.png) ### What you expected to happen i can Read the The source code find use this api `dolphinscheduler/worker-groups/all` WorkerGroupServiceImpl.queryAllGroup ![image](https://user-images.githubusercontent.com/10162958/195767390-71ab1801-8c56-435f-b61e-e06f792124a7.png) ResourceAcquisitionAndPermissionCheck.userOwnedResourceIdsAcquisition ![image](https://user-images.githubusercontent.com/10162958/195767498-3be2a538-5fb6-43d3-ac83-f29dd60c9fa2.png) if use tenant user only return ` Collections.emptySet();` why ??? i can find subsequent worker-groups add ZOOKEEPER `/dolphinscheduler/nodes/worker/` ![image](https://user-images.githubusercontent.com/10162958/195767943-274ccb03-9a44-499a-ba8c-b21d1dced086.png) ### How to reproduce I used to use version 2.0 Tenant user can find admin add new WorkerGroups How can I discover newly added WorkerGroups ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12377
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-14T05:20:24Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/K8SNamespaceServiceImpl.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.dolphinscheduler.api.service.impl; import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.k8s.K8sClientService; import org.apache.dolphinscheduler.api.service.K8sNamespaceService; import org.apache.dolphinscheduler.api.utils.PageInfo; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.Constants;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,377
[Bug] [api-service] Tenant user run Workflow WorkerGroups can't find admin add other Worker Group list
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened version :3.1.0 admin add new Workflow ![image](https://user-images.githubusercontent.com/10162958/195767028-077eacf9-6f67-468e-9d18-7fa77b2edf1f.png) tenant user hadoop run Workflow ![image](https://user-images.githubusercontent.com/10162958/195767111-983adf37-4911-4dba-9bfa-5b1635755099.png) ### What you expected to happen i can Read the The source code find use this api `dolphinscheduler/worker-groups/all` WorkerGroupServiceImpl.queryAllGroup ![image](https://user-images.githubusercontent.com/10162958/195767390-71ab1801-8c56-435f-b61e-e06f792124a7.png) ResourceAcquisitionAndPermissionCheck.userOwnedResourceIdsAcquisition ![image](https://user-images.githubusercontent.com/10162958/195767498-3be2a538-5fb6-43d3-ac83-f29dd60c9fa2.png) if use tenant user only return ` Collections.emptySet();` why ??? i can find subsequent worker-groups add ZOOKEEPER `/dolphinscheduler/nodes/worker/` ![image](https://user-images.githubusercontent.com/10162958/195767943-274ccb03-9a44-499a-ba8c-b21d1dced086.png) ### How to reproduce I used to use version 2.0 Tenant user can find admin add new WorkerGroups How can I discover newly added WorkerGroups ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12377
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-14T05:20:24Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/K8SNamespaceServiceImpl.java
import org.apache.dolphinscheduler.common.utils.CodeGenerateUtils; import org.apache.dolphinscheduler.dao.entity.Cluster; import org.apache.dolphinscheduler.dao.entity.K8sNamespace; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.mapper.ClusterMapper; import org.apache.dolphinscheduler.dao.mapper.K8sNamespaceMapper; import org.apache.dolphinscheduler.remote.exceptions.RemotingException; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; /** * k8s namespace service impl */ @Service public class K8SNamespaceServiceImpl extends BaseServiceImpl implements K8sNamespaceService { private static final Logger logger = LoggerFactory.getLogger(K8SNamespaceServiceImpl.class); private static String resourceYaml = "apiVersion: v1\n"
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,377
[Bug] [api-service] Tenant user run Workflow WorkerGroups can't find admin add other Worker Group list
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened version :3.1.0 admin add new Workflow ![image](https://user-images.githubusercontent.com/10162958/195767028-077eacf9-6f67-468e-9d18-7fa77b2edf1f.png) tenant user hadoop run Workflow ![image](https://user-images.githubusercontent.com/10162958/195767111-983adf37-4911-4dba-9bfa-5b1635755099.png) ### What you expected to happen i can Read the The source code find use this api `dolphinscheduler/worker-groups/all` WorkerGroupServiceImpl.queryAllGroup ![image](https://user-images.githubusercontent.com/10162958/195767390-71ab1801-8c56-435f-b61e-e06f792124a7.png) ResourceAcquisitionAndPermissionCheck.userOwnedResourceIdsAcquisition ![image](https://user-images.githubusercontent.com/10162958/195767498-3be2a538-5fb6-43d3-ac83-f29dd60c9fa2.png) if use tenant user only return ` Collections.emptySet();` why ??? i can find subsequent worker-groups add ZOOKEEPER `/dolphinscheduler/nodes/worker/` ![image](https://user-images.githubusercontent.com/10162958/195767943-274ccb03-9a44-499a-ba8c-b21d1dced086.png) ### How to reproduce I used to use version 2.0 Tenant user can find admin add new WorkerGroups How can I discover newly added WorkerGroups ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12377
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-14T05:20:24Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/K8SNamespaceServiceImpl.java
+ "kind: ResourceQuota\n" + "metadata:\n" + " name: ${name}\n" + " namespace: ${namespace}\n" + "spec:\n" + " hard:\n" + " ${limitCpu}\n" + " ${limitMemory}\n"; @Autowired private K8sNamespaceMapper k8sNamespaceMapper; @Autowired private K8sClientService k8sClientService; @Autowired private ClusterMapper clusterMapper; /** * query namespace list paging * * @param loginUser login user * @param pageNo page number * @param searchVal search value * @param pageSize page size * @return k8s namespace list */ @Override public Result queryListPaging(User loginUser, String searchVal, Integer pageNo, Integer pageSize) { Result result = new Result(); if (!isAdmin(loginUser)) { logger.warn("Only admin can query namespace list, current login user name:{}.", loginUser.getUserName()); putMsg(result, Status.USER_NO_OPERATION_PERM); return result;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,377
[Bug] [api-service] Tenant user run Workflow WorkerGroups can't find admin add other Worker Group list
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened version :3.1.0 admin add new Workflow ![image](https://user-images.githubusercontent.com/10162958/195767028-077eacf9-6f67-468e-9d18-7fa77b2edf1f.png) tenant user hadoop run Workflow ![image](https://user-images.githubusercontent.com/10162958/195767111-983adf37-4911-4dba-9bfa-5b1635755099.png) ### What you expected to happen i can Read the The source code find use this api `dolphinscheduler/worker-groups/all` WorkerGroupServiceImpl.queryAllGroup ![image](https://user-images.githubusercontent.com/10162958/195767390-71ab1801-8c56-435f-b61e-e06f792124a7.png) ResourceAcquisitionAndPermissionCheck.userOwnedResourceIdsAcquisition ![image](https://user-images.githubusercontent.com/10162958/195767498-3be2a538-5fb6-43d3-ac83-f29dd60c9fa2.png) if use tenant user only return ` Collections.emptySet();` why ??? i can find subsequent worker-groups add ZOOKEEPER `/dolphinscheduler/nodes/worker/` ![image](https://user-images.githubusercontent.com/10162958/195767943-274ccb03-9a44-499a-ba8c-b21d1dced086.png) ### How to reproduce I used to use version 2.0 Tenant user can find admin add new WorkerGroups How can I discover newly added WorkerGroups ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12377
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-14T05:20:24Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/K8SNamespaceServiceImpl.java
} Page<K8sNamespace> page = new Page<>(pageNo, pageSize); IPage<K8sNamespace> k8sNamespaceList = k8sNamespaceMapper.queryK8sNamespacePaging(page, searchVal); Integer count = (int) k8sNamespaceList.getTotal(); PageInfo<K8sNamespace> pageInfo = new PageInfo<>(pageNo, pageSize); pageInfo.setTotal(count); pageInfo.setTotalList(k8sNamespaceList.getRecords()); result.setData(pageInfo); putMsg(result, Status.SUCCESS); return result; } /** * create namespace,if not exist on k8s,will create,if exist only register in db * * @param loginUser login user * @param namespace namespace * @param clusterCode k8s not null * @param limitsCpu limits cpu, can null means not limit * @param limitsMemory limits memory, can null means not limit * @return */ @Override public Map<String, Object> createK8sNamespace(User loginUser, String namespace, Long clusterCode, Double limitsCpu, Integer limitsMemory) { Map<String, Object> result = new HashMap<>(); if (isNotAdmin(loginUser, result)) { logger.warn("Only admin can create K8s namespace, current login user name:{}.", loginUser.getUserName()); return result; } if (StringUtils.isEmpty(namespace)) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,377
[Bug] [api-service] Tenant user run Workflow WorkerGroups can't find admin add other Worker Group list
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened version :3.1.0 admin add new Workflow ![image](https://user-images.githubusercontent.com/10162958/195767028-077eacf9-6f67-468e-9d18-7fa77b2edf1f.png) tenant user hadoop run Workflow ![image](https://user-images.githubusercontent.com/10162958/195767111-983adf37-4911-4dba-9bfa-5b1635755099.png) ### What you expected to happen i can Read the The source code find use this api `dolphinscheduler/worker-groups/all` WorkerGroupServiceImpl.queryAllGroup ![image](https://user-images.githubusercontent.com/10162958/195767390-71ab1801-8c56-435f-b61e-e06f792124a7.png) ResourceAcquisitionAndPermissionCheck.userOwnedResourceIdsAcquisition ![image](https://user-images.githubusercontent.com/10162958/195767498-3be2a538-5fb6-43d3-ac83-f29dd60c9fa2.png) if use tenant user only return ` Collections.emptySet();` why ??? i can find subsequent worker-groups add ZOOKEEPER `/dolphinscheduler/nodes/worker/` ![image](https://user-images.githubusercontent.com/10162958/195767943-274ccb03-9a44-499a-ba8c-b21d1dced086.png) ### How to reproduce I used to use version 2.0 Tenant user can find admin add new WorkerGroups How can I discover newly added WorkerGroups ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12377
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-14T05:20:24Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/K8SNamespaceServiceImpl.java
logger.warn("Parameter namespace is empty."); putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, Constants.NAMESPACE); return result; } if (clusterCode == null) { logger.warn("Parameter clusterCode is null."); putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, Constants.CLUSTER); return result; } if (limitsCpu != null && limitsCpu < 0.0) { logger.warn("Parameter limitsCpu is invalid."); putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, Constants.LIMITS_CPU); return result; } if (limitsMemory != null && limitsMemory < 0) { logger.warn("Parameter limitsMemory is invalid."); putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, Constants.LIMITS_MEMORY); return result; } if (checkNamespaceExistInDb(namespace, clusterCode)) { logger.warn("K8S namespace already exists."); putMsg(result, Status.K8S_NAMESPACE_EXIST, namespace, clusterCode); return result; } Cluster cluster = clusterMapper.queryByClusterCode(clusterCode); if (cluster == null) { logger.error("Cluster does not exist, clusterCode:{}", clusterCode); putMsg(result, Status.CLUSTER_NOT_EXISTS, namespace, clusterCode); return result; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,377
[Bug] [api-service] Tenant user run Workflow WorkerGroups can't find admin add other Worker Group list
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened version :3.1.0 admin add new Workflow ![image](https://user-images.githubusercontent.com/10162958/195767028-077eacf9-6f67-468e-9d18-7fa77b2edf1f.png) tenant user hadoop run Workflow ![image](https://user-images.githubusercontent.com/10162958/195767111-983adf37-4911-4dba-9bfa-5b1635755099.png) ### What you expected to happen i can Read the The source code find use this api `dolphinscheduler/worker-groups/all` WorkerGroupServiceImpl.queryAllGroup ![image](https://user-images.githubusercontent.com/10162958/195767390-71ab1801-8c56-435f-b61e-e06f792124a7.png) ResourceAcquisitionAndPermissionCheck.userOwnedResourceIdsAcquisition ![image](https://user-images.githubusercontent.com/10162958/195767498-3be2a538-5fb6-43d3-ac83-f29dd60c9fa2.png) if use tenant user only return ` Collections.emptySet();` why ??? i can find subsequent worker-groups add ZOOKEEPER `/dolphinscheduler/nodes/worker/` ![image](https://user-images.githubusercontent.com/10162958/195767943-274ccb03-9a44-499a-ba8c-b21d1dced086.png) ### How to reproduce I used to use version 2.0 Tenant user can find admin add new WorkerGroups How can I discover newly added WorkerGroups ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12377
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-14T05:20:24Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/K8SNamespaceServiceImpl.java
long code = 0L; try { code = CodeGenerateUtils.getInstance().genCode(); cluster.setCode(code); } catch (CodeGenerateUtils.CodeGenerateException e) { logger.error("Generate cluster code error.", e); } if (code == 0L) { putMsg(result, Status.INTERNAL_SERVER_ERROR_ARGS, "Error generating cluster code"); return result; } K8sNamespace k8sNamespaceObj = new K8sNamespace(); Date now = new Date(); k8sNamespaceObj.setCode(code); k8sNamespaceObj.setNamespace(namespace); k8sNamespaceObj.setClusterCode(clusterCode); k8sNamespaceObj.setUserId(loginUser.getId()); k8sNamespaceObj.setLimitsCpu(limitsCpu); k8sNamespaceObj.setLimitsMemory(limitsMemory); k8sNamespaceObj.setPodReplicas(0); k8sNamespaceObj.setPodRequestCpu(0.0); k8sNamespaceObj.setPodRequestMemory(0); k8sNamespaceObj.setCreateTime(now); k8sNamespaceObj.setUpdateTime(now); if (!Constants.K8S_LOCAL_TEST_CLUSTER_CODE.equals(k8sNamespaceObj.getClusterCode())) { try { String yamlStr = genDefaultResourceYaml(k8sNamespaceObj); k8sClientService.upsertNamespaceAndResourceToK8s(k8sNamespaceObj, yamlStr); } catch (Exception e) { logger.error("Namespace create to k8s error", e);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,377
[Bug] [api-service] Tenant user run Workflow WorkerGroups can't find admin add other Worker Group list
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened version :3.1.0 admin add new Workflow ![image](https://user-images.githubusercontent.com/10162958/195767028-077eacf9-6f67-468e-9d18-7fa77b2edf1f.png) tenant user hadoop run Workflow ![image](https://user-images.githubusercontent.com/10162958/195767111-983adf37-4911-4dba-9bfa-5b1635755099.png) ### What you expected to happen i can Read the The source code find use this api `dolphinscheduler/worker-groups/all` WorkerGroupServiceImpl.queryAllGroup ![image](https://user-images.githubusercontent.com/10162958/195767390-71ab1801-8c56-435f-b61e-e06f792124a7.png) ResourceAcquisitionAndPermissionCheck.userOwnedResourceIdsAcquisition ![image](https://user-images.githubusercontent.com/10162958/195767498-3be2a538-5fb6-43d3-ac83-f29dd60c9fa2.png) if use tenant user only return ` Collections.emptySet();` why ??? i can find subsequent worker-groups add ZOOKEEPER `/dolphinscheduler/nodes/worker/` ![image](https://user-images.githubusercontent.com/10162958/195767943-274ccb03-9a44-499a-ba8c-b21d1dced086.png) ### How to reproduce I used to use version 2.0 Tenant user can find admin add new WorkerGroups How can I discover newly added WorkerGroups ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12377
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-14T05:20:24Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/K8SNamespaceServiceImpl.java
putMsg(result, Status.K8S_CLIENT_OPS_ERROR, e.getMessage()); return result; } } k8sNamespaceMapper.insert(k8sNamespaceObj); logger.info("K8s namespace create complete, namespace:{}.", k8sNamespaceObj.getNamespace()); putMsg(result, Status.SUCCESS); return result; } /** * update K8s Namespace tag and resource limit * * @param loginUser login user * @param userName owner * @param limitsCpu max cpu * @param limitsMemory max memory * @return */ @Override public Map<String, Object> updateK8sNamespace(User loginUser, int id, String userName, Double limitsCpu, Integer limitsMemory) { Map<String, Object> result = new HashMap<>(); if (isNotAdmin(loginUser, result)) { logger.warn("Only admin can update K8s namespace, current login user name:{}.", loginUser.getUserName()); return result; } if (limitsCpu != null && limitsCpu < 0.0) { logger.warn("Parameter limitsCpu is invalid."); putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, Constants.LIMITS_CPU); return result;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,377
[Bug] [api-service] Tenant user run Workflow WorkerGroups can't find admin add other Worker Group list
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened version :3.1.0 admin add new Workflow ![image](https://user-images.githubusercontent.com/10162958/195767028-077eacf9-6f67-468e-9d18-7fa77b2edf1f.png) tenant user hadoop run Workflow ![image](https://user-images.githubusercontent.com/10162958/195767111-983adf37-4911-4dba-9bfa-5b1635755099.png) ### What you expected to happen i can Read the The source code find use this api `dolphinscheduler/worker-groups/all` WorkerGroupServiceImpl.queryAllGroup ![image](https://user-images.githubusercontent.com/10162958/195767390-71ab1801-8c56-435f-b61e-e06f792124a7.png) ResourceAcquisitionAndPermissionCheck.userOwnedResourceIdsAcquisition ![image](https://user-images.githubusercontent.com/10162958/195767498-3be2a538-5fb6-43d3-ac83-f29dd60c9fa2.png) if use tenant user only return ` Collections.emptySet();` why ??? i can find subsequent worker-groups add ZOOKEEPER `/dolphinscheduler/nodes/worker/` ![image](https://user-images.githubusercontent.com/10162958/195767943-274ccb03-9a44-499a-ba8c-b21d1dced086.png) ### How to reproduce I used to use version 2.0 Tenant user can find admin add new WorkerGroups How can I discover newly added WorkerGroups ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12377
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-14T05:20:24Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/K8SNamespaceServiceImpl.java
} if (limitsMemory != null && limitsMemory < 0) { logger.warn("Parameter limitsMemory is invalid."); putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, Constants.LIMITS_MEMORY); return result; } K8sNamespace k8sNamespaceObj = k8sNamespaceMapper.selectById(id); if (k8sNamespaceObj == null) { logger.error("K8s namespace does not exist, namespaceId:{}.", id); putMsg(result, Status.K8S_NAMESPACE_NOT_EXIST, id); return result; } Date now = new Date(); k8sNamespaceObj.setLimitsCpu(limitsCpu); k8sNamespaceObj.setLimitsMemory(limitsMemory); k8sNamespaceObj.setUpdateTime(now); if (!Constants.K8S_LOCAL_TEST_CLUSTER_CODE.equals(k8sNamespaceObj.getClusterCode())) { try { String yamlStr = genDefaultResourceYaml(k8sNamespaceObj); k8sClientService.upsertNamespaceAndResourceToK8s(k8sNamespaceObj, yamlStr); } catch (Exception e) { logger.error("Namespace update to k8s error", e); putMsg(result, Status.K8S_CLIENT_OPS_ERROR, e.getMessage()); return result; } } k8sNamespaceMapper.updateById(k8sNamespaceObj); logger.info("K8s namespace update complete, namespace:{}.", k8sNamespaceObj.getNamespace()); putMsg(result, Status.SUCCESS);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,377
[Bug] [api-service] Tenant user run Workflow WorkerGroups can't find admin add other Worker Group list
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened version :3.1.0 admin add new Workflow ![image](https://user-images.githubusercontent.com/10162958/195767028-077eacf9-6f67-468e-9d18-7fa77b2edf1f.png) tenant user hadoop run Workflow ![image](https://user-images.githubusercontent.com/10162958/195767111-983adf37-4911-4dba-9bfa-5b1635755099.png) ### What you expected to happen i can Read the The source code find use this api `dolphinscheduler/worker-groups/all` WorkerGroupServiceImpl.queryAllGroup ![image](https://user-images.githubusercontent.com/10162958/195767390-71ab1801-8c56-435f-b61e-e06f792124a7.png) ResourceAcquisitionAndPermissionCheck.userOwnedResourceIdsAcquisition ![image](https://user-images.githubusercontent.com/10162958/195767498-3be2a538-5fb6-43d3-ac83-f29dd60c9fa2.png) if use tenant user only return ` Collections.emptySet();` why ??? i can find subsequent worker-groups add ZOOKEEPER `/dolphinscheduler/nodes/worker/` ![image](https://user-images.githubusercontent.com/10162958/195767943-274ccb03-9a44-499a-ba8c-b21d1dced086.png) ### How to reproduce I used to use version 2.0 Tenant user can find admin add new WorkerGroups How can I discover newly added WorkerGroups ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12377
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-14T05:20:24Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/K8SNamespaceServiceImpl.java
return result; } /** * verify namespace and k8s * * @param namespace namespace * @param clusterCode cluster code * @return true if the k8s and namespace not exists, otherwise return false */ @Override public Result<Object> verifyNamespaceK8s(String namespace, Long clusterCode) { Result<Object> result = new Result<>(); if (StringUtils.isEmpty(namespace)) { logger.warn("Parameter namespace is empty."); putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, Constants.NAMESPACE); return result; } if (clusterCode == null) { logger.warn("Parameter clusterCode is null."); putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, Constants.CLUSTER); return result; } if (checkNamespaceExistInDb(namespace, clusterCode)) { logger.warn("K8S namespace already exists."); putMsg(result, Status.K8S_NAMESPACE_EXIST, namespace, clusterCode); return result; } putMsg(result, Status.SUCCESS); return result; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,377
[Bug] [api-service] Tenant user run Workflow WorkerGroups can't find admin add other Worker Group list
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened version :3.1.0 admin add new Workflow ![image](https://user-images.githubusercontent.com/10162958/195767028-077eacf9-6f67-468e-9d18-7fa77b2edf1f.png) tenant user hadoop run Workflow ![image](https://user-images.githubusercontent.com/10162958/195767111-983adf37-4911-4dba-9bfa-5b1635755099.png) ### What you expected to happen i can Read the The source code find use this api `dolphinscheduler/worker-groups/all` WorkerGroupServiceImpl.queryAllGroup ![image](https://user-images.githubusercontent.com/10162958/195767390-71ab1801-8c56-435f-b61e-e06f792124a7.png) ResourceAcquisitionAndPermissionCheck.userOwnedResourceIdsAcquisition ![image](https://user-images.githubusercontent.com/10162958/195767498-3be2a538-5fb6-43d3-ac83-f29dd60c9fa2.png) if use tenant user only return ` Collections.emptySet();` why ??? i can find subsequent worker-groups add ZOOKEEPER `/dolphinscheduler/nodes/worker/` ![image](https://user-images.githubusercontent.com/10162958/195767943-274ccb03-9a44-499a-ba8c-b21d1dced086.png) ### How to reproduce I used to use version 2.0 Tenant user can find admin add new WorkerGroups How can I discover newly added WorkerGroups ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12377
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-14T05:20:24Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/K8SNamespaceServiceImpl.java
/** * delete namespace by id * * @param loginUser login user * @param id namespace id * @return */ @Override public Map<String, Object> deleteNamespaceById(User loginUser, int id) { Map<String, Object> result = new HashMap<>(); if (isNotAdmin(loginUser, result)) { logger.warn("Only admin can delete K8s namespace, current login user name:{}.", loginUser.getUserName()); return result; } K8sNamespace k8sNamespaceObj = k8sNamespaceMapper.selectById(id); if (k8sNamespaceObj == null) { logger.error("K8s namespace does not exist, namespaceId:{}.", id); putMsg(result, Status.K8S_NAMESPACE_NOT_EXIST, id); return result; } if (!Constants.K8S_LOCAL_TEST_CLUSTER_CODE.equals(k8sNamespaceObj.getClusterCode())) { try { k8sClientService.deleteNamespaceToK8s(k8sNamespaceObj.getNamespace(), k8sNamespaceObj.getClusterCode()); } catch (RemotingException e) { logger.error("Namespace delete in k8s error, namespaceId:{}.", id, e); putMsg(result, Status.K8S_CLIENT_OPS_ERROR, id); return result; } } k8sNamespaceMapper.deleteById(id);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,377
[Bug] [api-service] Tenant user run Workflow WorkerGroups can't find admin add other Worker Group list
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened version :3.1.0 admin add new Workflow ![image](https://user-images.githubusercontent.com/10162958/195767028-077eacf9-6f67-468e-9d18-7fa77b2edf1f.png) tenant user hadoop run Workflow ![image](https://user-images.githubusercontent.com/10162958/195767111-983adf37-4911-4dba-9bfa-5b1635755099.png) ### What you expected to happen i can Read the The source code find use this api `dolphinscheduler/worker-groups/all` WorkerGroupServiceImpl.queryAllGroup ![image](https://user-images.githubusercontent.com/10162958/195767390-71ab1801-8c56-435f-b61e-e06f792124a7.png) ResourceAcquisitionAndPermissionCheck.userOwnedResourceIdsAcquisition ![image](https://user-images.githubusercontent.com/10162958/195767498-3be2a538-5fb6-43d3-ac83-f29dd60c9fa2.png) if use tenant user only return ` Collections.emptySet();` why ??? i can find subsequent worker-groups add ZOOKEEPER `/dolphinscheduler/nodes/worker/` ![image](https://user-images.githubusercontent.com/10162958/195767943-274ccb03-9a44-499a-ba8c-b21d1dced086.png) ### How to reproduce I used to use version 2.0 Tenant user can find admin add new WorkerGroups How can I discover newly added WorkerGroups ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12377
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-14T05:20:24Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/K8SNamespaceServiceImpl.java
logger.info("K8s namespace delete complete, namespace:{}.", k8sNamespaceObj.getNamespace()); putMsg(result, Status.SUCCESS); return result; } /** * check namespace name exist * * @param namespace namespace * @return true if the k8s and namespace not exists, otherwise return false */ private boolean checkNamespaceExistInDb(String namespace, Long clusterCode) { return k8sNamespaceMapper.existNamespace(namespace, clusterCode) == Boolean.TRUE; } /** * use cpu memory create yaml * * @param k8sNamespace * @return yaml file */ private String genDefaultResourceYaml(K8sNamespace k8sNamespace) { String name = k8sNamespace.getNamespace(); String namespace = k8sNamespace.getNamespace(); String cpuStr = null; if (k8sNamespace.getLimitsCpu() != null) { cpuStr = k8sNamespace.getLimitsCpu() + ""; } String memoryStr = null; if (k8sNamespace.getLimitsMemory() != null) { memoryStr = k8sNamespace.getLimitsMemory() + "Gi";
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,377
[Bug] [api-service] Tenant user run Workflow WorkerGroups can't find admin add other Worker Group list
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened version :3.1.0 admin add new Workflow ![image](https://user-images.githubusercontent.com/10162958/195767028-077eacf9-6f67-468e-9d18-7fa77b2edf1f.png) tenant user hadoop run Workflow ![image](https://user-images.githubusercontent.com/10162958/195767111-983adf37-4911-4dba-9bfa-5b1635755099.png) ### What you expected to happen i can Read the The source code find use this api `dolphinscheduler/worker-groups/all` WorkerGroupServiceImpl.queryAllGroup ![image](https://user-images.githubusercontent.com/10162958/195767390-71ab1801-8c56-435f-b61e-e06f792124a7.png) ResourceAcquisitionAndPermissionCheck.userOwnedResourceIdsAcquisition ![image](https://user-images.githubusercontent.com/10162958/195767498-3be2a538-5fb6-43d3-ac83-f29dd60c9fa2.png) if use tenant user only return ` Collections.emptySet();` why ??? i can find subsequent worker-groups add ZOOKEEPER `/dolphinscheduler/nodes/worker/` ![image](https://user-images.githubusercontent.com/10162958/195767943-274ccb03-9a44-499a-ba8c-b21d1dced086.png) ### How to reproduce I used to use version 2.0 Tenant user can find admin add new WorkerGroups How can I discover newly added WorkerGroups ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12377
https://github.com/apache/dolphinscheduler/pull/12411
651588c98dbaae2261a2e34044afdbae99d23b60
1436ad65fc1e6be5f049a534251a0a4516100109
2022-10-14T05:20:24Z
java
2022-10-21T05:54:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/K8SNamespaceServiceImpl.java
} String result = resourceYaml.replace("${name}", name) .replace("${namespace}", namespace); if (cpuStr == null) { result = result.replace("${limitCpu}", ""); } else { result = result.replace("${limitCpu}", "limits.cpu: '" + cpuStr + "'"); } if (memoryStr == null) { result = result.replace("${limitMemory}", ""); } else { result = result.replace("${limitMemory}", "limits.memory: " + memoryStr); } return result; } /** * query unauthorized namespace * * @param loginUser login user * @param userId user id * @return the namespaces which user have not permission to see */ @Override public Map<String, Object> queryUnauthorizedNamespace(User loginUser, Integer userId) { Map<String, Object> result = new HashMap<>(); if (loginUser.getId() != userId && isNotAdmin(loginUser, result)) { return result; } List<K8sNamespace> namespaceList = k8sNamespaceMapper.selectList(null);