Skip to content

Commit 1617a05

Browse files
committed
ci: allow testing composes
Signed-off-by: Miguel Martín <mmartinv@redhat.com>
1 parent 5a5c27f commit 1617a05

3 files changed

Lines changed: 81 additions & 25 deletions

File tree

build/package/rpm/go-fdo-server.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ install -m 0644 -vp configs/manufacturing.yaml %{buildroot}%{_sysconfdir}/%{name
6868
install -m 0644 -vp configs/owner.yaml %{buildroot}%{_sysconfdir}/%{name}
6969
install -m 0644 -vp configs/rendezvous.yaml %{buildroot}%{_sysconfdir}/%{name}
7070
# Certificates
71-
install -m 0750 -vd %{buildroot}%{_sysconfdir}/pki/%{name}
71+
install -m 0755 -vd %{buildroot}%{_sysconfdir}/pki/%{name}
7272
# Sysusers
7373
install -m 0644 -vp -D %{SOURCE2} %{buildroot}/%{_sysusersdir}/go-fdo-server.conf
7474
install -m 0644 -vp -D %{SOURCE3} %{buildroot}/%{_sysusersdir}/go-fdo-server-manufacturer.conf

test/ci/test-onboarding.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ run_test() {
1515
log_info "Creating directories"
1616
create_directories
1717

18-
log_info "Generating service certificates"
19-
generate_service_certs
20-
2118
log_info "Build and install 'go-fdo-client' binary"
2219
install_client
2320

2421
log_info "Build and install 'go-fdo-server' binary"
2522
install_server
2623

24+
log_info "Generating service certificates"
25+
generate_service_certs
26+
2727
log_info "Configuring services"
2828
configure_services
2929

test/rpm/utils.sh

Lines changed: 77 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ owner_config_file="${configs_dir}/owner.yaml"
7171
owner_reuse_creds="false"
7272
owner_to0_insecure_tls="false"
7373

74+
go_fdo_server_rpms="go-fdo-server go-fdo-server-manufacturer go-fdo-server-owner go-fdo-server-rendezvous"
75+
go_fdo_client_rpms="go-fdo-client"
76+
7477
# systemd drop-in file configuration
7578
#
7679
systemd_drop_in_base_dir="/run/systemd/system"
@@ -209,50 +212,103 @@ install_from_copr() {
209212
# https://docs.testing-farm.io/Testing%20Farm/0.1/test-environment.html#disabling-tag-repository
210213
sudo dnf install --disablerepo=* --enablerepo=copr:copr.fedorainfracloud.org:group_fedora-iot:fedora-iot -y "$@"
211214
sudo dnf copr disable -y @fedora-iot/fedora-iot
215+
sudo dnf copr remove -y @fedora-iot/fedora-iot
216+
}
217+
218+
install_from_compose(){
219+
source /etc/os-release
220+
case "${ID}-${VERSION_ID}" in
221+
fedora-rawhide)
222+
compose_host="http://kojipkgs.fedoraproject.org"
223+
compose_id="latest-Fedora-${VERSION_ID^}"
224+
compose_streams="Everything"
225+
compose_base_url="${COMPOSE_BASE_URL:-${compose_host}/compose/${VERSION_ID}/${compose_id}/compose}"
226+
;;
227+
fedora-*)
228+
compose_host="http://kojipkgs.fedoraproject.org"
229+
compose_streams="Everything"
230+
compose_base_url="${COMPOSE_BASE_URL:-${compose_host}/compose/updates/f${VERSION_ID}-updates/compose}"
231+
;;
232+
centos-*)
233+
compose_host="https://composes.stream.centos.org"
234+
compose_id="latest-CentOS-Stream"
235+
compose_streams="BaseOS AppStream"
236+
compose_base_url="${COMPOSE_BASE_URL:-${compose_host}/stream-${VERSION_ID}/production/${compose_id}/compose}"
237+
;;
238+
rhel-*)
239+
compose_base_url="${COMPOSE_BASE_URL:-}"
240+
[ -n "${compose_base_url}" ] || log_error "Compose base URL must be set for RHEL (eg='http://download.host/.../latest-RHEL-Compose/compose/')"
241+
compose_streams="${COMPOSE_STREAMS:-BaseOS AppStream}"
242+
[ -n "${compose_streams}" ] || log_error "Streams must be set for RHEL (default='BaseOS AppStream')"
243+
;;
244+
*)
245+
log_error "OS not supported"
246+
;;
247+
esac
248+
for stream in ${compose_streams}; do
249+
repo_name="compose-${ID}-${VERSION_ID}-${stream}"
250+
sudo tee "/etc/yum.repos.d/compose-${repo_name}.repo" <<EOF
251+
[${repo_name}]
252+
name=${repo_name}
253+
baseurl=${compose_base_url}/${stream}/$(uname -m)/os/
254+
enabled=1
255+
gpgcheck=0
256+
EOF
257+
done
258+
sudo dnf install --disablerepo=* --enablerepo=compose* -y "$@"
259+
sudo rm -f /etc/yum.repos.d/compose-*
212260
}
213261

