📺 Develpreneur YouTube Episode

Video + transcript

DB Testing And Automation: Part 3

2022-03-22 •Youtube

Detailed Notes

Database testing is fraught with challenges. We have to find new ways to create a database replica, match the data in size and meaning as well as validate changes. These obstacles add up to this sort of testing requires automation and careful consideration. In this session, we look at the pitfalls and ways to properly test and validate your database.

Database Testing And Automation We cover this topic through looking at the issues, looking at the basic tools, and then what automation is needed. The discussion stays surface level and does not go deep into any specific tools. That way you can find this presentation useful no matter which database or environment you find your self facing.

The Mentor-Mastermind Group This series comes from our mentoring/mastermind classes. These classes are virtual meetings that focus on how to improve our technical skills and build our businesses. The goals of each member vary. However, this diversity makes for great discussions and a ton of educational value every time we meet. We hope you enjoy viewing this series as much as we enjoy creating it. As always, this may not be all new to you, but we hope it helps you be a better developer. Drop us a line to find out when the next one is so you can join our group.

Transcript Text
[Music]
so key steps if you're trying to test a
database
some of the key things that we've
already started talked about but i want
to make sure that
we laid these out in a little shorter
sort of summary
you need to verify that the data and
require relationships are correct
so again the idea of if i save something
i want to be able to load it back and
it be the same what i what i save i need
to be able to get the same thing back in
a load
we need to test the key the three key
actions are creating updating and
deleting data so those need to be in our
mind as we are testing
is what happens when i create a record
if it's
if that's feasible if that's possible
what happens when i update a record if
that's possible and what happens when i
delete data that's possible
and deleting
can be a little bit of a challenge
because in some cases
it deletes and removes that data in some
cases we just have some sort of a value
like a you know is deleted flag that you
have to check to see whether the data
was technically deleted or not
uh or maybe like an active flag or
something like that so deleting maybe
actually remove the data but it may also
be just marking data accordingly
from a testing point of view
it doesn't matter too much other than
you just need to know what does a
deleted record
look like or i guess not look like if it
doesn't exist
once we run our tests we need to be able
to have some way to clean up
so that we can
that we're not doing essentially damage
to the data we're
doing our testing
and then the challenge that often is
reproducing those tests is building our
regression scripts
sometimes we can do those within
uh normal means like maybe a web
interface we can use like a selenium or
something like that
sometimes we're going to have to write
code down at the
whatever level it is you know whether
it's a c sharp app or java app or maybe
even within the database itself we may
have some scripts that are run
that essentially go through and
for example in some cases
you have scripts that
your test user ids
are
known or you're consistent with those
and so this there's a script that you
can run after your test that goes out
and finds everything that was touched by
those user ids and cleans it all up
and varies from from situation situation
but
that's again where
you know it's just it's a little bit
extra challenge for the database to
to get those regression pieces done it's
not just regression against your test
but now i need to be able to do a
regression of cleaning up
again i got to mention if you could just
do an image restore so just back it up
run your test and then restore the
backup
that's
that's like ideal that's going to be the
easiest way to ensure that you didn't
miss something
going through a whole bunch we've had
already some good questions and comments
along the way but now i want to open it
up for anything else questions comments
on this
this might not be related to this topic
here but um
since i'm working with the database
do that the dba the database
administrators
uh
can they write
sql or can i mean are they very good
with the volume or vice verse candy sql
developer be a dba
uh
they can be sometime but it tends to the
those two roles
tend to be slightly different typically
a database developer
both of them are going to be able to
write sql
probably quite a bit of it database
developers are more likely going to be
able to
work with saving and loading and
updating
data dbas
are more about
being able to create the structures you
create a table
sometimes they're they're the ones that
really do the creation of triggers and
constraints
where database developers may create
stored procedures
okay dbas
often have more of the
actual database engine configuration
skills so they it's not just what's the
the logical database how you interact
with code but the physical database of
where does that
live on you know what server is that on
how is that actually configured within
the server and the storage
and so it's a
it's a little bit more of a dbas are a
little bit more of a configuration type
of job whereas the database developers
are more using the database
as opposed to dba that's creating the
database if that if that helps clarify
it maybe a little bit
okay
other questions and comments
thank you
excellent all right cool so we will move
here
so what do we learn hopefully ideally uh
one and i think we knew that it's one of
those things that
i don't know if we learned this i think
everybody sort of knows it at some level
from the start database testing has got
unique challenges it is different from
code
it's
as we've listed it out it's it's not the
same so being able to test the database
is a whole different
level or style of testing
we're often going to need to learn about
the requirements beyond just the records
of the data we've talked about all these
relationships and constraints and
triggers and permissions and all that
kind of good stuff
that we're going to have to
make sure that the requirements are
you know cover those that they
are at that level of detail
if we can use images with stage images
or testing or whatever you want to call
them
of the database itself
database snapshots
if we use those they're gonna be a lot
easier for us to
uh to restore and then
keep our fingerprints off of the
database
in the world of cloud that is
it can be expensive but sometimes that's
a nice thing is that there's it's easier
to spin up uh just like it is virtual
machines it's easier to spin up a
replica replication of that database
that you can go test and then you can
just drop it delete it when you're done
there's a lot of scripting that we can
use as part of dealing with
our our database testing
but
we need to
be thorough about it we need to remember
that when i write a script i'm making
these changes and i need to be able to
unmake them
uh and or clean up afterwards and also i
need to be which is
really just dealing with databases in
general we need to make sure that we are
particularly with the script we're
affecting or impacting the things only
that we want to impact
um it's
you know this is a little bit of really
more database developer vba kinds of
concerns but you know if you delete a
record you don't want to delete all the
records in the table you've got usually
you know a specific record or specific
types of records that you want to delete
in database testing is the same thing as
we need to be very aware of the impact
and the scope of
a script or an action that we're
taking
as always thank you for your time for
for listening for
you know the questions the feedback
if you have any others as you know we
always do at two in the morning you
sometimes have that thought that says oh
rats i wanted to ask this question
you can reach us you can send us an
email at info developer.com
you can put a
form entry for the contact us out on
developer.com you can always check us
out follow us tweet us whatever at
developerdoor out on twitter
and then we do still have a facebook
page facebook.com developer norm
we just want to keep working on these
things spending our time investing time
getting together
so that every we can make every
developer better uh everybody wants to
join us uh whether it's us or those that
we work we want to make everybody a
little bit better
thanks a lot
so dave in particular because you
mention this is that was this was that a
helpful that was sort of the kind of
thing you were hoping to to get that
sort of a presentation oh yeah yeah
definitely yeah i i think it gives me a
broader view about
what goes into the database and
yeah
okay good that was that was like i said
you were sort of the primary customer
for that so i want to make sure that
that did cover so some of the stuff that
you were looking to get to yeah he did
he did
good listen
are we good for the next one to be
two weeks it'll be february the 5th
yeah um february what the fifth yep yeah
i'm good i'm good with that and i think
we get to
[Music]
michael is doing
uh
now that we have our handy dandy
schedule here
so that's how you get rest assured i
think is an extra one we've got on our
list there
now i was going to ask you are you going
to do
um
i mean
do another series on database testing
like um i mean the approach because i
know usually as a test i usually i end
up getting uh just only the view view
access
yeah there's
we'll probably touch that a little bit
i'm gonna get into
and that's not going to come from and
it'll be a few weeks where it starts
showing up okay there's going to be a
youtube series that will be it's
basically it's on really focused on
database development and there's going
to be some of the there's going to be
some scripting and some automation and
some things like that that will be
part of those uh that series
um
i'm trying to think
i'm not sure where else we've actually
spent much time in it so that's probably
gonna be the first time we have some we
go a little deeper into
some of those pieces
but that and i'll mention that as we get
you know closer into that so probably
the next or maybe
two mentor sessions out it's probably
about the time that we'll start seeing
that
okay
and you're good for doing the rest of
shirt next time right michael i think
you said you're pretty close on that
yeah i should be ready for that um
also
i think if you go back to building the
product catalog i think i had some
database examples in there
i think you did
i think if you go back yeah building a
beta database
uh what do we call that but it's
basically that those go way back those
are out on vimeo they're also on you can
probably search
um
i think it was the
if you go look at like the become a
better developer oh here it is build a
picture yeah build a product
okay if you go look at that one then
you'll see that we had um
yeah there we go is that there's a whole
series and it included i think there was
like one
[Music]
uh testing our application but i think
there was one contest in the database as
well
um
yeah so there's a couple that are
specifically related to that data so
that may help you as well
david
by the way i apparently my mic hiccup
during the presentation i had a quick
comment on when you were talking about
the timestamp
so one thing to be careful of when
dealing with dates and times especially
with databases so when you store your
date into the database you need to be
conscious of or at least have your
requirements as to what
date time and time zone if you're
dealing with us-based dates
because if you just store the date and
then pull the date out
and try to display it if you're in a
different time zone if you're not
converting that date properly the
date that you're storing or the date
that you're pointing out is not going to
match
yeah and that's actually that's that's a
good point and that's not even that's
not just us that's just any time zone
data is making sure that the
the conversions as needed or are done
accordingly because you may have and
particularly this goes with
cloud computing
you may save your date you may have two
different servers that things get saved
on and if they if there isn't you know
utc time or something to tie those
stamps together
then it can break some of your that's
that's one of the relationships the data
integrity issues you have to worry about
is making sure that if i have a
time stamp on one record that says that
i did it at nine o'clock today then the
other record
should also say that that update was
done at nine o'clock today not at you
know ten o'clock or eight o'clock or
something like that which you can run
into when you don't have
uh consistent timestamp zones across the
data
and more and more you're seeing that it
will happen is the data will be stored
in utc time
and then the uh
the loads will convert data or the
display
will convert it to your whatever your
specific time zone is so good point time
is one of those
time stamps uh dates and times is
one of the common
data issues that you run into or
confusions you run into
yeah we're dealing with that at work
right now
yeah that's a that's again it's a good
point definitely one that we run into on
a regular basis
any other questions comments anything
else we want to talk about
going once going twice well excellent
then we
basically on time
and uh we'll wrap this one up and we'll
talk to you guys again in a couple weeks
you
Transcript Segments
0.48

[Music]

29.199

so key steps if you're trying to test a

32.239

database

33.52

some of the key things that we've

35.12

already started talked about but i want

36.32

to make sure that

37.52

we laid these out in a little shorter

39.36

sort of summary

41.76

you need to verify that the data and

44

require relationships are correct

46.8

so again the idea of if i save something

49.28

i want to be able to load it back and

52.399

it be the same what i what i save i need

55.199

to be able to get the same thing back in

56.719

a load

57.68

we need to test the key the three key

59.92

actions are creating updating and

61.52

deleting data so those need to be in our

63.68

mind as we are testing

66.08

is what happens when i create a record

68

if it's

69.119

if that's feasible if that's possible

70.799

what happens when i update a record if

72.24

that's possible and what happens when i

74.08

delete data that's possible

76

and deleting

78.4

can be a little bit of a challenge

80.08

because in some cases

82.4

it deletes and removes that data in some

85.2

cases we just have some sort of a value

87.439

like a you know is deleted flag that you

90.24

have to check to see whether the data

92.56

was technically deleted or not

94.88

uh or maybe like an active flag or

96.799

something like that so deleting maybe

98.64

actually remove the data but it may also

100.64

be just marking data accordingly

103.2

from a testing point of view

104.96

it doesn't matter too much other than

