-
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.
- Loading branch information
zeyu10
committed
Oct 24, 2024
1 parent
1e1efaf
commit 0ed46a7
Showing
2 changed files
with
67 additions
and
67 deletions.
There are no files selected for viewing
42 changes: 21 additions & 21 deletions
42
...ice/src/test/groovy/com/weibo/rill/flow/service/statistic/DAGResourceStatisticTest.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 |
---|---|---|
@@ -1,21 +1,21 @@ | ||
package com.weibo.rill.flow.service.statistic | ||
|
||
import com.alibaba.fastjson.JSONObject | ||
import spock.lang.Specification | ||
import spock.lang.Unroll | ||
|
||
class DAGResourceStatisticTest extends Specification { | ||
DAGResourceStatistic statistic = new DAGResourceStatistic() | ||
|
||
@Unroll | ||
def "test getRetryIntervalSeconds"() { | ||
when: | ||
JSONObject urlRet1 = new JSONObject(Map.of("data", "message")) | ||
JSONObject urlRet2 = new JSONObject(Map.of("data", Map.of("sys_info", Map.of("retry_interval_seconds", 100)))) | ||
JSONObject urlRet3 = new JSONObject(Map.of("error_detail", Map.of("retry_interval_seconds", 100))) | ||
then: | ||
statistic.getRetryIntervalSeconds(urlRet1) == 0 | ||
statistic.getRetryIntervalSeconds(urlRet2) == 100 | ||
statistic.getRetryIntervalSeconds(urlRet3) == 100 | ||
} | ||
} | ||
package com.weibo.rill.flow.service.statistic | ||
|
||
import com.alibaba.fastjson.JSONObject | ||
import spock.lang.Specification | ||
import spock.lang.Unroll | ||
|
||
class DAGResourceStatisticTest extends Specification { | ||
DAGResourceStatistic statistic = new DAGResourceStatistic() | ||
|
||
@Unroll | ||
def "test getRetryIntervalSeconds"() { | ||
when: | ||
JSONObject urlRet1 = new JSONObject(Map.of("data", "message")) | ||
JSONObject urlRet2 = new JSONObject(Map.of("data", Map.of("sys_info", Map.of("retry_interval_seconds", 100)))) | ||
JSONObject urlRet3 = new JSONObject(Map.of("error_detail", Map.of("retry_interval_seconds", 100))) | ||
then: | ||
statistic.getRetryIntervalSeconds(urlRet1) == 0 | ||
statistic.getRetryIntervalSeconds(urlRet2) == 100 | ||
statistic.getRetryIntervalSeconds(urlRet3) == 100 | ||
} | ||
} |
92 changes: 46 additions & 46 deletions
92
...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 |
---|---|---|
@@ -1,46 +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]) | ||
} | ||
} | ||
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]) | ||
} | ||
} |