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

test: Add auto-doc generation #2051

Merged
merged 87 commits into from
Nov 27, 2023
Merged

test: Add auto-doc generation #2051

merged 87 commits into from
Nov 27, 2023

Conversation

islamaliev
Copy link
Contributor

@islamaliev islamaliev commented Nov 13, 2023

Relevant issue(s)

Resolves #1974

Description

This pull request introduces gen.AutoGenerateDocs function, a dynamic and versatile tool designed for the automatic generation of documents based on specified collection definitions. This functionality is essential for testing and simulating various data models and scenarios, providing extensive customization and intelligent demand calculation for document generation.

Key Features

Dynamic Document Generation: AutoGenerateDocs can generate documents adhering to a defined schema, interpreting types and relationships to create realistic, interconnected data structures.
Intelligent Demand Calculation: The function calculates the 'demand' for documents based on the configuration, adjusting the number of generated documents for consistency in relationships (e.g., one-to-one, one-to-many).
Flexible Configuration: Documents can be configured directly within the schema using annotations or via options passed to the function, with options taking precedence.
Customization Options: Includes capabilities like WithTypeDemand, WithFieldRange, WithFieldLen, WithFieldGenerator, and WithRandomSeed for extensive customization and deterministic output.

Additional Functionality: Generation of Predefined Documents

GenerateDocs Function: Allows the generation of predefined documents, considering only the fields present in the schema and ignoring any extra fields in the DocList.

Tasks

  • I made sure the code is well commented, particularly hard-to-understand areas.
  • I made sure the repository-held documentation is changed accordingly.
  • I made sure the pull request title adheres to the conventional commit style (the subset used in the project can be found in tools/configs/chglog/config.yml).
  • I made sure to discuss its limitations such as threats to validity, vulnerability to mistake and misuse, robustness to invalidation of assumptions, resource requirements, ...

How has this been tested?

Unit and integration tests.

Specify the platform(s) on which this was tested:

  • MacOS

@islamaliev islamaliev self-assigned this Nov 14, 2023
@islamaliev islamaliev added the area/testing Related to any test or testing suite label Nov 14, 2023
tests/gen/README.md Outdated Show resolved Hide resolved
Copy link

codecov bot commented Nov 14, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (d7e00d1) 73.89% compared to head (26ef63c) 73.83%.

❗ Current head 26ef63c differs from pull request most recent head 117a463. Consider uploading reports for the commit 117a463 to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2051      +/-   ##
===========================================
- Coverage    73.89%   73.83%   -0.06%     
===========================================
  Files          248      248              
  Lines        24808    24820      +12     
===========================================
- Hits         18330    18324       -6     
- Misses        5218     5231      +13     
- Partials      1260     1265       +5     
Flag Coverage Δ
all-tests 73.83% <100.00%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
client/descriptions.go 75.90% <100.00%> (+5.48%) ⬆️

... and 5 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d7e00d1...117a463. Read the comment docs.

tests/gen/gen_auto.go Outdated Show resolved Hide resolved
tests/gen/gen_auto.go Outdated Show resolved Hide resolved
@jsimnz
Copy link
Member

jsimnz commented Nov 20, 2023

Haven't done a full review (and merging this isn't dependent on my review). Just want to chime in and say this looks really nice! Should really expand the kinds of tests we can write, without being exceedingly laborious/tedious. Additionally when we re-enable the benchmarks, can also be a really great data generation for that as well.

Cool shit!

Copy link
Contributor

@AndrewSisley AndrewSisley left a comment

Choose a reason for hiding this comment

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

I really like this, so please don't think otherwise based on the number of comments. I'm only part way through my review and will continue after the standup.

client/descriptions.go Outdated Show resolved Hide resolved
tests/gen/README.md Outdated Show resolved Hide resolved
tests/gen/README.md Outdated Show resolved Hide resolved
tests/gen/README.md Outdated Show resolved Hide resolved
tests/gen/README.md Show resolved Hide resolved
tests/gen/gen_auto.go Outdated Show resolved Hide resolved
tests/gen/gen_auto.go Outdated Show resolved Hide resolved
tests/gen/gen_auto.go Outdated Show resolved Hide resolved
tests/gen/gen_auto.go Outdated Show resolved Hide resolved
tests/gen/gen_auto.go Outdated Show resolved Hide resolved
tests/gen/gen_auto.go Outdated Show resolved Hide resolved
Copy link
Contributor

@AndrewSisley AndrewSisley left a comment

Choose a reason for hiding this comment

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

Still working my way though, but submitting comments so far

tests/gen/gen_auto.go Outdated Show resolved Hide resolved
tests/gen/gen_auto.go Outdated Show resolved Hide resolved
tests/gen/gen_auto.go Outdated Show resolved Hide resolved
tests/gen/gen_auto.go Show resolved Hide resolved
tests/gen/gen_auto.go Show resolved Hide resolved
Copy link
Contributor

@AndrewSisley AndrewSisley left a comment

Choose a reason for hiding this comment

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

I really like this, but I think the code needs a bit more documentation before it can be merged.

Please comment against any comment/discussion-threads you resolve, it makes it much easier for me to tell what (if anything) has been done to resolve them.

tests/gen/gen_predefined.go Outdated Show resolved Hide resolved
tests/gen/gen_predefined.go Outdated Show resolved Hide resolved
tests/integration/test_case.go Outdated Show resolved Hide resolved
tests/gen/schema_parser.go Outdated Show resolved Hide resolved
tests/gen/schema_parser.go Outdated Show resolved Hide resolved
Copy link
Contributor

@AndrewSisley AndrewSisley left a comment

Choose a reason for hiding this comment

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

LGTM, thanks a bunch Islam! :)

@islamaliev islamaliev merged commit 8d8e111 into develop Nov 27, 2023
29 of 30 checks passed
@islamaliev islamaliev deleted the test/islam/doc-generation branch November 27, 2023 20:45
shahzadlone pushed a commit to shahzadlone/defradb that referenced this pull request Jan 22, 2024
## Relevant issue(s)

Resolves sourcenetwork#1974

## Description

This pull request introduces `gen.AutoGenerateDocs` function, a dynamic
and versatile tool designed for the automatic generation of documents
based on specified collection definitions. This functionality is
essential for testing and simulating various data models and scenarios,
providing extensive customization and intelligent demand calculation for
document generation.
shahzadlone pushed a commit to shahzadlone/defradb that referenced this pull request Feb 23, 2024
## Relevant issue(s)

Resolves sourcenetwork#1974

## Description

This pull request introduces `gen.AutoGenerateDocs` function, a dynamic
and versatile tool designed for the automatic generation of documents
based on specified collection definitions. This functionality is
essential for testing and simulating various data models and scenarios,
providing extensive customization and intelligent demand calculation for
document generation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/testing Related to any test or testing suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Random doc generation based on GraphQL schema
4 participants