Skip to content

Commit fc022ed

Browse files
Version 0.8.0: add sqlite / mount uenv repo images (#43)
* add sqlite support
1 parent 26e7886 commit fc022ed

34 files changed

+26842
-353
lines changed

.clangd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
CompileFlags:
2-
Add: [-std=c++17]
2+
Add: [-std=c++17, -Isrc]

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.7.0
1+
0.8.0

ci/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ FROM ${DOCKER_CONTAINER}
44
RUN zypper install -y\
55
fuse3-devel\
66
git \
7+
sqlite3 \
8+
sqlite3-devel \
79
libopenssl-devel\
810
util-linux\
911
util-linux-systemd\

ci/tests/index.db.txt

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
PRAGMA foreign_keys=OFF;
2+
BEGIN TRANSACTION;
3+
CREATE TABLE images (
4+
sha256 TEXT PRIMARY KEY CHECK(length(sha256)==64),
5+
id TEXT UNIQUE CHECK(length(id)==16),
6+
date TEXT NOT NULL,
7+
size INTEGER NOT NULL,
8+
uarch TEXT NOT NULL,
9+
system TEXT NOT NULL
10+
);
11+
INSERT INTO images VALUES('3e8f96370a4685a7413d344d98f69889c0ba6bb1d6c2d3d19ce01b6079c58c68','3e8f96370a4685a7','2024-03-11 17:08:35.976000+00:00',8881353294,'x86_64','santis');
12+
INSERT INTO images VALUES('4e8f96370a4685a7413d344d98f69889c0ba6bb1d6c2d3d19ce01b6079c58c68','4e8f96370a4685a7','2024-03-11 17:08:35.976000+00:00',8881353294,'x86_64','santis');
13+
INSERT INTO images VALUES('1736b4bb5ad9b3c5cae8878c71782a8bf2f2f739dbce8e039b629de418cb4dab','1736b4bb5ad9b3c5','2024-02-19 06:33:57.442000+00:00',3987993166,'x86_64','santis');
14+
CREATE TABLE uenv (
15+
version_id INTEGER PRIMARY KEY,
16+
name TEXT NOT NULL,
17+
version TEXT NOT NULL,
18+
UNIQUE (name, version)
19+
);
20+
INSERT INTO uenv VALUES(1,'icon-wcp','v1');
21+
INSERT INTO uenv VALUES(2,'prgenv-gnu','24.2');
22+
INSERT INTO uenv VALUES(3,'prgenv-gnu','24.3');
23+
CREATE TABLE tags (
24+
version_id INTEGER,
25+
tag TEXT NOT NULL,
26+
sha256 TEXT NOT NULL,
27+
PRIMARY KEY (version_id, tag),
28+
FOREIGN KEY (version_id)
29+
REFERENCES uenv (version_id)
30+
ON DELETE CASCADE
31+
ON UPDATE CASCADE,
32+
FOREIGN KEY (sha256)
33+
REFERENCES images (sha256)
34+
ON DELETE CASCADE
35+
ON UPDATE CASCADE
36+
);
37+
INSERT INTO tags VALUES(1,'latest','3e8f96370a4685a7413d344d98f69889c0ba6bb1d6c2d3d19ce01b6079c58c68');
38+
INSERT INTO tags VALUES(1,'v3','3e8f96370a4685a7413d344d98f69889c0ba6bb1d6c2d3d19ce01b6079c58c68');
39+
INSERT INTO tags VALUES(2,'latest','1736b4bb5ad9b3c5cae8878c71782a8bf2f2f739dbce8e039b629de418cb4dab');
40+
INSERT INTO tags VALUES(2,'v2','1736b4bb5ad9b3c5cae8878c71782a8bf2f2f739dbce8e039b629de418cb4dab');
41+
INSERT INTO tags VALUES(3,'v3','4e8f96370a4685a7413d344d98f69889c0ba6bb1d6c2d3d19ce01b6079c58c68');
42+
CREATE VIEW records AS
43+
SELECT
44+
images.system AS system,
45+
images.uarch AS uarch,
46+
uenv.name AS name,
47+
uenv.version AS version,
48+
tags.tag AS tag,
49+
images.date AS date,
50+
images.size AS size,
51+
tags.sha256 AS sha256,
52+
images.id AS id
53+
FROM tags
54+
INNER JOIN uenv ON uenv.version_id = tags.version_id
55+
INNER JOIN images ON images.sha256 = tags.sha256;
56+
COMMIT;

ci/tests/test_sqlite.bats

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
function setup() {
2+
bats_load_library bats-support
3+
bats_load_library bats-assert
4+
load ./common
5+
SQFSDIR=$(mktemp -d)
6+
export SQFSDIR
7+
rm -f index.db
8+
sqlite3 ${SQFSDIR}/index.db < ci/tests/index.db.txt
9+
10+
img_hashes=(1736b4bb5ad9b3c5cae8878c71782a8bf2f2f739dbce8e039b629de418cb4dab 3313739553fe6553f789a35325eb6954a37a7b85cdeab943d0878a05edaac998 3e8f96370a4685a7413d344d98f69889c0ba6bb1d6c2d3d19ce01b6079c58c68)
11+
12+
for hash in ${img_hashes[@]}
13+
do
14+
mkdir -p ${SQFSDIR}/images/$hash
15+
done
16+
17+
dd=$(mktemp -d)
18+
(
19+
umask 022
20+
cd "$dd" || exit
21+
mkdir spack-install
22+
echo "This is file A" >> spack-install/fileA.txt
23+
)
24+
mksquashfs "$dd" ${SQFSDIR}/store.squashfs -quiet -noappend && rm -r "$dd"
25+
26+
for hash in ${img_hashes[@]}
27+
do
28+
cp ${SQFSDIR}/store.squashfs ${SQFSDIR}/images/${hash}/
29+
done
30+
}
31+
32+
function teardown() {
33+
rm -r ${SQFSDIR}
34+
}
35+
36+
37+
@test "mount prgenv-gnu" {
38+
export UENV_REPO_PATH=${SQFSDIR}
39+
run_srun --uenv=prgenv-gnu/24.2 true
40+
run_srun --uenv=prgenv-gnu:latest true
41+
run_srun --uenv=prgenv-gnu/24.2:latest true
42+
}
43+
44+
@test "mount jfrog image by id" {
45+
export UENV_REPO_PATH=${SQFSDIR}
46+
run_srun --uenv=1736b4bb5ad9b3c5 true
47+
}
48+
49+
@test "mount jfrog image by sha256" {
50+
export UENV_REPO_PATH=${SQFSDIR}
51+
run_srun --uenv=1736b4bb5ad9b3c5cae8878c71782a8bf2f2f739dbce8e039b629de418cb4dab true
52+
}
53+
54+
@test "attempt to mount ambiguous prgenv-gnu" {
55+
export UENV_REPO_PATH=${SQFSDIR}
56+
run_srun_unchecked --uenv=prgenv-gnu true
57+
assert_output --partial 'More than one uenv matches.'
58+
}
59+
60+

docker/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ RUN zypper install -y\
2828
util-linux-systemd\
2929
psmisc\
3030
psutils\
31-
strace
31+
strace \
32+
sqlite3 \
33+
sqlite3-devel
3234

3335
# install python
3436
RUN curl -O https://www.python.org/ftp/python/3.10.11/Python-3.10.11.tgz \

docker/rebuild.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/bash
22

33
docker compose exec -w /slurm-uenv-mount slurm \
4-
sh -c 'meson install -C /uenv-build'
4+
sh -c "meson install -C /uenv-build"

docker/run-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
22

3-
bats /slurm-uenv-mount/ci/tests/test.bats
3+
bats /slurm-uenv-mount/ci/tests

external/catch2/LICENSE.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Boost Software License - Version 1.0 - August 17th, 2003
2+
3+
Permission is hereby granted, free of charge, to any person or organization
4+
obtaining a copy of the software and accompanying documentation covered by
5+
this license (the "Software") to use, reproduce, display, distribute,
6+
execute, and transmit the Software, and to prepare derivative works of the
7+
Software, and to permit third-parties to whom the Software is furnished to
8+
do so, all subject to the following:
9+
10+
The copyright notices in the Software and this entire statement, including
11+
the above license grant, this restriction and the following disclaimer,
12+
must be included in all copies of the Software, in whole or in part, and
13+
all derivative works of the Software, unless such copies or derivative
14+
works are solely in the form of machine-executable object code generated by
15+
a source language processor.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
20+
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
21+
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
22+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23+
DEALINGS IN THE SOFTWARE.

0 commit comments

Comments
 (0)