214262
install_client() {
215263
# If PACKIT_COPR_RPMS is not defined it means we are running the test
216-
# locally so we will install the client from the copr repo
217-
[ -v "PACKIT_COPR_RPMS" ] || rpm -q go-fdo-client &>/dev/null || install_from_copr go-fdo-client
264+
# locally so we will install the client from the copr repo or from a compose
265+
if [ ! -v "PACKIT_COPR_RPMS" ]; then
266+
if [ "${USE_COMPOSE:-false}" == "true" ] ; then
267+
install_from_compose ${go_fdo_client_rpms}
268+
else
269+
install_from_copr ${go_fdo_client_rpms}
270+
fi
271+
fi
218272
log_info "Installed Client RPM:"
219-
echo "$(rpm -q go-fdo-client)"
273+
echo "$(rpm -q ${go_fdo_client_rpms})"
220274
}
221275

222276
uninstall_client() {
223-
# When running a test locally we remove the client package
224-
# after a successful execution.
225-
[ -v "PACKIT_COPR_RPMS" ] || {
226-
sudo dnf remove -y go-fdo-client
227-
sudo dnf copr remove -y @fedora-iot/fedora-iot
228-
}
277+
[ -v "PACKIT_COPR_RPMS" ] || sudo dnf remove -y ${go_fdo_client_rpms}
229278
}
230279

231280
install_server() {
232-
# If PACKIT_COPR_RPMS is not defined it means we are running the test
233-
# locally so we will build and install the RPMs from the *committed* code
234-
if [ ! -v "PACKIT_COPR_RPMS" ]; then
235-
commit="$(git rev-parse --short HEAD)"
236-
rpm -q go-fdo-server | grep -q "go-fdo-server.*git${commit}.*" || {
237-
make rpm
238-
sudo dnf install -y rpmbuild/rpms/{noarch,"$(uname -m)"}/*git"${commit}"*.rpm
239-
}
240-
else
241-
log_info "Expected Server RPMs:"
281+
# If PACKIT_COPR_RPMS is defined it means that all the rpms were built and installed already by packit
282+
if [ -v "PACKIT_COPR_RPMS" ]; then
283+
log_info "Expected RPMs:"
242284
for i in ${PACKIT_COPR_RPMS}; do
243285
echo "$i"
244286
done | sort
287+
else
288+
# If PACKIT_COPR_RPMS is not defined it means we are running the test
289+
# locally so we will build and install the RPMs from the *committed* code
290+
# or from a compose if USE_COMPOSE environment variable is "true"
291+
if [ "${USE_COMPOSE:-false}" == "true" ] ; then
292+
install_from_compose ${go_fdo_server_rpms}
293+
else
294+
commit="$(git rev-parse --short HEAD)"
295+
rpm -q go-fdo-server | grep -q "go-fdo-server.*git${commit}.*" || {
296+
make rpm
297+
sudo dnf install -y rpmbuild/rpms/{noarch,"$(uname -m)"}/*git"${commit}"*.rpm
298+
}
299+
fi
245300
fi
246301
# Make sure the RPMS are installed
247-
installed_rpms=$(rpm -q --qf "%{nvr}.%{arch} " go-fdo-server{,-{manufacturer,owner,rendezvous}})
302+
installed_rpms=$(rpm -q --qf "%{nvr}.%{arch} " ${go_fdo_server_rpms})
248303
log_info "Installed Server RPMs:"
249304
for i in ${installed_rpms}; do
250305
echo "$i"
251306
done | sort
307+
sudo chmod o+rX /etc/pki/go-fdo-server/
252308
}
253309

254310
uninstall_server() {
255-
[ -v "PACKIT_COPR_RPMS" ] || sudo dnf remove -y go-fdo-server{,-manufacturer,-owner,-rendezvous}
311+
[ -v "PACKIT_COPR_RPMS" ] || sudo dnf remove -y ${go_fdo_server_rpms}
256312
}
257313

258314
start_service_manufacturer() {

0 commit comments

Comments
 (0)