From 27485dc2456edf0165db63c825953abaf51dcb77 Mon Sep 17 00:00:00 2001
From: nguyentrungthat <80239428+nguentrungthat@users.noreply.github.com>
Date: Fri, 27 Mar 2026 08:45:44 +0700
Subject: [PATCH] Update skip physical test
---
BACKEND/app/services/line_connection.ts | 81 ++++++++++++++-----------
BACKEND/providers/socket_io_provider.ts | 12 ++--
2 files changed, 50 insertions(+), 43 deletions(-)
diff --git a/BACKEND/app/services/line_connection.ts b/BACKEND/app/services/line_connection.ts
index 8410791..4488b1f 100644
--- a/BACKEND/app/services/line_connection.ts
+++ b/BACKEND/app/services/line_connection.ts
@@ -1021,7 +1021,7 @@ export default class LineConnection {
await sendMessageToMail(
`[ATC] - [${this.config.stationName} - Line: ${this.config.lineNumber}] - Raw log issue ${result?.errors?.some((e) => e.category === 'SPECIAL_KEYWORD') ? '+ Special keywords' : ''}`,
tableHTML +
- `${`
+ `${`
@@ -1062,9 +1062,9 @@ export default class LineConnection {
| ${r.rule} |
${r.message} |
${escapeHtml(r.log.trim())
- .split('*')
- .filter((el) => el)
- .join(' *')} |
+ .split('*')
+ .filter((el) => el)
+ .join('
*')}
`
)
@@ -1175,6 +1175,8 @@ Ports Missing/Down: ${missing.length}\n\n`
}
this.config.runningPhysical = true
this.config.runningScenario = 'Physical Test'
+ this.config.isSkipPhysical = false
+ this.config.reasonSkipPhysical = ''
this.testingPortPoE = true
this.outputTestingPortPoE = ''
const listPorts = await this.getPorts()
@@ -1209,7 +1211,7 @@ Ports Missing/Down: ${missing.length}\n\n`
} else {
this.checkingPhysicalPort()
}
- }, 10000)
+ }, 15000)
}
async checkingPhysicalPort() {
@@ -1323,7 +1325,7 @@ Ports Missing/Down: ${missing.length}\n\n`
*/
async sendReportPhysicalTest(reason?: string) {
this.config.listFeatureTested = [...new Set([...this.config.listFeatureTested, 'PHYSICAL'])]
- if (reason) {
+ if (typeof reason === 'string' && reason.length > 0) {
this.config.isSkipPhysical = true
this.config.reasonSkipPhysical = reason
}
@@ -1335,11 +1337,12 @@ Ports Missing/Down: ${missing.length}\n\n`
)
this.setTimeoutSendSummaryReport(30000)
const formReport = this.physicalTest.getFormReport(this.config.inventory)
- const reasonSkipPhysical = reason
- ? `
User Skip Test Port
+ const reasonSkipPhysical =
+ typeof reason === 'string' && reason.length > 0
+ ? `
User Skip Test Port
────────────────────────────────
${reason}`
- : ''
+ : ''
await sendMessageToMail(
`[ATC] - [${this.config.stationName} - Line: ${this.config.lineNumber}] - Physical Ports Test`,
formReport + reasonSkipPhysical
@@ -1437,7 +1440,7 @@ Ports Missing/Down: ${missing.length}\n\n`
await sendMessageToMail(
`[ATC] - [${this.config.stationName} - Line: ${this.config.lineNumber}] - Load IOS Report`,
body +
- `${`
+ `${`
Logs:
@@ -1475,7 +1478,7 @@ Ports Missing/Down: ${missing.length}\n\n`
await sendMessageToMail(
`[ATC] - [${this.config.stationName} - Line: ${this.config.lineNumber}] - Load License Report`,
body +
- `${`
+ `${`
Logs:
@@ -1780,15 +1783,15 @@ ${log}
${escapeHtml(output)
- .replace('show ver', '')
- .replace('sh ver', '')
- .replace('show version', '')
- .replace('sh version', '')
- .replace(mem, `${mem}`)
- .replace(
- flash,
- `${flash}`
- )}
+ .replace('show ver', '')
+ .replace('sh ver', '')
+ .replace('show version', '')
+ .replace('sh version', '')
+ .replace(mem, `${mem}`)
+ .replace(
+ flash,
+ `${flash}`
+ )}
`
await sendMessageToMail(subject, body)
}
@@ -1841,11 +1844,12 @@ ${log}
showLicense?.textfsm && Array.isArray(showLicense?.textfsm) ? showLicense?.textfsm : null
const issue = config?.latestScenario?.detectAI?.issue || []
const summary = config?.latestScenario?.detectAI?.summary || ''
+ const reason = this.config.reasonSkipPhysical || snapshot?.reason
const reasonSkipPhysical =
- snapshot?.reason || this.config.reasonSkipPhysical
+ typeof reason === 'string' && reason.length > 0
? `
User Skip Test Port
────────────────────────────────
- ${snapshot?.reason || this.config.reasonSkipPhysical}`
+ ${reason}`
: ''
const body = `
@@ -1861,13 +1865,14 @@ ${log}
IOS: ${dataShowVersion?.SOFTWARE_IMAGE ?? ''} ${dataShowVersion?.VERSION ?? ''}
MEM: ${dataShowVersion?.MEMORY ? convertFromKilobytesString(dataShowVersion?.MEMORY) : ''}
FLASH: ${dataShowVersion?.USB_FLASH ? convertFromKilobytesString(dataShowVersion?.USB_FLASH) : ''}
- Licenses: ${dataShowLic
- ? dataShowLic
- ?.filter((el) => el.LICENSE_TYPE?.toLowerCase()?.includes('permanent'))
- ?.map((v) => v.FEATURE)
- ?.join(', ')
- : ''
- }
+ Licenses: ${
+ dataShowLic
+ ? dataShowLic
+ ?.filter((el) => el.LICENSE_TYPE?.toLowerCase()?.includes('permanent'))
+ ?.map((v) => v.FEATURE)
+ ?.join(', ')
+ : ''
+ }
Summary: ${summary}
Issues: ${issue?.length ? `
- ` + issue.join(`
- `) : 'No issues detected.'}
@@ -1875,21 +1880,23 @@ ${log}
Total Ports: ${portPhysical?.length}
Ports Tested (Link UP): ${tested.length} (${testedPoE?.length} PoE, ${testedSFP?.length} SFP)
Ports Missing/Down: ${missing.length}
- ${missingPoE?.length
- ? `
+ ${
+ missingPoE?.length
+ ? `
Ports Missing PoE
────────────────────────────────
${missingPoE.map((p) => physicalTest.normalizePortName(p.name)).join('
')}
`
- : ''
- }
- ${missingSFP?.length
- ? `
+ : ''
+ }
+ ${
+ missingSFP?.length
+ ? `
Ports Missing SFP
────────────────────────────────
${missingSFP.map((p) => physicalTest.normalizePortName(p.name)).join('
')}
`
- : ''
- }
+ : ''
+ }
${reasonSkipPhysical}
diff --git a/BACKEND/providers/socket_io_provider.ts b/BACKEND/providers/socket_io_provider.ts
index b72ebec..531cf21 100644
--- a/BACKEND/providers/socket_io_provider.ts
+++ b/BACKEND/providers/socket_io_provider.ts
@@ -53,22 +53,22 @@ type StationAction = (
export default class SocketIoProvider {
private static _io: CustomServer
- constructor(protected app: ApplicationService) { }
+ constructor(protected app: ApplicationService) {}
/**
* Register bindings to the container
*/
- register() { }
+ register() {}
/**
* The container bindings have booted
*/
- async boot() { }
+ async boot() {}
/**
* The application has been booted
*/
- async start() { }
+ async start() {}
/**
* The process has been started
@@ -83,7 +83,7 @@ export default class SocketIoProvider {
/**
* Preparing to shutdown the app
*/
- async shutdown() { }
+ async shutdown() {}
public static get io() {
return this._io
@@ -100,7 +100,7 @@ export class WebSocketIo {
lineConnecting: number[] = [] // key = lineId
intervalKeepConnect: { [key: string]: NodeJS.Timeout } = {}
- constructor(protected app: ApplicationService) { }
+ constructor(protected app: ApplicationService) {}
async boot() {
const SOCKET_IO_PORT = env.get('SOCKET_PORT') || 8989