Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR to execute testcase on pipeline #10

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,9 @@ jobs:

- name: Build Docker image
run: docker build -t lods --build-arg VULKAN_DLL_PATH=./vulkan-sdt/1.3.268.0/runtime/x64/vulkan-1.dll .


- name: Execute test case | tmp
run: |
docker run -d -e HTTP_SERVER_PORT=8080 -e HTTP_SERVER_HOST=0.0.0.0 lods > container_id.txt
sleep 180
docker logs $(cat container_id.txt)
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# prepare base image for TS projects
FROM mcr.microsoft.com/windows/servercore:ltsc2019 as base
FROM mcr.microsoft.com/windows/nanoserver:ltsc2019 as base

ADD https://aka.ms/vs/16/release/vc_redist.x64.exe C:\\vc_redist.x64.exe
RUN C:\\vc_redist.x64.exe /quiet /install
Expand Down Expand Up @@ -59,7 +59,7 @@ ARG VULKAN_DLL_PATH
COPY ${VULKAN_DLL_PATH} ./publish/vulkan-1.dll

# bundle all apps
FROM mcr.microsoft.com/windows:ltsc2019
FROM mcr.microsoft.com/windows/nanoserver:ltsc2019

ADD https://aka.ms/vs/16/release/vc_redist.x64.exe C:\\vc_redist.x64.exe
RUN C:\\vc_redist.x64.exe /quiet /install
Expand Down
17 changes: 10 additions & 7 deletions consumer-server/src/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import { createMetricsComponent, instrumentHttpServerWithMetrics } from '@well-k

import { AppComponents, GlobalContext } from './types'
import { metricDeclarations } from './metrics'
import { createSqsAdapter } from './adapters/sqs'
import { createMessagesConsumerComponent } from './logic/message-consumer'
// import { createSqsAdapter } from './adapters/sqs'
// import { createMessagesConsumerComponent } from './logic/message-consumer'
import { buildLicense } from './utils/license-builder'

import { validate } from './logic/boot-validator'

export async function initComponents(): Promise<AppComponents> {
const config = await createDotEnvConfigComponent({ path: ['.env.default', '.env'] })

Expand All @@ -19,8 +21,9 @@ export async function initComponents(): Promise<AppComponents> {

await instrumentHttpServerWithMetrics({ metrics, server, config })

const queue = await createSqsAdapter({ config })
const messageConsumer = await createMessagesConsumerComponent({ logs, queue })
// const queue = await createSqsAdapter({ config })
// const messageConsumer = await createMessagesConsumerComponent({ logs, queue })
const result = await validate({ logs })

await buildLicense({ config, logs })

Expand All @@ -29,8 +32,8 @@ export async function initComponents(): Promise<AppComponents> {
logs,
server,
metrics,
statusChecks,
queue,
messageConsumer
statusChecks
// queue,
// messageConsumer
}
}
70 changes: 70 additions & 0 deletions consumer-server/src/logic/boot-validator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { exec } from 'child_process'
import path from 'path'
import fs from 'fs'
import os from 'os'

import { AppComponents } from '../types'

const projectRoot = path.resolve(__dirname, '..', '..', '..')
const lodGeneratorProgram = path.join(projectRoot, 'api', 'DCL_PiXYZ.exe')
const sceneLodEntitiesManifestBuilder = path.join(projectRoot, 'scene-lod')

export async function validate({ logs }: Pick<AppComponents, 'logs'>): Promise<void> {
const logger = logs.getLogger('boot-validator')

logger.info('Validating boot...')

logger.info('Checking if PiXYZ is present at', { lodGeneratorProgram })
if (fs.existsSync(lodGeneratorProgram)) {
logger.info('PiXYZ program found')
} else {
logger.error('PiXYZ program not found')
}

if (fs.existsSync(sceneLodEntitiesManifestBuilder)) {
logger.info('Scene LOD Entities directory found')
} else {
logger.error('Scene LOD Entities directory not found')
}

if (fs.existsSync(lodGeneratorProgram) && fs.existsSync(sceneLodEntitiesManifestBuilder)) {
logger.info('Executing test case...')
const outputPath = path.join(os.tmpdir(), 'output');
if (!fs.existsSync(outputPath)) {
fs.mkdirSync(outputPath);
}

const command = `${lodGeneratorProgram} "coords" "-129,-77" "50" ${sceneLodEntitiesManifestBuilder} "${outputPath}"`
// trigger exec asynchronously
await Promise.all([
new Promise((resolve, _) => {
logger.info('Triggering command')
return exec(command, (error, stdout, stderr) => {
if (error) {
logger.error(`exec error: ${error}`)
resolve(false)
}
logger.info(`stdout: ${stdout}`)
logger.error(`stderr: ${stderr}`)
resolve(true)
})
})
])

// await new Promise((resolve, reject) => {
// exec(command, (error, stdout, stderr) => {
// if (error) {
// logger.error(`exec error: ${error}`)
// resolve(false)
// }
// logger.info(`stdout: ${stdout}`)
// logger.error(`stderr: ${stderr}`)
// resolve(true)
// })
// })
// list files from outputPath
const files = fs.readdirSync(outputPath)
logger.info('Output files:', { files: JSON.stringify(files, null, 2) })
}
process.exit(0)
}
64 changes: 32 additions & 32 deletions consumer-server/src/logic/message-consumer.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
import { AppComponents, QueueWorker } from '../types'
// import { AppComponents, QueueWorker } from '../types'

export async function createMessagesConsumerComponent({
logs,
queue
}: Pick<AppComponents, 'logs' | 'queue'>): Promise<QueueWorker> {
const logger = logs.getLogger('messages-consumer')
// export async function createMessagesConsumerComponent({
// logs,
// queue
// }: Pick<AppComponents, 'logs' | 'queue'>): Promise<QueueWorker> {
// const logger = logs.getLogger('messages-consumer')

async function start() {
while (true) {
const messages = await queue.receiveSingleMessage()
for (const message of messages) {
const { MessageId, Body, ReceiptHandle } = message
// async function start() {
// while (true) {
// const messages = await queue.receiveSingleMessage()
// for (const message of messages) {
// const { MessageId, Body, ReceiptHandle } = message

try {
const parsedMessage: { Message: string } = JSON.parse(Body!)
logger.info('Handling message from queue', {
id: MessageId!,
message: parsedMessage.Message
})
} catch (error: any) {
logger.error('Failed while handling message from queue', {
id: MessageId!,
error
})
} finally {
await queue.deleteMessage(ReceiptHandle!)
}
}
}
}
// try {
// const parsedMessage: { Message: string } = JSON.parse(Body!)
// logger.info('Handling message from queue', {
// id: MessageId!,
// message: parsedMessage.Message
// })
// } catch (error: any) {
// logger.error('Failed while handling message from queue', {
// id: MessageId!,
// error
// })
// } finally {
// await queue.deleteMessage(ReceiptHandle!)
// }
// }
// }
// }

return {
start
}
}
// return {
// start
// }
// }
2 changes: 0 additions & 2 deletions consumer-server/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ export type BaseComponents = {
logs: ILoggerComponent
server: IHttpServerComponent<GlobalContext>
metrics: IMetricsComponent<keyof typeof metricDeclarations>
queue: QueueService
messageConsumer: QueueWorker
}

// components used in runtime
Expand Down
Loading