Skip to content

Commit

Permalink
modify enter
Browse files Browse the repository at this point in the history
  • Loading branch information
zeyu10 committed Oct 24, 2024
1 parent 1e1efaf commit 0ed46a7
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 67 deletions.
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
}
}
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])
}
}

0 comments on commit 0ed46a7

Please sign in to comment.