Top Banner
Rapid Data Modeling and Testing AARON BENTON
61

Rapid Data Modeling and Testing with FakeIt

Jan 23, 2018

Download

Technology

Aaron Benton
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Rapid Data Modeling and Testing with FakeIt

Rapid Data Modeling and Testing

AARON BENTON

Page 2: Rapid Data Modeling and Testing with FakeIt

bit.ly/cbcommunity

Page 3: Rapid Data Modeling and Testing with FakeIt
Page 4: Rapid Data Modeling and Testing with FakeIt

+

Page 5: Rapid Data Modeling and Testing with FakeIt
Page 6: Rapid Data Modeling and Testing with FakeIt

OUR CAPABILITIES

6

Page 7: Rapid Data Modeling and Testing with FakeIt

Enthusiasm Disillusionment Panic

Search for the Guilty

Punishment of the Innocent

Praise for Non-Participants

Page 8: Rapid Data Modeling and Testing with FakeIt

First, solve the problem. Then, write the code.“ ”John Johnson

Page 9: Rapid Data Modeling and Testing with FakeIt

Data Modeling

Page 10: Rapid Data Modeling and Testing with FakeIt

Phases• Conceptual • Logical • Physical

Page 11: Rapid Data Modeling and Testing with FakeIt

Conceptual Data Modeling

Entity NamesEntity Relationships

Users Products

Line Items

Orders

Page 12: Rapid Data Modeling and Testing with FakeIt

N 1Person Birthplace Location Person Location

Born In

Birthplace of

Person Location(1, 1) Born In

Birthplace of (0, N)

<< Entity >> Person

0. .N

1

<< Entity >> Location

<< Relationship >>Born in >

< Birthplace of

Chen

Person LocationIDEF1x

Person LocationBorn In

Birthplace of

Bachman

Crow's Foot

ISO

UML

Page 13: Rapid Data Modeling and Testing with FakeIt

Logical Data Modeling

Entity NamesEntity AttributesEntity Relationships

UsersUser ID (PK)

Username

Password

First Name

Last Name

Address

City

State

Zip Code

Country

Email

Phone

OrdersOrder ID (PK)

Order Number

User ID (FK)

Order Date

Address

City

State

Zip Code

Country

Phone

Email

Credit Card

Expiration Date

Order Line ItemsOrder ID (FK)

Product ID (FK)

Quantity

Total

ProductsProduct ID (PK)

Product Name

Description

Price

Page 14: Rapid Data Modeling and Testing with FakeIt

Physical Data ModelingEntity Names -> Table NamesEntity Attributes -> Field NamesEntity Relationships -> Keys Data Types

Page 15: Rapid Data Modeling and Testing with FakeIt

NoSql Modeling• How do you represent a model? • What tools do you use? • How do you show relationships? • Does code define the model? • What key patterns should be used?

Page 16: Rapid Data Modeling and Testing with FakeIt

JSON

Page 17: Rapid Data Modeling and Testing with FakeIt

JSON Schema

Page 18: Rapid Data Modeling and Testing with FakeIt

YAML

Page 19: Rapid Data Modeling and Testing with FakeIt

Now What?

Page 20: Rapid Data Modeling and Testing with FakeIt

20

Page 21: Rapid Data Modeling and Testing with FakeIt
Page 22: Rapid Data Modeling and Testing with FakeIt
Page 23: Rapid Data Modeling and Testing with FakeIt

Fake Data Generators• FakerJS • ChanceJS • json-generator.com • objgen.com/json • mockaroo.com • jsonschema.net

Page 24: Rapid Data Modeling and Testing with FakeIt

Relationships are Hard

Page 25: Rapid Data Modeling and Testing with FakeIt

FakeIT

Page 26: Rapid Data Modeling and Testing with FakeIt

Fakeit• CLI Tool inspired by Swagger • Models defined in YAML • Generates JSON, CSON, YAML, CSV • Exports to Couchbase, Sync Gateway, Zip,

Console

Page 27: Rapid Data Modeling and Testing with FakeIt

Fakeit Data• Exposes FakerJS and ChanceJS • Custom Build Functions w/ Pre and Post • Multiple Models • Dependencies • Definitions

*fakeit is for structure, cbworkloadgen is for sizing

Page 28: Rapid Data Modeling and Testing with FakeIt

npm install fakeit -g

Page 29: Rapid Data Modeling and Testing with FakeIt

Original YAML Model

Page 30: Rapid Data Modeling and Testing with FakeIt

Simple Model

30

Data Attribute

Page 31: Rapid Data Modeling and Testing with FakeIt

Console Output

Page 32: Rapid Data Modeling and Testing with FakeIt

File Output

Page 33: Rapid Data Modeling and Testing with FakeIt

Output Formats

Page 34: Rapid Data Modeling and Testing with FakeIt

CSV Output

Page 35: Rapid Data Modeling and Testing with FakeIt

Zip Archive

Page 36: Rapid Data Modeling and Testing with FakeIt

. . . ?

Page 37: Rapid Data Modeling and Testing with FakeIt

Couchbase

Page 38: Rapid Data Modeling and Testing with FakeIt

What about Mobile…?

Page 39: Rapid Data Modeling and Testing with FakeIt

Sync Gateway

Page 40: Rapid Data Modeling and Testing with FakeIt

Sync Gateway with Auth

Page 41: Rapid Data Modeling and Testing with FakeIt

How does it Work?

Page 42: Rapid Data Modeling and Testing with FakeIt

Property Data:

value

• A static value to be used • Executed at build time

fake

• A FakerJS template string • Executed at build time

pre_build

• Function body used to initialize a property

• Property is set to the returned value

build

• Function body used to set a property

• Property is set to the returned value

post_build

• Function body used to manipulate a property after it has been set

• Property is set to the returned value

pre_run

• Function body that is executed before any models are generated

post_run

• Function body that is executed before after all models have been generated

Page 43: Rapid Data Modeling and Testing with FakeIt
Page 44: Rapid Data Modeling and Testing with FakeIt

FlowModel

Pre_RUNModel

PRE_BUILD

Initialize Property

Value (EACH)

Start Document

Run

Property PRE_BUILD +

BUILD (EACH)

PROPERTY POST_BUILD

(EACH)

MODEL POST_BUILD

MODEL POST_RUN

Page 45: Rapid Data Modeling and Testing with FakeIt

Flow

Page 46: Rapid Data Modeling and Testing with FakeIt

Flow

Page 47: Rapid Data Modeling and Testing with FakeIt

Multiple Models

Page 48: Rapid Data Modeling and Testing with FakeIt

Multiple Models

Page 49: Rapid Data Modeling and Testing with FakeIt

Dependencies

Users Products Reviews Orders

Page 50: Rapid Data Modeling and Testing with FakeIt

Dependencies

Page 51: Rapid Data Modeling and Testing with FakeIt

Dependencies

Page 52: Rapid Data Modeling and Testing with FakeIt

Definitions

Page 53: Rapid Data Modeling and Testing with FakeIt

Definitions

Page 54: Rapid Data Modeling and Testing with FakeIt
Page 55: Rapid Data Modeling and Testing with FakeIt

continents.json countries.csv

Input

Page 56: Rapid Data Modeling and Testing with FakeIt

continents.json countries.csv

Input

Page 57: Rapid Data Modeling and Testing with FakeIt

How we use FakeIt• YAML models store in the repository • Make commands to generate data • Docker Compose:

• Nginx • Couchbase • Sync Gateway

• Testing / QA

Page 58: Rapid Data Modeling and Testing with FakeIt

Demos

Page 59: Rapid Data Modeling and Testing with FakeIt

Fakeit Examples• Contacts • Ecommerce • Flat • Flight Data • Music • Simple • Social

github.com/bentonam/fakeit-examples

Page 60: Rapid Data Modeling and Testing with FakeIt

Questions?

Page 61: Rapid Data Modeling and Testing with FakeIt

HOW TO CONTACT MEDon’t hesitate to contact with me. I will be happy to answer your questions.

TWITTER: @bentonam

github.com/bentonam

EMAIL: [email protected]

THANK YOU