A repository split by component (pass_docker.c P4.2b). `rename`: component * b becomes bee -- the split changes, and the reference in compose.run.yaml, * a file this run does not repair, must leave the old Image `*-b`: a closure * repair cannot re-point it, so the run rebuilds. Else an edit keeping the * split: a closure repair. Returns "repo=N b=M bimg=K" (runner's references * to the reposi
| 4115 | * split: a closure repair. Returns "repo=N b=M bimg=K" (runner's references |
| 4116 | * to the repository Image / to `*-b`, `*-b` Images), or NULL. */ |
| 4117 | static char *incremental_image_split(bool rename, cbm_incremental_route_t *route) { |
| 4118 | char tmp[256]; |
| 4119 | snprintf(tmp, sizeof(tmp), "/tmp/cbm_imagesplit_XXXXXX"); |
| 4120 | if (!cbm_mkdtemp(tmp)) { |
| 4121 | return NULL; |
| 4122 | } |
| 4123 | write_temp_file(tmp, "svc/a/Dockerfile", "FROM alpine:3.20\n"); |
| 4124 | write_temp_file(tmp, "svc/b/Dockerfile", "FROM alpine:3.20\n"); |
| 4125 | write_temp_file(tmp, "compose.yaml", |
| 4126 | "services:\n a:\n image: acme/demo:1-a\n build: ./svc/a\n" |
| 4127 | " b:\n image: acme/demo:1-b\n build: ./svc/b\n"); |
| 4128 | write_temp_file(tmp, "compose.run.yaml", "services:\n runner:\n image: acme/demo:2-b\n"); |
| 4129 | char db_path[512]; |
| 4130 | snprintf(db_path, sizeof(db_path), "%s/imagesplit.db", tmp); |
| 4131 | static const char to_repo[] = |
| 4132 | "SELECT COUNT(*) FROM edges e JOIN nodes s ON s.id=e.source_id JOIN nodes t ON " |
| 4133 | "t.id=e.target_id WHERE e.type='USAGE' AND s.name='Service/runner' AND " |
| 4134 | "t.name='acme/demo'"; |
| 4135 | static const char to_b[] = |
| 4136 | "SELECT COUNT(*) FROM edges e JOIN nodes s ON s.id=e.source_id JOIN nodes t ON " |
| 4137 | "t.id=e.target_id WHERE e.type='USAGE' AND s.name='Service/runner' AND " |
| 4138 | "t.name='acme/demo:*-b'"; |
| 4139 | static const char b_img[] = |
| 4140 | "SELECT COUNT(*) FROM nodes WHERE label='Image' AND name='acme/demo:*-b'"; |
| 4141 | if (k8s_inc_index(tmp, db_path) != 0 || k8s_inc_count(db_path, to_b) != 1) { |
| 4142 | th_rmtree(tmp); |
| 4143 | return NULL; |
| 4144 | } |
| 4145 | write_temp_file(tmp, "compose.yaml", |
| 4146 | rename ? "services:\n a:\n image: acme/demo:1-a\n build: ./svc/a\n" |
| 4147 | " b:\n image: acme/demo:1-bee\n build: ./svc/b\n" |
| 4148 | : "services:\n a:\n image: acme/demo:1-a\n build: ./svc/a\n" |
| 4149 | " environment:\n - MODE\n" |
| 4150 | " b:\n image: acme/demo:1-b\n build: ./svc/b\n"); |
| 4151 | char *out = NULL; |
| 4152 | if (k8s_inc_index(tmp, db_path) == 0) { |
| 4153 | char buf[64]; |
| 4154 | snprintf(buf, sizeof(buf), "repo=%d b=%d bimg=%d", k8s_inc_count(db_path, to_repo), |
| 4155 | k8s_inc_count(db_path, to_b), k8s_inc_count(db_path, b_img)); |
| 4156 | out = strdup(buf); |
| 4157 | } |
| 4158 | *route = cbm_pipeline_incremental_test_last_route(); |
| 4159 | th_rmtree(tmp); |
| 4160 | return out; |
| 4161 | } |
| 4162 | |
| 4163 | TEST(incremental_image_split_change_rebuilds) { |
| 4164 | cbm_incremental_route_t route = CBM_INCREMENTAL_ROUTE_NONE; |
no test coverage detected