Просмотр исходного кода

remove dry run (#19820)

GitOrigin-RevId: b92e08da6654cdd37314f7c52a6946cc7ec8983a
Liangjun Song 2 лет назад
Родитель
Сommit
2133dde8bf

+ 6 - 8
services/clsi/app/js/LockManager.js

@@ -10,7 +10,7 @@ const LOCK_TIMEOUT_MS = RequestParser.MAX_TIMEOUT * 1000 + 120000
 
 const LOCKS = new Map()
 
-function acquire(key, concurrencyLimitDryRun = true) {
+function acquire(key) {
   const currentLock = LOCKS.get(key)
   if (currentLock != null) {
     if (currentLock.isExpired()) {
@@ -21,14 +21,14 @@ function acquire(key, concurrencyLimitDryRun = true) {
     }
   }
 
-  checkConcurrencyLimit(concurrencyLimitDryRun)
+  checkConcurrencyLimit()
 
   const lock = new Lock(key)
   LOCKS.set(key, lock)
   return lock
 }
 
-function checkConcurrencyLimit(dryRun) {
+function checkConcurrencyLimit() {
   Metrics.gauge('concurrent_compile_requests', LOCKS.size)
 
   if (LOCKS.size <= Settings.compileConcurrencyLimit) {
@@ -37,11 +37,9 @@ function checkConcurrencyLimit(dryRun) {
 
   Metrics.inc('exceeded-compilier-concurrency-limit')
 
-  if (!dryRun) {
-    throw new Errors.TooManyCompileRequestsError(
-      'too many concurrent compile requests'
-    )
-  }
+  throw new Errors.TooManyCompileRequestsError(
+    'too many concurrent compile requests'
+  )
 }
 
 class Lock {

+ 2 - 17
services/clsi/test/unit/js/LockManagerTests.js

@@ -75,24 +75,9 @@ describe('LockManager', function () {
   })
 
   describe('concurrency limit', function () {
-    it('dry run', function () {
-      for (let i = 0; i <= this.Settings.compileConcurrencyLimit; i++) {
-        this.LockManager.acquire('test_key' + i)
-      }
-      this.Metrics.inc
-        .calledWith('exceeded-compilier-concurrency-limit')
-        .should.equal(false)
-      this.LockManager.acquire(
-        'test_key_' + (this.Settings.compileConcurrencyLimit + 1)
-      )
-      this.Metrics.inc
-        .calledWith('exceeded-compilier-concurrency-limit')
-        .should.equal(true)
-    })
-
     it('exceeding the limit', function () {
       for (let i = 0; i <= this.Settings.compileConcurrencyLimit; i++) {
-        this.LockManager.acquire('test_key' + i, false)
+        this.LockManager.acquire('test_key' + i)
       }
       this.Metrics.inc
         .calledWith('exceeded-compilier-concurrency-limit')
@@ -111,7 +96,7 @@ describe('LockManager', function () {
 
     it('within the limit', function () {
       for (let i = 0; i <= this.Settings.compileConcurrencyLimit - 1; i++) {
-        this.LockManager.acquire('test_key' + i, false)
+        this.LockManager.acquire('test_key' + i)
       }
       this.Metrics.inc
         .calledWith('exceeded-compilier-concurrency-limit')