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

Support test data generation for services with parameters #2237

Merged
merged 1 commit into from
May 24, 2023

Conversation

irisyngao
Copy link
Contributor

@irisyngao irisyngao commented May 18, 2023

Summary

Support test data generation for services with parameters

How did you test this change?

  • Test(s) added
  • Manual testing (please provide screenshots/recordings)
  • No testing (please provide an explanation)

@irisyngao irisyngao requested a review from a team as a code owner May 18, 2023 14:32
@changeset-bot
Copy link

changeset-bot bot commented May 18, 2023

🦋 Changeset detected

Latest commit: 0d90da5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 27 packages
Name Type
@finos/legend-graph Patch
@finos/legend-application-studio Minor
@finos/legend-application-pure-ide Patch
@finos/legend-application-query-bootstrap Patch
@finos/legend-application-query Patch
@finos/legend-application-studio-bootstrap Patch
@finos/legend-application-taxonomy-bootstrap Patch
@finos/legend-application-taxonomy Patch
@finos/legend-extension-dsl-data-space Patch
@finos/legend-extension-dsl-diagram Patch
@finos/legend-extension-dsl-mastery Patch
@finos/legend-extension-dsl-persistence Patch
@finos/legend-extension-dsl-service Patch
@finos/legend-extension-dsl-snowflake-app Patch
@finos/legend-extension-dsl-text Patch
@finos/legend-extension-format-graphql Patch
@finos/legend-extension-format-json-schema Patch
@finos/legend-extension-store-flat-data Patch
@finos/legend-extension-store-relational Patch
@finos/legend-extension-store-service-store Patch
@finos/legend-lego Patch
@finos/legend-manual-tests Patch
@finos/legend-query-builder Patch
@finos/legend-application-pure-ide-deployment Patch
@finos/legend-application-query-deployment Patch
@finos/legend-application-studio-deployment Patch
@finos/legend-application-taxonomy-deployment Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@irisyngao irisyngao added the Status: Waiting for Backend Change The PR should not be merged if the changes in the backend has not been live yet label May 18, 2023
@irisyngao irisyngao self-assigned this May 18, 2023
@irisyngao irisyngao added Extension: DSL Service Application: Studio Issues related to Legend Studio application and removed Status: Waiting for Backend Change The PR should not be merged if the changes in the backend has not been live yet labels May 18, 2023
@irisyngao irisyngao added this to the 10.0.0 milestone May 18, 2023
@codecov
Copy link

codecov bot commented May 18, 2023

Codecov Report

Merging #2237 (cdc5f44) into master (660e33f) will increase coverage by 0.25%.
The diff coverage is 16.36%.

❗ Current head cdc5f44 differs from pull request most recent head 0d90da5. Consider uploading reports for the commit 0d90da5 to get more accurate results

@@            Coverage Diff             @@
##           master    #2237      +/-   ##
==========================================
+ Coverage   39.36%   39.61%   +0.25%     
==========================================
  Files        1551     1556       +5     
  Lines       72334    72468     +134     
  Branches    16841    16878      +37     
==========================================
+ Hits        28473    28710     +237     
+ Misses      43748    43645     -103     
  Partials      113      113              
Impacted Files Coverage Δ
.../service-editor/testable/ServiceTestDataEditor.tsx 11.81% <0.00%> (-0.22%) ⬇️
...raph/src/graph-manager/AbstractPureGraphManager.ts 30.55% <ø> (ø)
...ph-manager/protocol/pure/v1/V1_PureGraphManager.ts 43.44% <ø> (ø)
packages/legend-graph/src/graph/MetaModelConst.ts 100.00% <ø> (ø)
packages/legend-graph/src/graph/PureModel.ts 57.61% <ø> (ø)
...tor-state/service/testable/ServiceTestDataState.ts 11.72% <8.33%> (-0.78%) ⬇️
...o/src/application/LegendStudioApplicationConfig.ts 93.54% <100.00%> (+0.21%) ⬆️
...l/pure/packageableElements/domain/PrimitiveType.ts 86.66% <100.00%> (+0.95%) ⬆️
...omponents/shared/BasicValueSpecificationEditor.tsx 43.96% <100.00%> (+0.21%) ⬆️
...src/stores/QueryBuilderValueSpecificationHelper.ts 80.00% <100.00%> (+0.80%) ⬆️
... and 1 more

... and 77 files with indirect coverage changes

@irisyngao
Copy link
Contributor Author

