-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
check dag length when add descriptor (#48)
* check dag length when add descriptor --------- Co-authored-by: techloghub <[email protected]> Co-authored-by: zeyu10 <[email protected]>
- Loading branch information
1 parent
cf32306
commit f8f0490
Showing
11 changed files
with
134 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...service/src/test/groovy/com/weibo/rill/flow/service/facade/DAGDescriptorFacadeTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.weibo.rill.flow.service.facade | ||
|
||
import com.weibo.rill.flow.common.exception.TaskException | ||
import com.weibo.rill.flow.olympicene.storage.constant.StorageErrorCode | ||
import com.weibo.rill.flow.olympicene.storage.exception.StorageException | ||
import com.weibo.rill.flow.service.manager.DescriptorManager | ||
import com.weibo.rill.flow.service.statistic.DAGSubmitChecker | ||
import org.springframework.context.ApplicationEventPublisher | ||
import spock.lang.Specification | ||
|
||
class DAGDescriptorFacadeTest extends Specification { | ||
DAGSubmitChecker dagSubmitChecker = Mock(DAGSubmitChecker) | ||
DescriptorManager descriptorManager = Mock(DescriptorManager) | ||
ApplicationEventPublisher applicationEventPublisher = Mock(ApplicationEventPublisher) | ||
DAGDescriptorFacade facade = new DAGDescriptorFacade( | ||
dagSubmitChecker: dagSubmitChecker, | ||
applicationEventPublisher: applicationEventPublisher, | ||
descriptorManager: descriptorManager | ||
) | ||
|
||
def "test addDescriptor"() { | ||
given: | ||
var descriptor_id = "testBusiness:testFeatureName_c_8921a32f" | ||
applicationEventPublisher.publishEvent(*_) >> null | ||
dagSubmitChecker.checkDAGInfoLengthByBusinessId(*_) >> null | ||
descriptorManager.createDAGDescriptor(*_) >> descriptor_id | ||
expect: | ||
facade.addDescriptor(null, "testBusiness", "testFeatureName", "release", "hello world") == [ret: true, descriptor_id: descriptor_id] | ||
facade.addDescriptor(null, "testBusiness", "testFeatureName", "release", "") == [ret: true, descriptor_id: descriptor_id] | ||
} | ||
|
||
def "test addDescriptor when check error"() { | ||
given: | ||
var descriptor_id = "testBusiness:testFeatureName_c_8921a32f" | ||
applicationEventPublisher.publishEvent(*_) >> null | ||
dagSubmitChecker.checkDAGInfoLengthByBusinessId(*_) >> {throw new StorageException(StorageErrorCode.DAG_LENGTH_LIMITATION.getCode(), "DAG length limitation")} | ||
descriptorManager.createDAGDescriptor(*_) >> descriptor_id | ||
when: | ||
facade.addDescriptor(null, "testBusiness", "testFeatureName", "release", "hello world") | ||
then: | ||
thrown TaskException | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
...service/src/test/groovy/com/weibo/rill/flow/service/statistic/DAGSubmitCheckerTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.weibo.rill.flow.service.statistic | ||
|
||
import com.weibo.rill.flow.olympicene.core.switcher.SwitcherManager | ||
import com.weibo.rill.flow.olympicene.storage.exception.StorageException | ||
import com.weibo.rill.flow.service.dconfs.BizDConfs | ||
import spock.lang.Specification | ||
|
||
class DAGSubmitCheckerTest extends Specification { | ||
SwitcherManager switcherManager = Mock(SwitcherManager) | ||
BizDConfs bizDConfs = Mock(BizDConfs) | ||
DAGSubmitChecker dagSubmitChecker = new DAGSubmitChecker(switcherManagerImpl: switcherManager, bizDConfs: bizDConfs) | ||
|
||
def "test checkDAGInfoLength when switcher is off"() { | ||
given: | ||
switcherManager.getSwitcherState("ENABLE_DAG_INFO_LENGTH_CHECK") >> false | ||
expect: | ||
dagSubmitChecker.checkDAGInfoLength("testBusiness1:testFeatureName1_c_0dc48c1d-32a2", ["hello world".bytes]) | ||
} | ||
|
||
def "test checkDAGInfoLength when switcher is on and be limited"() { | ||
given: | ||
switcherManager.getSwitcherState("ENABLE_DAG_INFO_LENGTH_CHECK") >> true | ||
bizDConfs.getRedisBusinessIdToDAGInfoMaxLength() >> ["testBusiness1": 5] | ||
when: | ||
dagSubmitChecker.checkDAGInfoLength("testBusiness1:testFeatureName1_c_0dc48c1d-32a2", ["hello world".bytes]) | ||
then: | ||
thrown StorageException | ||
} | ||
|
||
def "test checkDAGInfoLength when switcher is on"() { | ||
given: | ||
switcherManager.getSwitcherState("ENABLE_DAG_INFO_LENGTH_CHECK") >> true | ||
bizDConfs.getRedisBusinessIdToDAGInfoMaxLength() >> ["testBusiness1": 5] | ||
expect: | ||
dagSubmitChecker.checkDAGInfoLength("testBusiness1:testFeatureName1_c_0dc48c1d-32a2", null) | ||
dagSubmitChecker.checkDAGInfoLength("testBusiness2:testFeatureName1_c_0dc48c1d-32a2", ["hello world".bytes]) | ||
} | ||
|
||
def "test checkDAGInfoLength when switcher is on and dconfs return null"() { | ||
given: | ||
switcherManager.getSwitcherState("ENABLE_DAG_INFO_LENGTH_CHECK") >> true | ||
bizDConfs.getRedisBusinessIdToDAGInfoMaxLength() >> null | ||
expect: | ||
dagSubmitChecker.checkDAGInfoLength("testBusiness2:testFeatureName1_c_0dc48c1d-32a2", ["hello world".bytes]) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters