Code Monkey home page Code Monkey logo

cockroachdb-test's Introduction

CockroachDB test

This test consists in bringing up a cluster of 3 nodes with a HAProxy Load Balancer in front of them.

Once the cluster is up and running a Golang application will fire 2000 transactions over 10 connections that all try to write over the same records thus over the same Range.

Every transaction consists of two INSERTs, one UPDATE and one SELECT.

The concept is very simple, an account is created in the accounts table with a balance of 1,000.00€ then 2000 goroutines are created. Each one of them tries a Database transaction.

Each Database transaction tries to add two monetary transactions to the transactions table for the exact same account, one of 500.00€ and one of 495.00€.

After writing the two monetary transactions the Database transaction tries to update the account balance. It then SELECTs the balance to check whether it is below zero. If it is below zero it rollbacks the transaction, if it is not below zero it commits the Database transaction.

We expect only one Database transaction to succeed out of the 2000, which means that the remaining balance at the end of the program should be 5.00€.

Run the example

  1. Bring the cluster up with make run
  2. Once the cluster is up and running then run the test with make test

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.