File tree 4 files changed +93
-1
lines changed
4 files changed +93
-1
lines changed Original file line number Diff line number Diff line change @@ -134,4 +134,5 @@ jobs:
134
134
135
135
- name : Test nix run
136
136
run : |
137
+ nix run -L .#nativelink-prevent-store-conflict-test
137
138
nix run -L .#nativelink-is-executable-test
Original file line number Diff line number Diff line change 133
133
134
134
local-image-test = pkgs . callPackage ./tools/local-image-test.nix { } ;
135
135
136
+ nativelink-prevent-store-conflict-test = pkgs . callPackage ./tools/nativelink-prevent-store-conflict-test.nix { inherit nativelink ; } ;
137
+
136
138
nativelink-is-executable-test = pkgs . callPackage ./tools/nativelink-is-executable-test.nix { inherit nativelink ; } ;
137
139
138
140
rbe-configs-gen = pkgs . callPackage ./local-remote-execution/rbe-configs-gen.nix { } ;
251
253
} ;
252
254
} ;
253
255
packages = rec {
254
- inherit publish-ghcr local-image-test nativelink-is-executable-test nativelink nativelink-debug native-cli lre-cc nativelink-worker-init ;
256
+ inherit publish-ghcr local-image-test nativelink-prevent-store-conflict-test nativelink- is-executable-test nativelink nativelink-debug native-cli lre-cc nativelink-worker-init ;
255
257
default = nativelink ;
256
258
257
259
rbe-autogen-lre-cc = rbe-autogen lre-cc ;
Original file line number Diff line number Diff line change @@ -243,6 +243,23 @@ async fn inner_main(
243
243
// Currently we only support http as our socket type.
244
244
let ListenerConfig :: http( http_config) = server_cfg. listener ;
245
245
246
+ // Check if CAS and AC use the same store.
247
+ if let Some ( cas_config) = & services. cas {
248
+ if let Some ( ac_config) = & services. ac {
249
+ for ( instance_name, cas_store_config) in cas_config {
250
+ if let Some ( ac_store_config) = ac_config. get ( instance_name) {
251
+ if cas_store_config. cas_store == ac_store_config. ac_store {
252
+ return Err ( make_err ! (
253
+ Code :: InvalidArgument ,
254
+ "CAS and AC cannot use the same store '{}' in the config" ,
255
+ cas_store_config. cas_store
256
+ ) ) ?;
257
+ }
258
+ }
259
+ }
260
+ }
261
+ }
262
+
246
263
let tonic_services = TonicServer :: builder ( )
247
264
. add_optional_service (
248
265
services
Original file line number Diff line number Diff line change
1
+ {
2
+ nativelink ,
3
+ writeShellScriptBin ,
4
+ } :
5
+ writeShellScriptBin "prevent-store-conflict-test" ''
6
+ set -xuo pipefail
7
+
8
+ cat > store_conflict_test.json <<EOF
9
+ {
10
+ "stores": {
11
+ "FILESYSTEM_STORE": {
12
+ "compression": {
13
+ "compression_algorithm": {
14
+ "lz4": {}
15
+ },
16
+ "backend": {
17
+ "filesystem": {
18
+ "content_path": "~/.cache/nativelink/content_path-cas",
19
+ "temp_path": "~/.cache/nativelink/tmp_path-cas",
20
+ "eviction_policy": {
21
+ // 10gb.
22
+ "max_bytes": 10000000000,
23
+ }
24
+ }
25
+ }
26
+ }
27
+ }
28
+ },
29
+ "servers": [{
30
+ "listener": {
31
+ "http": {
32
+ "socket_address": "0.0.0.0:50053"
33
+ }
34
+ },
35
+ "services": {
36
+ "cas": {
37
+ "main": {
38
+ "cas_store": "FILESYSTEM_STORE"
39
+ }
40
+ },
41
+ "ac": {
42
+ "main": {
43
+ "ac_store": "FILESYSTEM_STORE"
44
+ }
45
+ },
46
+ "capabilities": {},
47
+ "bytestream": {
48
+ "cas_stores": {
49
+ "main": "FILESYSTEM_STORE",
50
+ }
51
+ }
52
+ }
53
+ }]
54
+ }
55
+ EOF
56
+
57
+ nativelink_output="$(${ nativelink } /bin/nativelink ./store_conflict_test.json 2>&1)"
58
+
59
+ rm ./store_conflict_test.json
60
+
61
+ print_error_output=$(cat <<EOF
62
+ Error: Error { code: InvalidArgument, messages: ["CAS and AC cannot use the same store 'FILESYSTEM_STORE' in the config"] }
63
+ EOF)
64
+
65
+ if [ "$nativelink_output" = "$print_error_output" ]; then
66
+ echo "The output of nativelink matches the print_error output."
67
+ else
68
+ echo 'The output of nativelink does not match the print_error output:'
69
+ diff <(echo "$nativelink_output") <(echo "$print_error_output") >&2
70
+ exit 1
71
+ fi
72
+ ''
You can’t perform that action at this time.
0 commit comments