()
| 143 | } |
| 144 | |
| 145 | async test () { |
| 146 | if (this.isTesting) { |
| 147 | log.debug(`[speed] test skipped (already running): ${this.hostname}`) |
| 148 | return |
| 149 | } |
| 150 | this.isTesting = true |
| 151 | this.testCount++ |
| 152 | log.debug(`[speed] test start: ${this.hostname}, testCount: ${this.testCount}`) |
| 153 | |
| 154 | try { |
| 155 | const newList = await this.getIpListFromDns(this.dnsMap) |
| 156 | const newBackupList = [...newList, ...this.backupList] |
| 157 | this.backupList = _.unionBy(newBackupList, 'host') |
| 158 | await this.testBackups() |
| 159 | log.info(`[speed] test end: ${this.hostname} ➜ ip-list:`, this.backupList, `, testCount: ${this.testCount}`) |
| 160 | if (config.notify) { |
| 161 | config.notify({ key: 'test' }) |
| 162 | } |
| 163 | } catch (e) { |
| 164 | log.error(`[speed] test failed: ${this.hostname}, testCount: ${this.testCount}, error:`, e) |
| 165 | } finally { |
| 166 | this.isTesting = false |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | async testBackups () { |
| 171 | if (this.isTestingBackups) { |
no test coverage detected