1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
Artifact splitting tests
========================
Parsing and validation
----------------------
To verify that the products fields are parsed correctly, we have a
scenario that uses all of them, not relying on the default rules.
SCENARIO building a system with morphologies that have splitting rules
GIVEN a workspace
AND a git server
To test that all the fields are recognised, we set the new fields to
their default values.
AND chunk test-chunk includes the default splitting rules
AND stratum test-stratum includes the default splitting rules
AND system test-system includes the default splitting rules
The default rules produce a system that is identical to not providing
them, and since this test is about validation, we don't care about the
result, so much as it succeeding to build something.
WHEN the user checks out the system branch called master
THEN morph build the system test-system of the branch master
Smaller systems
---------------
An example use-case for splitting is to only include the runtime
strata for a target system, rather than including all the development
information, such as the documentation, C library headers and C static
libraries.
SCENARIO building a system only using runtime strata
GIVEN a workspace
AND a git server
The only change we need to make is to add a field to the system morphology
to select which artifact to use in the system.
AND system test-system only uses test-stratum-runtime from test-stratum
WHEN the user checks out the system branch called master
The best way to test that only using some stratum artifacts works is
to check which files the output has, so we deploy a tarball and inspect
its contents.
GIVEN a cluster called test-cluster for deploying only the test-system system as type tar in system branch master
WHEN the user builds the system test-system in branch master
AND the user attempts to deploy the cluster test-cluster in branch master with options system.location="$DATADIR/test.tar"
The -runtime artifacts include executables and shared libraries.
THEN tarball test.tar contains bin/test
AND tarball test.tar contains lib/libtest.so
The -devel artifacts include static libraries and documentation, so if
we've successfully excluded it, we won't have those files.
AND tarball test.tar doesn't contain lib/libtest.a
AND tarball test.tar doesn't contain man/man3/test.3.gz
Implementations
---------------
IMPLEMENTS GIVEN chunk (\S+) includes the default splitting rules
# Append default products rules
cat <<EOF >>"$DATADIR/gits/$MATCH_1/$MATCH_1.morph"
products:
- artifact: $MATCH_1-bins
include: [ "(usr/)?s?bin/.*" ]
- artifact: $MATCH_1-libs
include:
- (usr/)?lib(32|64)?/lib[^/]*\.so(\.\d+)*
- (usr/)?libexec/.*
- artifact: $MATCH_1-devel
include:
- (usr/)?include/.*
- (usr/)?lib(32|64)?/lib.*\.a
- (usr/)?lib(32|64)?/lib.*\.la
- (usr/)?(lib(32|64)?|share)/pkgconfig/.*\.pc
- artifact: $MATCH_1-doc
include:
- (usr/)?share/doc/.*
- (usr/)?share/man/.*
- (usr/)?share/info/.*
- artifact: $MATCH_1-locale
include:
- (usr/)?share/locale/.*
- (usr/)?share/i18n/.*
- (usr/)?share/zoneinfo/.*
- artifact: $MATCH_1-misc
include: [ .* ]
EOF
run_in "$DATADIR/gits/$MATCH_1" git add "$MATCH_1.morph"
run_in "$DATADIR/gits/$MATCH_1" git commit -m 'Add default splitting rules'
IMPLEMENTS GIVEN stratum (\S+) includes the default splitting rules
# Append default products rules
cat <<EOF >"$DATADIR/gits/morphs/$MATCH_1.morph"
name: $MATCH_1
kind: stratum
products:
- artifact: $MATCH_1-devel
include:
- .*-devel
- .*-debug
- .*-doc
- artifact: $MATCH_1-runtime
include:
- .*-bins
- .*-libs
- .*-locale
- .*-misc
- .*
chunks:
- name: test-chunk
repo: test:test-chunk
ref: master
morph: test-chunk
build-mode: test
build-depends: []
artifacts:
test-chunk-bins: $MATCH_1-runtime
test-chunk-libs: $MATCH_1-runtime
test-chunk-locale: $MATCH_1-runtime
test-chunk-misc: $MATCH_1-runtime
test-chunk-devel: $MATCH_1-devel
test-chunk-doc: $MATCH_1-devel
EOF
run_in "$DATADIR/gits/morphs" git add "$MATCH_1.morph"
run_in "$DATADIR/gits/morphs" git commit -m 'Add default splitting rules'
IMPLEMENTS GIVEN system (\S+) includes the default splitting rules
cat << EOF > "$DATADIR/gits/morphs/$MATCH_1.morph"
name: $MATCH_1
kind: system
arch: $(run_morph print-architecture)
strata:
- name: test-stratum
repo: test:morphs
ref: master
morph: test-stratum
artifacts:
- test-stratum-runtime
- test-stratum-devel
EOF
run_in "$DATADIR/gits/morphs" git add "$MATCH_1.morph"
run_in "$DATADIR/gits/morphs" git commit -m 'Add default splitting rules'
IMPLEMENTS GIVEN system (\S+) only uses (\S+) from (\S+)
python -c 'import sys, yaml
with open(sys.argv[1], "r") as f:
d = yaml.load(f)
for spec in d["strata"]:
if spec["name"] == sys.argv[3]:
spec["artifacts"] = [sys.argv[2]]
with open(sys.argv[1], "w") as f:
yaml.dump(d, f)
' "$DATADIR/gits/morphs/$MATCH_1.morph" "$MATCH_2" "$MATCH_3"
run_in "$DATADIR/gits/morphs" git add "$MATCH_1.morph"
run_in "$DATADIR/gits/morphs" git commit -m "Make $MATCH_1 only use $MATCH_2"
|