Skip to content

Commit

Permalink
Merge pull request #246 from maany/feature-226-fixes-in-prod
Browse files Browse the repository at this point in the history
Feature 226 fixes in prod
  • Loading branch information
maany authored Jul 14, 2023
2 parents a660bc8 + 3db9e49 commit 11c0b8a
Show file tree
Hide file tree
Showing 11 changed files with 142 additions and 131 deletions.
215 changes: 109 additions & 106 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"build": "next build",
"start": "next start",
"lint": "next lint",
"test": "jest --testPathPattern test/component test/api --projects test/api/jest.api.config.js test/component/jest.component.config.js",
"test": "jest --testPathPattern test/component test/api test/gateway test/sdk --projects test/api/jest.api.config.js test/component/jest.component.config.js test/gateway/jest.gateway.config.js test/sdk/jest.sdk.config.js",
"test:api": "jest --testPathPattern=test/api --projects test/api/jest.api.config.js",
"test:component": "jest --testPathPattern=test/component --projects test/component/jest.component.config.js",
"test:gateway": "jest --testPathPattern=test/gateway --projects test/gateway/jest.gateway.config.js",
Expand Down
1 change: 1 addition & 0 deletions src/app/dashboard/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default async function DashboardLayout({
return (
<div>
<h3>You are logged in as {sessionUser?.rucioIdentity}</h3>
<h3>Your rucio auth token is {rucioAuthToken}</h3>
{children}
</div>
)
Expand Down
16 changes: 11 additions & 5 deletions src/app/listdids/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';
import { ListDID as ListDIDStory } from "@/component-library/components/Pages/ListDID/ListDID";
import { DIDMeta } from "@/lib/core/entity/rucio";
import { DIDMeta, DIDType } from "@/lib/core/entity/rucio";
import { DIDLong } from "@/lib/core/entity/rucio"
import { DIDName } from '@/lib/infrastructure/data/view-model/create-rule'
import useComDOM from "@/lib/infrastructure/hooks/useComDOM";
Expand All @@ -11,7 +11,7 @@ import { createDIDMeta } from "test/fixtures/table-fixtures";

export default function ListDID() {

const [didMetaQueryResponse, setDIDMetaQueryResponse] = useState<DIDMeta>(createDIDMeta())
const [didMetaQueryResponse, setDIDMetaQueryResponse] = useState<DIDMeta>({} as DIDMeta)
const didMetaQuery = (did: DIDName) => { setDIDMetaQueryResponse(createDIDMeta()) }

const DIDSearchComDOM = useComDOM<DIDLong>(
Expand All @@ -22,15 +22,21 @@ export default function ListDID() {
200,
true
)
useEffect(() => {
setDIDMetaQueryResponse(createDIDMeta())
}, [])
useEffect(() => {
const setRequest = async () => {
const request: HTTPRequest = {
url: new URL('http://localhost:3000/api/listdids'),
method: 'GET',
url: new URL('http://localhost:3000/api/dids'),
method: 'POST',
headers: new Headers({
'Content-Type': 'application/json',
} as HeadersInit),
body: null,
body: {
"query": "test:*",
"type": DIDType.DATASET
},
}
await DIDSearchComDOM.setRequest(request)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { DIDType } from "@/lib/core/entity/rucio";
import { Response } from "node-fetch";

export default class GetDIDEndpoint extends BaseEndpoint<DIDDTO> {
private url = `${this.rucioHost}/dids/${this.scope}/${this.name}/status`

constructor(
private rucioAuthToken: string,
Expand All @@ -19,6 +18,7 @@ export default class GetDIDEndpoint extends BaseEndpoint<DIDDTO> {
*/
async initialize(): Promise<void> {
await super.initialize()
this.url = `${this.rucioHost}/dids/${this.scope}/${this.name}/status`
const request: HTTPRequest = {
method: 'GET',
url: this.url,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { BaseStreamableEndpoint } from "@/lib/sdk/gateway-endpoints"
import { parseDIDString } from "@/lib/common/did-utils"
import { HTTPRequest } from "@/lib/common/http"
import { ListDIDDTO } from "@/lib/core/dto/did-dto"
import { DID, DIDType } from "@/lib/core/entity/rucio"
Expand Down Expand Up @@ -83,11 +82,10 @@ export default class ListDIDsEndpoint extends BaseStreamableEndpoint<ListDIDDTO,

/** @implements */
createDTO(chunk: Buffer): DID {
const didName = JSON.parse(chunk.toString())
const parsedDID = parseDIDString(didName)
const didName = JSON.parse(chunk.toString()).split('"')[1]
const did: DID = {
name: parsedDID.name,
scope: parsedDID.scope,
name: didName,
scope: this.scope,
did_type: this.type,
}
return did
Expand Down
5 changes: 4 additions & 1 deletion src/lib/sdk/gateway-endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,11 @@ export abstract class BaseEndpoint<TDTO extends BaseDTO> {
protected initialized: boolean = false;
protected request: HTTPRequest | undefined;
protected rucioHost: string = 'https://rucio-host.com';
protected envConfigGateway: EnvConfigGatewayOutputPort;

protected url: string = '';

protected envConfigGateway: EnvConfigGatewayOutputPort;

constructor(
) {
this.envConfigGateway = appContainer.get<EnvConfigGatewayOutputPort>(GATEWAYS.ENV_CONFIG);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/sdk/presenter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export abstract class BaseStreamingPresenter<
const responseModel: TResponseModel = chunk
const viewModel =
this.convertResponseModelToViewModel(responseModel)
callback(undefined, viewModel)
callback(undefined, JSON.stringify(viewModel))
} catch (error) {
this.emit('error', error)
callback(error as Error)
Expand Down
8 changes: 4 additions & 4 deletions test/api/did/list-dids.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ describe('DID API Tests', () => {
},
body: Readable.from(
[
'test:dataset1',
'test:dataset2',
'test:dataset3',
'"dataset1"',
'"dataset2"',
'"dataset3"',
].join('\n'),
),
},
Expand Down Expand Up @@ -124,7 +124,7 @@ describe('DID API Tests', () => {

const receivedData: any[] = []
const onData = (data: any) => {
receivedData.push(data)
receivedData.push(JSON.parse(data))
}

const done = new Promise<void>((resolve, reject) => {
Expand Down
12 changes: 6 additions & 6 deletions test/gateway/did-gateway.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ describe('DID Gateway Tests', () => {
status: 401,
})
}
if (req.url.includes('/mc16_13TeV/dids/search')) {
if (req.url.includes('/data17_13TeV/dids/search')) {
const stream = Readable.from(
[
'data17_13TeV:00325748.physics_Main.merge.DAOD_EXOT15.f102_m2608_p3372_tid15339900_00',
'data17_13TeV:00325748.physics_Main.merge.DAOD_EXOT15.f102_m2608_p3372_tid15339900_01',
'data17_13TeV:00325748.physics_Main.merge.DAOD_EXOT15.f102_m2608_p3372_tid15339900_02',
'"00325748.physics_Main.merge.DAOD_EXOT15.f102_m2608_p3372_tid15339900_00"',
'"00325748.physics_Main.merge.DAOD_EXOT15.f102_m2608_p3372_tid15339900_01"',
'"00325748.physics_Main.merge.DAOD_EXOT15.f102_m2608_p3372_tid15339900_02"',
].join('\n'),
)
return Promise.resolve({
Expand Down Expand Up @@ -62,8 +62,8 @@ describe('DID Gateway Tests', () => {
)
const dto: ListDIDDTO = await rucioDIDGateway.listDIDs(
'rucio-ddmlab-askdjljioj',
'mc16_13TeV',
'data17_13TeV.00325748.physics_Main.merge.DAOD_EXOT15.f102_m2608_p3372_tid15339900_00',
'data17_13TeV',
'00325748.physics_Main.merge.DAOD_EXOT15.f102_m2608_p3372_tid15339900_00',
DIDType.DATASET,
)
expect(dto.status).toBe('success')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ describe('BaseMultiCallStreamableUseCase', () => {

const receivedData: any[] = []
const onData = (data: string) => {
receivedData.push(data)
receivedData.push(JSON.parse(data))
}

const done = new Promise<void>((resolve, reject) => {
Expand Down

0 comments on commit 11c0b8a

Please sign in to comment.