Page MenuHomePhabricator

[services] Tunnelbroker - Database SessionItem tests
ClosedPublic

Authored by max on Apr 11 2022, 3:34 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Jul 4, 11:27 AM
Unknown Object (File)
Mon, Jul 1, 9:34 AM
Unknown Object (File)
Sat, Jun 29, 10:38 PM
Unknown Object (File)
Sat, Jun 29, 10:38 PM
Unknown Object (File)
Sat, Jun 29, 10:37 PM
Unknown Object (File)
Sat, Jun 29, 10:37 PM
Unknown Object (File)
Sat, Jun 29, 10:37 PM
Unknown Object (File)
Sat, Jun 29, 10:37 PM

Details

Summary

Database (DynamoDB) item tests. For the SessionItem database entity we perform:

  • Check if the table is available,
  • Create and fulfill database item entity,
  • Put into the database table,
  • Find the record using the primary key,
  • Compare record fields of created item and item from database record,
  • Remove the testing record from the database.

Related linear task: ENG-686

Test Plan

Run yarn test-tunnelbroker-service all tests are run and succeed.

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

max retitled this revision from [services] Tunnelbroker - Database SessionItem tests. to [services] Tunnelbroker - Database SessionItem tests.Apr 11 2022, 3:35 AM
max edited the summary of this revision. (Show Details)
max added reviewers: varun, tomek, karol.
tomek requested changes to this revision.Apr 11 2022, 5:01 AM

We also need to clarify our approach to randomness in D3654

services/tunnelbroker/test/DatabaseManagerTest.cpp
44–49 ↗(On Diff #11273)

It's always better to use functions provided by the testing framework, as in case of failure, they provide a lot more useful messages. So in this case, if we wanted to compare char* it would be better to use a combination of ASSERT_THAT and ElementsAre matcher... but in this case there's no need for that. We want to compare item.getDeviceID so why would we want to extract bytes from it? Can't we just compare strings?

BTW, your solution would not fail if item.getDeviceID() was a prefix of foundItem->getDeviceID() because we're comparing only item.getDeviceID().size() bytes.

This revision now requires changes to proceed.Apr 11 2022, 5:01 AM
max marked an inline comment as done.

Switch from memcmp to a simple EQ.

services/tunnelbroker/test/DatabaseManagerTest.cpp
44–49 ↗(On Diff #11273)

It's always better to use functions provided by the testing framework, as in case of failure, they provide a lot more useful messages. So in this case, if we wanted to compare char* it would be better to use a combination of ASSERT_THAT and ElementsAre matcher... but in this case there's no need for that. We want to compare item.getDeviceID so why would we want to extract bytes from it? Can't we just compare strings?

BTW, your solution would not fail if item.getDeviceID() was a prefix of foundItem->getDeviceID() because we're comparing only item.getDeviceID().size() bytes.

This is a good catch! Switched to simple EQ.

Switching to the Plan changes until we clarify the random/non-random value for tests.

Added tests with static variables along with generated ones following D3654#102087.

Verbose output for generated values in case of failure was added.

This revision is now accepted and ready to land.Apr 19 2022, 2:28 AM