This package enables integration testing of the RedisCobuildLockProvider
by connecting to an actual Redis created using an redis docker image.
Docker and docker compose must be installed
In this folder run docker-compose up -d
In this folder run docker-compose down
rush update
rush build -t rush-redis-cobuild-plugin-integration-test
# start the docker container: docker-compose up -d
# build the code: rushx build
rushx test-lock-provider
Sandbox repo folder: build-tests/rush-redis-cobuild-plugin-integration-test/sandbox/repo
cd sandbox/repo
node ../../lib/runRush.js update
You can also test sharded operations with cobuilds using the build-tests/rush-redis-cobuild-plugin-integration-test/sandbox/sharded-repo
cd sandbox/sharded-repo
node ../../lib/runRush.js update
You should expect to see multiple shards for operations a
(15 shards), b
(75) and h
(50) and e
(75).
- Write to build cache
rm -rf common/temp/build-cache && node ../../lib/runRush.js --debug cobuild
- Read from build cache
node ../../lib/runRush.js --debug cobuild
Expected behavior: Cobuild feature is disabled. Build cache is saved/restored as normal.
- Clear redis server
(cd ../.. && docker compose down && docker compose up -d)
- Run cobuilds
rm -rf common/temp/build-cache && RUSH_COBUILD_CONTEXT_ID=foo REDIS_PASS=redis123 RUSH_COBUILD_RUNNER_ID=runner1 node ../../lib/runRush.js --debug cobuild
Expected behavior: Cobuild feature is enabled. Run command successfully. You can also see cobuild related logs in the terminal.
Running cobuild (runner foo/runner1)
Analyzing repo state... DONE (0.11 seconds)
Executing a maximum of 10 simultaneous processes...
==[ b (build) ]====================================================[ 1 of 9 ]==
Get completed_state(cobuild:completed:foo:2e477baf39a85b28fc40e63b417692fe8afcc023)_package(b)_phase(_phase:build): SUCCESS;2e477baf39a85b28fc40e63b417692fe8afcc023
Get completed_state(cobuild:completed:foo:cfc620db4e74a6f0db41b1a86d0b5402966b97f3)_package(a)_phase(_phase:build): SUCCESS;cfc620db4e74a6f0db41b1a86d0b5402966b97f3
Successfully acquired lock(cobuild:lock:foo:4c36160884a7a502f9894e8f0adae05c45c8cc4b)_package(b)_phase(_phase:build) to runner(runner1) and it expires in 30s
Note: This test requires Visual Studio Code to be installed.
-
Open predefined
.vscode/redis-cobuild.code-workspace
in Visual Studio Code. -
Clear redis server
# Under rushstack/build-tests/rush-redis-cobuild-plugin-integration-test
docker compose down && docker compose up -d
- Clear build cache
# Under rushstack/build-tests/rush-redis-cobuild-plugin-integration-test/sandbox/repo
rm -rf common/temp/build-cache
- Open command palette (Ctrl+Shift+P or Command+Shift+P) and select
Tasks: Run Task
and selectcobuild
.
In this step, two dedicated terminal windows will open. Running
rush cobuild
command under sandbox repo respectively.
Expected behavior: Cobuild feature is enabled, cobuild related logs out in both terminals.
Note: This test requires Visual Studio Code to be installed.
-
Open predefined
.vscode/redis-cobuild.code-workspace
in Visual Studio Code. -
Making the cobuild command of project "A" fails
sandbox/repo/projects/a/package.json
"scripts": {
- "_phase:build": "node ../build.js a",
+ "_phase:build": "exit 1",
}
- Clear redis server
# Under rushstack/build-tests/rush-redis-cobuild-plugin-integration-test
docker compose down && docker compose up -d
- Clear build cache
# Under rushstack/build-tests/rush-redis-cobuild-plugin-integration-test/sandbox/repo
rm -rf common/temp/build-cache
- Open command palette (Ctrl+Shift+P or Command+Shift+P) and select
Tasks: Run Task
and selectcobuild
.
Expected behavior: Cobuild feature is enabled, cobuild related logs out in both terminals. These two cobuild commands fail because of the failing build of project "A". And, one of them restored the failing build cache created by the other one.
Enable the allowCobuildWithoutCache
experiment in experiments.json
.
Navigate to the sandbox for sharded cobuilds,
cd sandbox/sharded-repo
Next, start up your Redis instance,
docker compose down && docker compose up -d
Then, open 2 terminals and run this in each (changing the RUSH_COBUILD_RUNNER_ID across the 2 terminals),
rm -rf common/temp/build-cache && RUSH_COBUILD_CONTEXT_ID=foo REDIS_PASS=redis123 RUSH_COBUILD_RUNNER_ID=runner1 node ../../lib/runRush.js cobuild -p 10 --timeline
If all goes well, you should see a bunch of operation with - shard xx/yy
. Operations h (build)
and e (build)
are both sharded heavily and should be cobuild compatible. To validate changes you're making, ensure that the timeline view for all of the shards of those 2 operations are cobuilt across both terminals. If they're not, something is wrong with your update.