diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index e379fc9a..54227673 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,6 +1,11 @@ { "name": "Pink builder", - "image": "ubuntu:22.04", + "build": { + "context": "..", + "dockerfile": "../Dockerfile" + }, + "workspaceMount": "source=${localWorkspaceFolder},target=/usr/src/app,type=bind", + "workspaceFolder": "/usr/src/app", "features": { "ghcr.io/devcontainers/features/common-utils:2.5.1": {}, "ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}, @@ -26,10 +31,9 @@ } } }, - "postCreateCommand": "sudo apt-get update && sudo apt-get install -y build-essential redis-server libprotobuf-dev protobuf-compiler", "containerEnv": { - "RONDB_PATH": "/workspaces/pink/rondb-22.10.5-linux-glibc2.28-arm64_v8" + "RONDB_PATH": "/usr/src/app/rondb-22.10.5-linux-glibc2.28-arm64_v8" // Do this manually: - // export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/workspaces/pink/rondb-22.10.5-linux-glibc2.28-arm64_v8/lib + // export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/src/app/rondb-22.10.5-linux-glibc2.28-arm64_v8/lib } } \ No newline at end of file diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..05d77292 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +rondb-docker +rondb-**/** diff --git a/.github/workflows/build_test_push.yaml b/.github/workflows/build_test_push.yaml new file mode 100644 index 00000000..60045b0a --- /dev/null +++ b/.github/workflows/build_test_push.yaml @@ -0,0 +1,86 @@ +name: Run Redis benchmark on Rondis + +on: + pull_request: + # Launch on PRs *towards* these branches + branches: + - main + - master + types: [opened, synchronize, reopened] + +jobs: + build-and-run-redis-benchmark: + runs-on: ubuntu-latest + env: + RONDB_TARBALL_URI: https://repo.hops.works/master/rondb-22.10.5-linux-glibc2.28-x86_64.tar.gz + RONDB_PATH: /tmp/rondb + IMAGE_NAME: rondis:latest + CONTAINER_NAME: rondis + RONDIS_PORT: 6379 + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Run rondb-docker + env: + RONDB_DOCKER_DIR: /tmp/rondb-docker + run: | + path_now=$(pwd) + git clone -b release-0.7 https://github.com/logicalclocks/rondb-docker.git $RONDB_DOCKER_DIR + cd $RONDB_DOCKER_DIR && ./build_run_docker.sh -d \ + --size small \ + --num-mgm-nodes 1 \ + --node-groups 1 \ + --replication-factor 1 \ + --num-mysql-nodes 1 \ + --num-rest-api-nodes 0 \ + --num-benchmarking-nodes 0 + cd $path_now + + - name: Build Rondis image + run: docker build -t $IMAGE_NAME . + + - name: Download RonDB + run: | + wget $RONDB_TARBALL_URI -O /tmp/temp_tarball.tar.gz + mkdir -p $RONDB_PATH + tar xfz /tmp/temp_tarball.tar.gz -C $RONDB_PATH --strip-components=1 + + - name: Create Rondis environment + env: + DOCKER_WORK_DIR: /usr/src/app + run: | + docker run -d \ + --name=$CONTAINER_NAME \ + -v $RONDB_PATH:$RONDB_PATH \ + -v $(pwd):$DOCKER_WORK_DIR \ + -e RONDB_PATH=$RONDB_PATH \ + -w $DOCKER_WORK_DIR \ + -p $RONDIS_PORT:$RONDIS_PORT \ + $IMAGE_NAME \ + tail -f /dev/null + + - name: Build Pink + run: docker exec -i $CONTAINER_NAME bash -c "cd pink && ./build.sh" + + - name: Run SQL scripts + run: | + docker exec -i mysqld_1 bash -c "mysql -uroot -e 'CREATE DATABASE redis;'" + for sql_file in pink/rondis/sql/*.sql; do + cat "$sql_file" | docker exec -i mysqld_1 mysql -uroot + done + + - name: Connect Docker network + run: | + # Get network name that starts with "rondb" + COMPOSE_NETWORK=$(docker network list | grep rondb | awk '{print $2}') + docker network connect $COMPOSE_NETWORK $CONTAINER_NAME + + - name: Run Rondis + run: | + docker exec -i $CONTAINER_NAME bash -c \ + "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/tmp/rondb/lib && pink/rondis/rondis 6379 mgmd_1:1186 2 &" + + - name: Run Redis benchmark + run: docker exec -i $CONTAINER_NAME bash -c "redis-benchmark -t get,set -c 2" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..bb7cb624 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM ubuntu:22.04 + +RUN apt-get update && \ + apt-get install -y build-essential redis-server libprotobuf-dev \ + protobuf-compiler git + +CMD ["/bin/bash"] diff --git a/pink/build.sh b/pink/build.sh index 4d2d30d9..e35612f8 100755 --- a/pink/build.sh +++ b/pink/build.sh @@ -1,5 +1,7 @@ #!/bin/bash +set -e + PINK_PATH=$PWD # We depend on slash diff --git a/pink/rondis/common.cc b/pink/rondis/common.cc index 46aae1ac..2285cc4f 100644 --- a/pink/rondis/common.cc +++ b/pink/rondis/common.cc @@ -21,7 +21,7 @@ int execute_no_commit(NdbTransaction *trans, int &ret_code, bool allow_fail) int execute_commit(Ndb *ndb, NdbTransaction *trans, int &ret_code) { - printf("Execute transaction\n"); + // printf("Execute transaction\n"); if (trans->execute(NdbTransaction::Commit) != 0) { ret_code = trans->getNdbError().code; diff --git a/pink/rondis/common.h b/pink/rondis/common.h index 03dcd487..182303a5 100644 --- a/pink/rondis/common.h +++ b/pink/rondis/common.h @@ -1,7 +1,7 @@ #include #include -#define MAX_CONNECTIONS 4 +#define MAX_CONNECTIONS 2 #define REDIS_DB_NAME "redis" diff --git a/pink/rondis/rondb.cc b/pink/rondis/rondb.cc index b9e71837..e2eaa9e8 100644 --- a/pink/rondis/rondb.cc +++ b/pink/rondis/rondb.cc @@ -123,7 +123,12 @@ int rondb_redis_handler(const pink::RedisCmdArgsType &argv, } else { - printf("Unsupported command\n"); + printf("Unsupported command: "); + for (const auto &arg : argv) + { + printf("%s ", arg.c_str()); + } + printf("\n"); return -1; } } diff --git a/pink/rondis/rondis.cc b/pink/rondis/rondis.cc index 17ea22e2..41e9ce3a 100644 --- a/pink/rondis/rondis.cc +++ b/pink/rondis/rondis.cc @@ -69,12 +69,14 @@ RondisConn::RondisConn( int RondisConn::DealMessage(const RedisCmdArgsType &argv, std::string *response) { - printf("Received Redis message: "); - for (int i = 0; i < argv.size(); i++) - { - printf("%s ", argv[i].c_str()); - } - printf("\n"); + /* + printf("Received Redis message: "); + for (int i = 0; i < argv.size(); i++) + { + printf("%s ", argv[i].c_str()); + } + printf("\n"); + */ return rondb_redis_handler(argv, response, _worker_id); } diff --git a/pink/rondis/string/db_interactions.cc b/pink/rondis/string/db_interactions.cc index e50e16af..df47e747 100644 --- a/pink/rondis/string/db_interactions.cc +++ b/pink/rondis/string/db_interactions.cc @@ -295,9 +295,11 @@ int get_simple_key_row(std::string *response, response->append(buf); response->append((const char *)&key_row->value_start[2], key_row->tot_value_len); response->append("\r\n"); - printf("Respond with tot_value_len: %u, string: %s\n", + /* + printf("Respond with tot_value_len: %u, string: %s\n", key_row->tot_value_len, (const char *)&key_row->value_start[2], key_row->tot_value_len); + */ ndb->closeTransaction(trans); return 0; }