Skip to content

Commit

Permalink
fix broken roundtrip tests (finos#2753)
Browse files Browse the repository at this point in the history
  • Loading branch information
YannanGao-gs authored Nov 2, 2023
1 parent 5e96592 commit 8254d76
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/curly-moose-sparkle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@finos/legend-extension-dsl-persistence': patch
'@finos/legend-extension-dsl-data-space': patch
'@finos/legend-graph': patch
---
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const TEST_DATA__roundtrip = [
package: 'test::model',
runtimeValue: {
_type: 'engineRuntime',
connectionStores: [],
connections: [],
mappings: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export const TEST_DATA__roundtrip_append_only_allow_duplicates = [
mapping: 'test::Mapping',
runtime: {
_type: 'engineRuntime',
connectionStores: [],
connections: [],
mappings: [
{
Expand Down Expand Up @@ -447,6 +448,7 @@ export const TEST_DATA__roundtrip_bitemporal_no_del_ind_user_specifies_from = [
mapping: 'test::Mapping',
runtime: {
_type: 'engineRuntime',
connectionStores: [],
connections: [],
mappings: [
{
Expand Down Expand Up @@ -724,6 +726,7 @@ export const TEST_DATA__roundtrip_non_temporal_snapshot_date_time_audit = [
mapping: 'test::Mapping',
runtime: {
_type: 'engineRuntime',
connectionStores: [],
connections: [],
mappings: [
{
Expand Down Expand Up @@ -1351,6 +1354,7 @@ export const TEST_DATA__roundtrip_graph_fetch_basic = [
package: 'test::runtime',
runtimeValue: {
_type: 'engineRuntime',
connectionStores: [],
connections: [
{
store: {
Expand Down Expand Up @@ -1386,6 +1390,7 @@ export const TEST_DATA__roundtrip_graph_fetch_basic = [
package: 'test::runtime',
runtimeValue: {
_type: 'engineRuntime',
connectionStores: [],
connections: [
{
store: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ export const TEST_DATA__roundtrip_case1 = [
mapping: 'org::dxl::Mapping',
runtime: {
_type: 'engineRuntime',
connectionStores: [],
connections: [],
mappings: [{ path: 'org::dxl::Mapping', type: 'MAPPING' }],
},
Expand Down Expand Up @@ -484,6 +485,7 @@ export const TEST_DATA__roundtrip_case2 = [
mapping: 'org::dxl::Mapping',
runtime: {
_type: 'engineRuntime',
connectionStores: [],
connections: [],
mappings: [
{
Expand Down Expand Up @@ -783,6 +785,7 @@ export const TEST_DATA__cloud__roundtrip = [
mapping: 'org::dxl::Mapping',
runtime: {
_type: 'engineRuntime',
connectionStores: [],
connections: [],
mappings: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export const TEST_DATA__RuntimeRoundtrip = [
package: 'test',
runtimeValue: {
_type: 'engineRuntime',
connectionStores: [],
connections: [
{
store: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ export const TEST_DATA__ServiceRoundtrip = [
mapping: 'my::map',
runtime: {
_type: 'engineRuntime',
connectionStores: [],
connections: [],
mappings: [
{
Expand Down Expand Up @@ -328,6 +329,7 @@ export const TEST_DATA__ServiceRoundtrip = [
mapping: 'my::map',
runtime: {
_type: 'engineRuntime',
connectionStores: [],
connections: [],
mappings: [
{
Expand Down Expand Up @@ -456,6 +458,7 @@ export const TEST_DATA__ServiceRoundtrip = [
mapping: 'my::map',
runtime: {
_type: 'engineRuntime',
connectionStores: [],
connections: [],
mappings: [
{
Expand Down Expand Up @@ -811,6 +814,7 @@ export const TEST_DATA__ServiceRoundtrip = [
mapping: 'my::map',
runtime: {
_type: 'engineRuntime',
connectionStores: [],
connections: [],
mappings: [
{
Expand Down Expand Up @@ -955,6 +959,7 @@ export const TEST_DATA__ServiceRoundtrip = [
mapping: 'my::map',
runtime: {
_type: 'engineRuntime',
connectionStores: [],
connections: [],
mappings: [
{
Expand Down Expand Up @@ -1115,6 +1120,7 @@ export const TEST_DATA__ServiceRoundtrip = [
mapping: 'test::tMapping',
runtime: {
_type: 'engineRuntime',
connectionStores: [],
connections: [
{
store: {
Expand Down Expand Up @@ -1168,6 +1174,7 @@ export const TEST_DATA__ServiceRoundtrip = [
package: 'test',
runtimeValue: {
_type: 'engineRuntime',
connectionStores: [],
connections: [],
mappings: [
{
Expand Down Expand Up @@ -1683,6 +1690,7 @@ export const TEST_DATA__SERVICE_WITH_ONLY_QUERY_Roundtrip = [
package: 'execution',
runtimeValue: {
_type: 'engineRuntime',
connectionStores: [],
connections: [
{
store: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { CORE_HASH_STRUCTURE } from '../../../../../../../graph/Core_HashUtils.j
import { type Hashable, hashArray } from '@finos/legend-shared';
import type { V1_PackageableElementPointer } from '../../../model/packageableElements/V1_PackageableElement.js';
import type { V1_Connection } from '../../../model/packageableElements/connection/V1_Connection.js';
import type { V1_ConnectionPointer } from '../connection/V1_ConnectionPointer.js';

export abstract class V1_Runtime implements Hashable {
abstract get hashCode(): string;
Expand Down Expand Up @@ -49,14 +50,29 @@ export class V1_StoreConnections implements Hashable {
}
}

export class V1_ConnectionStores implements Hashable {
connectionPointer!: V1_ConnectionPointer;
storePointers: V1_PackageableElementPointer[] = [];

get hashCode(): string {
return hashArray([
CORE_HASH_STRUCTURE.STORE_CONNECTIONS,
this.connectionPointer,
hashArray(this.storePointers),
]);
}
}

export class V1_EngineRuntime extends V1_Runtime implements Hashable {
mappings: V1_PackageableElementPointer[] = [];
connectionStores: V1_ConnectionStores[] = [];
connections: V1_StoreConnections[] = [];

get hashCode(): string {
return hashArray([
CORE_HASH_STRUCTURE.ENGINE_RUNTIME,
hashArray(this.mappings),
hashArray(this.connectionStores),
hashArray(this.connections),
]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ import {
V1_LegacyRuntime,
V1_RuntimePointer,
V1_StoreConnections,
V1_ConnectionStores,
} from '../../../model/packageableElements/runtime/V1_Runtime.js';
import {
V1_serializeConnectionValue,
V1_deserializeConnectionValue,
V1_connectionPointerModelSchema,
} from './V1_ConnectionSerializationHelper.js';
import type { PureProtocolProcessorPlugin } from '../../../../PureProtocolProcessorPlugin.js';

Expand Down Expand Up @@ -86,12 +88,19 @@ export const V1_setupEngineRuntimeSerialization = (
),
id: primitive(),
});
createModelSchema(V1_ConnectionStores, {
connectionPointer: usingModelSchema(V1_connectionPointerModelSchema),
storePointers: list(
usingModelSchema(V1_packageableElementPointerModelSchema),
),
});
createModelSchema(V1_StoreConnections, {
store: usingModelSchema(V1_packageableElementPointerModelSchema),
storeConnections: list(object(V1_IdentifiedConnection)),
});
createModelSchema(V1_EngineRuntime, {
_type: usingConstantValueSchema(V1_RuntimeType.ENGINE_RUNTIME),
connectionStores: list(object(V1_ConnectionStores)),
connections: list(object(V1_StoreConnections)),
mappings: list(usingModelSchema(V1_packageableElementPointerModelSchema)),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ import {
CORE_HASH_STRUCTURE,
hashElementPointer,
} from '../../../../../graph/Core_HashUtils.js';
import type { Connection } from '../connection/Connection.js';
import type {
Connection,
ConnectionPointer,
} from '../connection/Connection.js';
import type { PackageableRuntime } from './PackageableRuntime.js';
import type { Mapping } from '../mapping/Mapping.js';
import type { Store } from '../store/Store.js';
Expand Down Expand Up @@ -66,12 +69,37 @@ export class StoreConnections implements Hashable {
}
}

export class ConnectionStores implements Hashable {
connectionPointer: ConnectionPointer;
storePointers: PackageableElementReference<Store>[] = [];

constructor(connectionPointer: ConnectionPointer) {
this.connectionPointer = connectionPointer;
}

get hashCode(): string {
return hashArray([
CORE_HASH_STRUCTURE.STORE_CONNECTIONS,
this.connectionPointer,
hashArray(
this.storePointers.map((s) =>
hashElementPointer(
PackageableElementPointerType.STORE,
s.valueForSerialization ?? '',
),
),
),
]);
}
}

export abstract class Runtime implements Hashable {
abstract get hashCode(): string;
}

export class EngineRuntime extends Runtime implements Hashable {
mappings: PackageableElementReference<Mapping>[] = [];
connectionStores: ConnectionStores[] = [];
connections: StoreConnections[] = [];

get hashCode(): string {
Expand All @@ -85,6 +113,7 @@ export class EngineRuntime extends Runtime implements Hashable {
),
),
),
hashArray(this.connectionStores),
hashArray(
this.connections.filter(
// TODO: use `isStubbed_StoreConnections` when we refactor hashing
Expand Down

0 comments on commit 8254d76

Please sign in to comment.