106.799

you just need to know what does a

108.32

deleted record

109.84

look like or i guess not look like if it

111.759

doesn't exist

114.079

once we run our tests we need to be able

116.32

to have some way to clean up

118.399

so that we can

120.24

that we're not doing essentially damage

122.719

to the data we're

124.56

doing our testing

127.2

and then the challenge that often is

129.28

reproducing those tests is building our

131.2

regression scripts

133.2

sometimes we can do those within

135.52

uh normal means like maybe a web

137.92

interface we can use like a selenium or

139.68

something like that

140.959

sometimes we're going to have to write

142.16

code down at the

143.68

whatever level it is you know whether

145.28

it's a c sharp app or java app or maybe

147.92

even within the database itself we may

149.76

have some scripts that are run

152.959

that essentially go through and

155.68

for example in some cases

157.44

you have scripts that

159.28

your test user ids

161.599

are

162.64

known or you're consistent with those

164.48

and so this there's a script that you

166.08

can run after your test that goes out

168.16

and finds everything that was touched by

170

those user ids and cleans it all up

173.92

and varies from from situation situation

177.2

but

178.239

that's again where

179.84

you know it's just it's a little bit

181.04

extra challenge for the database to

183.28

to get those regression pieces done it's

185.44

not just regression against your test

187.76