{"clientVersion":"vX_X_X","function":{"_type":"lambda","body":[{"_type":"func","function":"take","parameters":[{"_type":"func","function":"sort","parameters":[{"_type":"func","function":"groupBy","parameters":[{"_type":"func","function":"getAll","parameters":[{"_type":"packageableElementPtr","fullPath":"model::Person"}]},{"_type":"collection","multiplicity":{"lowerBound":1,"upperBound":1},"values":[{"_type":"lambda","body":[{"_type":"property","parameters":[{"_type":"var","name":"x"}],"property":"lastName"}],"parameters":[{"_type":"var","name":"x"}]}]},{"_type":"collection","multiplicity":{"lowerBound":1,"upperBound":1},"values":[{"_type":"func","function":"agg","parameters":[{"_type":"lambda","body":[{"_type":"property","parameters":[{"_type":"var","name":"x"}],"property":"lastName"}],"parameters":[{"_type":"var","name":"x"}]},{"_type":"lambda","body":[{"_type":"func","function":"count","parameters":[{"_type":"func","function":"distinct","parameters":[{"_type":"var","name":"x"}]}]}],"parameters":[{"_type":"var","name":"x"}]}]}]},{"_type":"collection","multiplicity":{"lowerBound":2,"upperBound":2},"values":[{"_type":"string","value":"Value"},{"_type":"string","value":"Count"}]}]},{"_type":"collection","multiplicity":{"lowerBound":2,"upperBound":2},"values":[{"_type":"func","function":"desc","parameters":[{"_type":"string","value":"Count"}]},{"_type":"func","function":"asc","parameters":[{"_type":"string","value":"Value"}]}]}]},{"_type":"integer","value":10}]}],"parameters":[{"_type":"var","class":"Date","multiplicity":{"lowerBound":1,"upperBound":1},"name":"var_1"}]},"mapping":"model::RelationalMapping","model":{"_type":"data","elements":[{"_type":"profile","name":"MyExtension","package":"model","stereotypes":["important"],"tags":["doc"]},{"_type":"Enumeration","name":"IncType","package":"model","values":[{"value":"Corp"},{"value":"LLC"}]},{"_type":"class","constraints":[{"functionDefinition":{"_type":"lambda","body":[{"_type":"func","function":"startsWith","parameters":[{"_type":"property","property":"legalName","parameters":[{"_type":"var","name":"this"}]},{"_type":"string","value":"_"}]}],"parameters":[]},"name":"validName"}],"name":"Firm","package":"model","properties":[{"multiplicity":{"lowerBound":1},"name":"employees","type":"model::Person"},{"multiplicity":{"lowerBound":1,"upperBound":1},"name":"incType","type":"model::IncType"},{"multiplicity":{"lowerBound":1,"upperBound":1},"name":"isApple","type":"Boolean"}],"qualifiedProperties":[{"body":[{"_type":"func","function":"count","parameters":[{"_type":"property","property":"employees","parameters":[{"_type":"var","name":"this"}]}]}],"name":"employeeSize","parameters":[],"returnMultiplicity":{"lowerBound":1,"upperBound":1},"returnType":"Number"}],"stereotypes":[{"profile":"model::MyExtension","value":"important"}],"superTypes":["model::LegalEntity"],"taggedValues":[{"tag":{"profile":"model::MyExtension","value":"doc"},"value":"This is a model of a firm"}]},{"_type":"class","name":"Person","package":"model","properties":[{"multiplicity":{"lowerBound":1,"upperBound":1},"name":"firstName","type":"String"},{"multiplicity":{"lowerBound":1,"upperBound":1},"name":"lastName","type":"String"},{"multiplicity":{"lowerBound":1,"upperBound":1},"name":"age","type":"Integer"}],"qualifiedProperties":[{"body":[{"_type":"func","function":"plus","parameters":[{"_type":"collection","multiplicity":{"lowerBound":3,"upperBound":3},"values":[{"_type":"property","property":"firstName","parameters":[{"_type":"var","name":"this"}]},{"_type":"string","value":" "},{"_type":"property","property":"lastName","parameters":[{"_type":"var","name":"this"}]}]}]}],"name":"fullName","parameters":[],"returnMultiplicity":{"lowerBound":1,"upperBound":1},"returnType":"String"}]},{"_type":"class","name":"LegalEntity","package":"model","properties":[{"multiplicity":{"lowerBound":1,"upperBound":1},"name":"legalName","type":"String"}]},{"_type":"relational","filters":[],"includedStores":[],"joins":[{"name":"FirmPerson","operation":{"_type":"dynaFunc","funcName":"equal","parameters":[{"_type":"column","column":"firm_id","table":{"_type":"Table","database":"model::MyDatabase","mainTableDb":"model::MyDatabase","schema":"default","table":"PersonTable"},"tableAlias":"PersonTable"},{"_type":"column","column":"id","table":{"_type":"Table","database":"model::MyDatabase","mainTableDb":"model::MyDatabase","schema":"default","table":"FirmTable"},"tableAlias":"FirmTable"}]}}],"name":"MyDatabase","package":"model","schemas":[{"name":"default","tables":[{"columns":[{"name":"id","nullable":false,"type":{"_type":"Integer"}},{"name":"Legal_name","nullable":true,"type":{"_type":"Varchar","size":200}},{"name":"Inc","nullable":true,"type":{"_type":"Varchar","size":200}}],"name":"FirmTable","primaryKey":["id"]},{"columns":[{"name":"id","nullable":false,"type":{"_type":"Integer"}},{"name":"firm_id","nullable":true,"type":{"_type":"Integer"}},{"name":"firstName","nullable":true,"type":{"_type":"Varchar","size":200}},{"name":"lastName","nullable":true,"type":{"_type":"Varchar","size":200}}],"name":"PersonTable","primaryKey":["id"]}],"views":[]}]},{"_type":"mapping","classMappings":[{"_type":"relational","class":"model::Firm","distinct":false,"mainTable":{"_type":"Table","database":"model::MyDatabase","mainTableDb":"model::MyDatabase","schema":"default","table":"FirmTable"},"primaryKey":[{"_type":"column","column":"id","table":{"_type":"Table","database":"model::MyDatabase","mainTableDb":"model::MyDatabase","schema":"default","table":"FirmTable"},"tableAlias":"FirmTable"}],"propertyMappings":[{"_type":"relationalPropertyMapping","property":{"class":"model::Firm","property":"legalName"},"relationalOperation":{"_type":"dynaFunc","funcName":"concat","parameters":[{"_type":"column","column":"Legal_name","table":{"_type":"Table","database":"model::MyDatabase","mainTableDb":"model::MyDatabase","schema":"default","table":"FirmTable"},"tableAlias":"FirmTable"},{"_type":"literal","value":"_LTD"}]}},{"_type":"relationalPropertyMapping","property":{"class":"model::Firm","property":"employees"},"relationalOperation":{"_type":"elemtWithJoins","joins":[{"db":"model::MyDatabase","name":"FirmPerson"}]},"target":"model_Person"},{"_type":"relationalPropertyMapping","property":{"class":"model::Firm","property":"isApple"},"relationalOperation":{"_type":"dynaFunc","funcName":"case","parameters":[{"_type":"dynaFunc","funcName":"equal","parameters":[{"_type":"column","column":"Legal_name","table":{"_type":"Table","database":"model::MyDatabase","mainTableDb":"model::MyDatabase","schema":"default","table":"FirmTable"},"tableAlias":"FirmTable"},{"_type":"literal","value":"Apple"}]},{"_type":"literal","value":"true"},{"_type":"literal","value":"false"}]}},{"_type":"relationalPropertyMapping","enumMappingId":"model_IncType","property":{"class":"model::Firm","property":"incType"},"relationalOperation":{"_type":"column","column":"Inc","table":{"_type":"Table","database":"model::MyDatabase","mainTableDb":"model::MyDatabase","schema":"default","table":"FirmTable"},"tableAlias":"FirmTable"}}],"root":true},{"_type":"relational","class":"model::Person","distinct":false,"mainTable":{"_type":"Table","database":"model::MyDatabase","mainTableDb":"model::MyDatabase","schema":"default","table":"PersonTable"},"primaryKey":[{"_type":"column","column":"id","table":{"_type":"Table","database":"model::MyDatabase","mainTableDb":"model::MyDatabase","schema":"default","table":"PersonTable"},"tableAlias":"PersonTable"}],"propertyMappings":[{"_type":"relationalPropertyMapping","property":{"class":"model::Person","property":"firstName"},"relationalOperation":{"_type":"column","column":"firstName","table":{"_type":"Table","database":"model::MyDatabase","mainTableDb":"model::MyDatabase","schema":"default","table":"PersonTable"},"tableAlias":"PersonTable"}},{"_type":"relationalPropertyMapping","property":{"class":"model::Person","property":"lastName"},"relationalOperation":{"_type":"column","column":"lastName","table":{"_type":"Table","database":"model::MyDatabase","mainTableDb":"model::MyDatabase","schema":"default","table":"PersonTable"},"tableAlias":"PersonTable"}},{"_type":"relationalPropertyMapping","property":{"class":"model::Person","property":"age"},"relationalOperation":{"_type":"literal","value":10}}],"root":true}],"enumerationMappings":[{"enumValueMappings":[{"enumValue":"Corp","sourceValues":[{"_type":"stringSourceValue","value":"Corp"},{"_type":"stringSourceValue","value":"CORP"}]},{"enumValue":"LLC","sourceValues":[{"_type":"stringSourceValue","value":"LLC"}]}],"enumeration":"model::IncType"}],"includedMappings":[],"name":"RelationalMapping","package":"model","tests":[]},{"_type":"runtime","name":"Runtime","package":"model","runtimeValue":{"_type":"engineRuntime","connections":[{"store":{"path":"model::MyDatabase","type":"STORE"},"storeConnections":[{"connection":{"_type":"connectionPointer","connection":"model::MyConnection"},"id":"my_connection"}]}],"mappings":[{"path":"model::RelationalMapping","type":"MAPPING"}]}},{"_type":"connection","connectionValue":{"_type":"RelationalDatabaseConnection","authenticationStrategy":{"_type":"h2Default"},"databaseType":"H2","datasourceSpecification":{"_type":"h2Local","testDataSetupSqls":["Drop table if exists FirmTable;\nDrop table if exists PersonTable;\nCreate Table FirmTable(id INT, Legal_Name VARCHAR(200), Inc VARCHAR(200));\nCreate Table PersonTable(id INT, firm_id INT, lastName VARCHAR(200), firstName VARCHAR(200), age INT);\nInsert into FirmTable (id, Legal_Name, Inc) values (1, 'Finos', 'CORP');\nInsert into FirmTable (id, Legal_Name, Inc) values (2, 'Apple', 'Corp');\nInsert into FirmTable (id, Legal_Name, Inc) values (3, 'GS', 'Corp');\nInsert into FirmTable (id, Legal_Name, Inc) values (4, 'Google', 'Corp');\nInsert into FirmTable (id, Legal_Name, Inc) values (5, 'Alphabet', 'LLC');\nInsert into FirmTable (id, Legal_Name, Inc) values (6, 'Alphabet', 'LLC');\nInsert into FirmTable (id, Legal_Name, Inc) values (7, 'Twitter', 'LLC');\nInsert into PersonTable (id, firm_id, lastName, firstName, age) values (1, 3, 'X1', 'Mauricio', 20);\nInsert into PersonTable (id, firm_id, lastName, firstName, age) values (2, 3, 'X2', 'An', 20);\nInsert into PersonTable (id, firm_id, lastName, firstName, age) values (3, 3, 'X3', 'Anne', 20);\nInsert into PersonTable (id, firm_id, lastName, firstName, age) values (4, 3, 'X4', 'Gayathri', 20);\nInsert into PersonTable (id, firm_id, lastName, firstName, age) values (5, 3, 'X5', 'Yannan', 20);\nInsert into PersonTable (id, firm_id, lastName, firstName, age) values (6, 3, 'X6', 'Dave', 20);\nInsert into PersonTable (id, firm_id, lastName, firstName, age) values (7, 3, 'X7', 'Mo', 20);\nInsert into PersonTable (id, firm_id, lastName, firstName, age) values (8, 3, 'X8', 'Teddy', 20);\nInsert into PersonTable (id, firm_id, lastName, firstName, age) values (9, 7, 'X8', 'Test1', 20);\nInsert into PersonTable (id, firm_id, lastName, firstName, age) values (10, 7, 'X8', 'Test2', 20);\nInsert into PersonTable (id, firm_id, lastName, firstName, age) values (11, 7, 'X8', 'Test2', 20);\nInsert into PersonTable (id, firm_id, lastName, firstName, age) values (12, 7, 'X8', 'Test3', 20);\nInsert into PersonTable (id, firm_id, lastName, firstName, age) values (13, 7, 'X8', 'Test4', 20);\nInsert into PersonTable (id, firm_id, lastName, firstName, age) values (14, 7, 'X8', 'Test5', 20);\nInsert into PersonTable (id, firm_id, lastName, firstName, age) values (15, 7, 'X8', 'Test6', 20);\nInsert into PersonTable (id, firm_id, lastName, firstName, age) values (16, 7, 'X8', 'Test7', 20);\nInsert into PersonTable (id, firm_id, lastName, firstName, age) values (17, 7, 'X8', 'Test8', 20);\nInsert into PersonTable (id, firm_id, lastName, firstName, age) values (18, 7, 'X8', 'Test9', 20);\nInsert into PersonTable (id, firm_id, lastName, firstName, age) values (19, 7, 'X8', 'Test10', 20);\nInsert into PersonTable (id, firm_id, lastName, firstName, age) values (20, 7, 'X8', 'Test11', 20);\nInsert into PersonTable (id, firm_id, lastName, firstName, age) values (21, 7, 'X8', 'Test12', 20);\nInsert into PersonTable (id, firm_id, lastName, firstName, age) values (22, 7, 'X8', 'Test13', 20);\nInsert into PersonTable (id, firm_id, lastName, firstName, age) values (23, 7, 'X8', 'Test14', 20);\nInsert into PersonTable (id, firm_id, lastName, firstName, age) values (24, 7, 'X8', 'Test15', 20);\nInsert into PersonTable (id, firm_id, lastName, firstName, age) values (25, 7, 'X8', 'Test16', 20);\nInsert into PersonTable (id, firm_id, lastName, firstName, age) values (26, 7, 'X8', 'Test17', 20);\nInsert into PersonTable (id, firm_id, lastName, firstName, age) values (27, 7, 'X8', 'Test18', 20);\nInsert into PersonTable (id, firm_id, lastName, firstName, age) values (28, 7, 'X8', 'Test19', 20);\nInsert into PersonTable (id, firm_id, lastName, firstName, age) values (29, 7, 'X8', 'Test20', 20);\nInsert into PersonTable (id, firm_id, lastName, firstName, age) values (30, 7, 'X8', 'Test21', 20);\nInsert into PersonTable (id, firm_id, lastName, firstName, age) values (31, 7, 'X8', 'Test22', 20);\nInsert into PersonTable (id, firm_id, lastName, firstName, age) values (32, 7, 'X8', 'Test23', 20);\nInsert into PersonTable (id, firm_id, lastName, firstName, age) values (33, 7, 'X8', 'Test24', 20);\nInsert into PersonTable (id, firm_id, lastName, firstName, age) values (34, 7, 'X8', 'Test25', 20);\nInsert into PersonTable (id, firm_id, lastName, firstName, age) values (35, 7, 'X8', 'Test26', 20);\nInsert into PersonTable (id, firm_id, lastName, firstName, age) values (36, 7, 'X8', 'Test27', 20);\nInsert into PersonTable (id, firm_id, lastName, firstName, age) values (37, 7, 'X8', 'Test28', 20);\nInsert into PersonTable (id, firm_id, lastName, firstName, age) values (38, 7, 'X8', 'Test29', 20);\nInsert into PersonTable (id, firm_id, lastName, firstName, age) values (39, 7, 'X8', 'Test30', 20);\nInsert into PersonTable (id, firm_id, lastName, firstName, age) values (40, 7, 'X8', 'Test31', 20);\nInsert into PersonTable (id, firm_id, lastName, firstName, age) values (41, 7, 'X8', 'Test32', 20);\nInsert into PersonTable (id, firm_id, lastName, firstName, age) values (42, 7, 'X8', 'Test33', 20);\nInsert into PersonTable (id, firm_id, lastName, firstName, age) values (43, 7, 'X8', 'Test34', 20);\nInsert into PersonTable (id, firm_id, lastName, firstName, age) values (44, 7, 'X8', 'Test35', 20);\nInsert into PersonTable (id, firm_id, lastName, firstName, age) values (45, 7, 'X8', 'Test36', 20);\nInsert into PersonTable (id, firm_id, lastName, firstName, age) values (46, 7, 'X8', 'Test36', 20);\n\n\n"]},"element":"model::MyDatabase","quoteIdentifiers":false,"type":"H2"},"name":"MyConnection","package":"model"}]},"runtime":{"_type":"runtimePointer","runtime":"model::Runtime"},"context":{"_type":"BaseExecutionContext","queryTimeOutInSeconds":null,"enableConstraints":true},"parameterValues":[{"name":"var_1","value":{"_type":"strictDate","value":"2023-05-04"}}],"hashStrings":true,"parameters":[]}

@irisyngao irisyngao force-pushed the testDataGen branch 2 times, most recently from 619f024 to 9f74ea1 Compare May 23, 2023 19:23
Copy link
Member

@MauricioUyaguari MauricioUyaguari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small comment

const connection = guaranteeNonNullable(
this.resolveConnectionValue(this.connectionData.connectionId),
`Unable to resolve connection ID '${this.connectionData.connectionId}`,
// NOTE: since we don't have a generic mechanism for test-data generation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this api call takes a bit of time. we should be adding generatingTestDataSate to keep track of that and show loading indicator

@MauricioUyaguari MauricioUyaguari merged commit 85c8e5a into finos:master May 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Application: Studio Issues related to Legend Studio application Extension: DSL Service
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants