Skip to content

This is an experiment on how changing dependency versions can break your codebase. It uses the aerospike npm module as an example.

Notifications You must be signed in to change notification settings

anikeshk/aerospike-boolean-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

aerospike-boolean-example

This is an experiment on how changing dependency versions can break your codebase.

You can read the full article here - https://anikeshk.com/breaking-changes-breaking-projects

This experiment targets the aerospike Node.js module version 3.16.3, which introduced the boolean datatype for the Map datatype. Follow the instructions below to run this experiment yourself!

Pre-Requisites

  1. Install Docker from here.

Instructions

  1. Clone this repository and go to the folder.
git clone https://github.com/anikeshk/aerospike-boolean-example.git
  1. Create a docker network to connect the Aerospike and the Node.js script.
docker network create nodejs-aero
  1. Pull and start the Aerospike docker image.
docker pull aerospike:4.9.0.10
docker run --rm -tid --name aerospike --network nodejs-aero -p 3000:3000 -p 3001:3001 -p 3002:3002 aerospike:4.9.0.10

Note: We are using Aerospike server version 4.9.0.10 as this code was tested only with this server version.

  1. Connect to aql using the docker exec command.
docker exec -it <container id> aql

Note: You can get the container id by using the docker ps command.

  1. Switch to a new terminal. Go to the cloned repository. Build the image to use the aerospike@3.11.0 Node.js library.
cd aerospike-boolean-example
docker build -t aerospike-boolean-example:1.0 .
  1. Run this image and check the results.
docker run --network nodejs-aero aerospike-boolean-example:1.0

The output should be something like this:

Connection to Aerospike cluster succeeded!
User data stored!
User data fetched! {"age":21,"gender":"male","food":{"pizza":0,"burger":1,"taco":1}}
  1. Check aql for the same entry:
aql> select * from test.users where PK="tom"
+-------+-----+--------+------------------------------------------+
| PK    | age | gender | food                                     |
+-------+-----+--------+------------------------------------------+
| "tom" | 21  | "male" | MAP('{"pizza":0, "burger":1, "taco":1}') |
+-------+-----+--------+------------------------------------------+
1 row in set (0.000 secs)

In both the output from the script and aql, you can see Aerospike has stored the boolean values as 1 or 0 in the Map, depending if the choice is true or false.

  1. Delete the entry from the database.
aql> delete from test.users where PK="tom"
OK, 1 record affected.
  1. Change the aerospike version in the package.json to 3.16.3 using any editor.
{
  ...
  "dependencies": {
    "aerospike": "3.16.3"
  }
}
  1. Re-build the image using a different tag.
docker build -t aerospike-boolean-example:2.0 .
  1. Run this image and check the results.
docker run --network nodejs-aero aerospike-boolean-example:2.0

The output should be something like this:

Connection to Aerospike cluster succeeded!
User data stored!
User data fetched! {"age":21,"gender":"male","food":{"pizza":false,"burger":true,"taco":true}}
  1. Check aql for the same entry:
aql> select * from test.users where PK="tom"
+-------+-----+--------+------------------------------------------+
| PK    | age | gender | food                                     |
+-------+-----+--------+------------------------------------------+
| "tom" | 21  | "male" | MAP('{"pizza":0, "burger":1, "taco":1}') |
+-------+-----+--------+------------------------------------------+
1 row in set (0.000 secs)

This time in aql the values are stored as 1 or 0, but the script outputs true or false. The datatype of the output has changed!

  1. Stop and remove the Aerospike docker image.
docker rm -f <container-id>
  1. Delete the network created earlier.
docker network rm nodejs-aero

About

This is an experiment on how changing dependency versions can break your codebase. It uses the aerospike npm module as an example.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published