but now i need to be able to do a

189.519

regression of cleaning up

191.84

again i got to mention if you could just

193.68

do an image restore so just back it up

196.159

run your test and then restore the

197.599

backup

198.72

that's

199.599

that's like ideal that's going to be the

201.04

easiest way to ensure that you didn't

203.519

miss something

207.44

going through a whole bunch we've had

208.879

already some good questions and comments

210.72

along the way but now i want to open it

212.64

up for anything else questions comments

215.84

on this

219.519

this might not be related to this topic

221.28

here but um

222.64

since i'm working with the database

225.44

do that the dba the database

228.239

administrators

230.48

uh

231.36

can they write

233.2

sql or can i mean are they very good

235.84

with the volume or vice verse candy sql

239.04

developer be a dba

242.64

uh

244.64

they can be sometime but it tends to the

249.76

those two roles

251.2

tend to be slightly different typically

254.72

a database developer

256.479

both of them are going to be able to

257.359

write sql

258.72

probably quite a bit of it database

260.56

developers are more likely going to be

262.479

able to

263.84

work with saving and loading and

265.759

updating

266.84

data dbas

269.199

are more about

270.88

being able to create the structures you

272.88

create a table

274.639

sometimes they're they're the ones that

276.08

really do the creation of triggers and

278.479

constraints

279.919

where database developers may create

281.759

stored procedures

283.52

okay dbas

285.44

often have more of the

288.24

actual database engine configuration

290.479

skills so they it's not just what's the

293.12

the logical database how you interact

295.44

with code but the physical database of

297.759

where does that

299.36

live on you know what server is that on

301.52

how is that actually configured within

303.36

the server and the storage

305.68

and so it's a

307.919

it's a little bit more of a dbas are a

310.08

little bit more of a configuration type

312.24

of job whereas the database developers

314.88

are more using the database

317.44

as opposed to dba that's creating the

319.759

database if that if that helps clarify

322.24

it maybe a little bit

326

okay

328.72

other questions and comments

333.36

thank you

335.36

excellent all right cool so we will move

338.96

here

340.56

so what do we learn hopefully ideally uh

343.28

one and i think we knew that it's one of

345.199

those things that

346.4

i don't know if we learned this i think

347.6

everybody sort of knows it at some level

349.199

from the start database testing has got

351.44

unique challenges it is different from

354.16

code

355.6

it's

357.199

as we've listed it out it's it's not the

359.919

same so being able to test the database

361.84

is a whole different

363.44

level or style of testing

367.039

we're often going to need to learn about

368.4

the requirements beyond just the records

370.16

of the data we've talked about all these

371.919

relationships and constraints and

374.08

triggers and permissions and all that

375.84

kind of good stuff

377.199

that we're going to have to

379.12

make sure that the requirements are

381.28

you know cover those that they

383.039

are at that level of detail

386.24

if we can use images with stage images

388.72

or testing or whatever you want to call

390.319

them

391.039

of the database itself

393.52

database snapshots

395.6

if we use those they're gonna be a lot

396.88

easier for us to

398.8

uh to restore and then

401.44

keep our fingerprints off of the

403.36

database

404.72

in the world of cloud that is

406.72

it can be expensive but sometimes that's

408.4

a nice thing is that there's it's easier

410.56

to spin up uh just like it is virtual

412.96

machines it's easier to spin up a

414.72

replica replication of that database

417.759

that you can go test and then you can

419.28

just drop it delete it when you're done

423.039

there's a lot of scripting that we can

424.72

use as part of dealing with

427.919

our our database testing

430.4

but

431.199

we need to

432.4

be thorough about it we need to remember

434.08

that when i write a script i'm making

436.4

these changes and i need to be able to

438.479

unmake them

440

uh and or clean up afterwards and also i

443.599

need to be which is

445.28

really just dealing with databases in

446.96

general we need to make sure that we are

449.599

particularly with the script we're

450.96

affecting or impacting the things only

453.44

that we want to impact

455.68

um it's

457.52

you know this is a little bit of really

460.16

more database developer vba kinds of

462.84

concerns but you know if you delete a

465.36

record you don't want to delete all the

466.8

records in the table you've got usually

468.72

you know a specific record or specific

471.28

types of records that you want to delete

473.759

in database testing is the same thing as

476.24

we need to be very aware of the impact

479.919

and the scope of

481.84

a script or an action that we're

483.919

taking

487.919

as always thank you for your time for

490.08

for listening for

491.44

you know the questions the feedback

493.599

if you have any others as you know we

495.36

always do at two in the morning you

496.639

sometimes have that thought that says oh

499.36

rats i wanted to ask this question

502.24

you can reach us you can send us an

503.919

email at info developer.com

506.24

you can put a

508.08

form entry for the contact us out on

510.919

developer.com you can always check us

513.68

out follow us tweet us whatever at

515.68

developerdoor out on twitter

518.24

and then we do still have a facebook

519.68

page facebook.com developer norm

523.2

we just want to keep working on these

524.56

things spending our time investing time

526.56

getting together

527.839

so that every we can make every

529.519

developer better uh everybody wants to

532

join us uh whether it's us or those that

534.399

we work we want to make everybody a

536.24

little bit better

537.6

thanks a lot

545.04

so dave in particular because you

546.959

mention this is that was this was that a

549.12

helpful that was sort of the kind of

550.32

thing you were hoping to to get that

551.92

sort of a presentation oh yeah yeah

554.16

definitely yeah i i think it gives me a

557.12

broader view about

559.12

what goes into the database and

561.68

yeah

562.64

okay good that was that was like i said

564.56

you were sort of the primary customer

566

for that so i want to make sure that

567.76

that did cover so some of the stuff that

569.44

you were looking to get to yeah he did

571.279

he did

572.64

good listen

575.04

are we good for the next one to be

577.68

two weeks it'll be february the 5th

582.64

yeah um february what the fifth yep yeah

586.32

i'm good i'm good with that and i think

589.04

we get to

590.38

[Music]

591.76

michael is doing

594.16

uh

601.76

now that we have our handy dandy

604

schedule here

606.16

so that's how you get rest assured i

607.76

think is an extra one we've got on our

608.88

list there

610.16

now i was going to ask you are you going

611.36

to do

612.24

um

614.399

i mean

615.76

do another series on database testing

618

like um i mean the approach because i

620.24

know usually as a test i usually i end

622.48

up getting uh just only the view view

625.12

access

626.64

yeah there's

628.16

we'll probably touch that a little bit

629.68

i'm gonna get into

631.279

and that's not going to come from and

632.959

it'll be a few weeks where it starts

634.24

showing up okay there's going to be a

636.16

youtube series that will be it's

638.72

basically it's on really focused on

640.72

database development and there's going

642.8

to be some of the there's going to be

644

some scripting and some automation and

645.44

some things like that that will be

647.44

part of those uh that series

650.8

um

651.76

i'm trying to think

654.72

i'm not sure where else we've actually

656.16

spent much time in it so that's probably

657.6

gonna be the first time we have some we

659.36

go a little deeper into

661.6

some of those pieces

663.44

but that and i'll mention that as we get

665.76

you know closer into that so probably

668.56

the next or maybe

670.079

two mentor sessions out it's probably

673.12

about the time that we'll start seeing

674.399

that

675.36

okay

678.64

and you're good for doing the rest of

679.92

shirt next time right michael i think

681.279

you said you're pretty close on that

683.36

yeah i should be ready for that um

687.2

also

688.48

i think if you go back to building the

690.72

product catalog i think i had some

692.32

database examples in there

695.04

i think you did

696.399

i think if you go back yeah building a

697.76

beta database

700

uh what do we call that but it's

701.6

basically that those go way back those

704.24

are out on vimeo they're also on you can

706.56

probably search

708.079

um

714.24

i think it was the

715.76

if you go look at like the become a

717.44

better developer oh here it is build a

719.04

picture yeah build a product

720.88

okay if you go look at that one then

722.88

you'll see that we had um

725.76

yeah there we go is that there's a whole

727.6

series and it included i think there was

729.76

like one

730.51

[Music]

732.48

uh testing our application but i think

734.399

there was one contest in the database as

736.399

well

738.48

um

741.68

yeah so there's a couple that are

742.8

specifically related to that data so

744.48

that may help you as well

746.079

david

749.12

by the way i apparently my mic hiccup

752

during the presentation i had a quick

754.24

comment on when you were talking about

756.24

the timestamp

758.639

so one thing to be careful of when

760.88

dealing with dates and times especially

763.92

with databases so when you store your

768.079

date into the database you need to be

770.24

conscious of or at least have your

772.399

requirements as to what

774.16

date time and time zone if you're

776.8

dealing with us-based dates

779.12

because if you just store the date and

781.2

then pull the date out

783.92

and try to display it if you're in a

786.24

different time zone if you're not

787.6

converting that date properly the

790.16

date that you're storing or the date

791.839

that you're pointing out is not going to

793.2

match

794.16

yeah and that's actually that's that's a

795.76

good point and that's not even that's

796.959

not just us that's just any time zone

799.2

data is making sure that the

801.36

the conversions as needed or are done

804.32

accordingly because you may have and

806.24

particularly this goes with

807.839

cloud computing

809.68

you may save your date you may have two

810.959

different servers that things get saved

813.279

on and if they if there isn't you know

815.519

utc time or something to tie those

817.68

stamps together

819.04

then it can break some of your that's

821.36

that's one of the relationships the data

823.199

integrity issues you have to worry about

825.199

is making sure that if i have a

827.44

time stamp on one record that says that

830.24

i did it at nine o'clock today then the

833.04

other record

834.48

should also say that that update was

836.32

done at nine o'clock today not at you

838.32

know ten o'clock or eight o'clock or

839.76

something like that which you can run

841.04

into when you don't have

843.76

uh consistent timestamp zones across the

847.76

data

848.88

and more and more you're seeing that it

850.32

will happen is the data will be stored

852.8

in utc time

854.56

and then the uh

857.36

the loads will convert data or the

859.92

display

861.12

will convert it to your whatever your

863.279

specific time zone is so good point time

866.32

is one of those

868.079

time stamps uh dates and times is

870.959

one of the common

872.639

data issues that you run into or

874.88

confusions you run into

877.12

yeah we're dealing with that at work

879.12

right now

881.12

yeah that's a that's again it's a good

884.24

point definitely one that we run into on

886.24

a regular basis

888.959

any other questions comments anything

890.56

else we want to talk about

894.639

going once going twice well excellent

897.44

then we

898.639

basically on time

900.32

and uh we'll wrap this one up and we'll

902.639

talk to you guys again in a couple weeks

920.8

you