Update skip physical test

This commit is contained in:
nguyentrungthat 2026-03-27 08:45:44 +07:00
parent 36dc75bee8
commit 27485dc245
2 changed files with 50 additions and 43 deletions

View File

@ -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 +
`${`
`${`
<hr />
<p>Logs:</p>
<div style="white-space: break-spaces; background-color: #f5f5f5; color: black; padding: 8px; max-height: 500px; overflow-y: scroll; border: 1px #ccc solid;"><span style="color: black;">
@ -1062,9 +1062,9 @@ export default class LineConnection {
<td style="padding:6px; text-align:center;">${r.rule}</td>
<td style="padding:6px; text-align:center;">${r.message}</td>
<td style="padding:6px; font-family:monospace;">${escapeHtml(r.log.trim())
.split('*')
.filter((el) => el)
.join('<br/>*')}</td>
.split('*')
.filter((el) => el)
.join('<br/>*')}</td>
</tr>
`
)
@ -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
? `<b style="color: #ff0000;">User Skip Test Port</b><br/>
const reasonSkipPhysical =
typeof reason === 'string' && reason.length > 0
? `<b style="color: #ff0000;">User Skip Test Port</b><br/>
<br/>
${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 +
`${`
`${`
<hr />
<p>Logs:</p>
<div style="white-space: break-spaces; background-color: #f5f5f5; color: black; padding: 8px; max-height: 500px; overflow-y: scroll; border: 1px #ccc solid;"><span style="color: black;">
@ -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 +
`${`
`${`
<hr />
<p>Logs:</p>
<div style="white-space: break-spaces; background-color: #f5f5f5; color: black; padding: 8px; max-height: 500px; overflow-y: scroll; border: 1px #ccc solid;"><span style="color: black;">
@ -1780,15 +1783,15 @@ ${log}
<hr />
<div style="white-space: break-spaces; background-color: #f5f5f5; color: black; padding: 8px; max-height: 500px; overflow-y: scroll; border: 1px #ccc solid;"><span style="color: black;">
${escapeHtml(output)
.replace('show ver', '')
.replace('sh ver', '')
.replace('show version', '')
.replace('sh version', '')
.replace(mem, `<span style="color: ${isWarningRAM ? 'red' : 'black'};">${mem}</span>`)
.replace(
flash,
`<span style="color: ${isWarningFlash ? 'red' : 'black'};">${flash}</span>`
)}</span></div>
.replace('show ver', '')
.replace('sh ver', '')
.replace('show version', '')
.replace('sh version', '')
.replace(mem, `<span style="color: ${isWarningRAM ? 'red' : 'black'};">${mem}</span>`)
.replace(
flash,
`<span style="color: ${isWarningFlash ? 'red' : 'black'};">${flash}</span>`
)}</span></div>
`
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
? `<br/><b style="color: #ff0000;">User Skip Test Port</b><br/>
<br/>
${snapshot?.reason || this.config.reasonSkipPhysical}`
${reason}`
: ''
const body = `<table cellpadding="6" cellspacing="0" border="1" style="margin-top: 10px; border-collapse: collapse; width: 100%">
@ -1861,13 +1865,14 @@ ${log}
IOS: <b>${dataShowVersion?.SOFTWARE_IMAGE ?? ''}</b> <b>${dataShowVersion?.VERSION ?? ''}</b><br/>
MEM: <b>${dataShowVersion?.MEMORY ? convertFromKilobytesString(dataShowVersion?.MEMORY) : ''}</b><br/>
FLASH: <b>${dataShowVersion?.USB_FLASH ? convertFromKilobytesString(dataShowVersion?.USB_FLASH) : ''}</b><br/>
Licenses: <b>${dataShowLic
? dataShowLic
?.filter((el) => el.LICENSE_TYPE?.toLowerCase()?.includes('permanent'))
?.map((v) => v.FEATURE)
?.join(', ')
: ''
}</b><br/>
Licenses: <b>${
dataShowLic
? dataShowLic
?.filter((el) => el.LICENSE_TYPE?.toLowerCase()?.includes('permanent'))
?.map((v) => v.FEATURE)
?.join(', ')
: ''
}</b><br/>
Summary: <b style="color: ${!summary?.includes('No hardware issues found') ? '#ff0000' : ''};">${summary}</b><br/>
Issues: <b style="color: ${issue.filter((el) => !el.includes('No issues detected')).length ? '#ff0000' : 'black'};">${issue?.length ? `<br>- ` + issue.join(`<br>- `) : 'No issues detected.'}</b><br/>
</td>
@ -1875,21 +1880,23 @@ ${log}
Total Ports: ${portPhysical?.length}<br/>
Ports Tested (Link UP): <b style="color: #008000;">${tested.length} (${testedPoE?.length} PoE, ${testedSFP?.length} SFP)</b><br/>
Ports Missing/Down: <b style="color: #ff0000;">${missing.length}</b><br/>
${missingPoE?.length
? `
${
missingPoE?.length
? `
<br/><b style="color: #ff0000;">Ports Missing PoE</b><br/>
<br/>
<div style="column-count: 6;">${missingPoE.map((p) => physicalTest.normalizePortName(p.name)).join('<br/>')}</div>
`
: ''
}
${missingSFP?.length
? `
: ''
}
${
missingSFP?.length
? `
<br/><b style="color: #ff0000;">Ports Missing SFP</b><br/>
<br/>
<div style="column-count: 6;">${missingSFP.map((p) => physicalTest.normalizePortName(p.name)).join('<br/>')}</div>`
: ''
}
: ''
}
${reasonSkipPhysical}
</td>
</tr>

View File

@ -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