Hello,
recently I fixed a small bug in cockpit [1]. The fix is rather trivial but it was
quite difficult to test it and verify that it really fixes the problem.
ALP Prerequisites
=================
1. Install ALP from https://download.opensuse.org/repositories/SUSE:/ALP/images/,
see the previous mails about the installation and configuration
2. Install cockpit with "transactional-update pkg install cockpit",
then reboot the system
(the backend packages are already preinstalled in the ALP image, this will
install the web frontend)
3. Start the cockpit service: "systemctl enable --now cockpit.socket"
Now you will have the standard cockpit installed and ready to run, you might
test it by connecting to https://localhost:9090
Development
===========
Note: I needed to patch a cockpit plugin which is basically a JS code + HTML + CSS.
If you would need to patch the cockpit core (the C code) it would be more
difficult, see the suggestion in the end.
I did the development directly on my workstation (Leap 15.4), the ALP instance was
running in a VM.
Development Prerequisites
-------------------------
For patching a cockpit plugin you should not need much libraries installed, but the
the Makefile (generated by autotools) requires the libraries also for the C part.
On my workstation I had to additionally install these packages:
zypper install json-glib-devel krb5-devel sassc nodejs16
You might actually need some more libraries or tools (autotools), I use my
workstation as a development machine and it already contains a lot of libraries.
Check that nodejs and npm default versions are 16, esp. if you have multiple versions
installed. Originally I probably did something wrong and got some strange failures...
Then you can checkout the sources from GitHub
git clone git@github.com:cockpit-project/cockpit.git
and checkout the version used in ALP
cd cockpit
git checkout -b 276
Check https://build.opensuse.org/package/show/SUSE:ALP/cockpit, it might change in
the future.
To build the sources use:
# this installs the npm packages using "npm install"
./autogen.sh
# autogen.sh runs configure but it will very likely fail, by default it needs
# some additional libraries, if you want to patch just a plugin then run
./configure --disable-doc --disable-ssh --disable-pcp --disable-polkit
make
Now the compiled plugins are available in ./dist/ subdirectory. Now we need to
transfer these changed file to the ALP system.
There are several possibilities to do this. You can run an "scp" command after each
edit/build or you can use some network file system.
I tested that with sshfs. The disadvantage is that the sshfs packages are not
available for ALP, as a workaround I installed the "sshfs" and "fuse3" packages from
Tumbleweed. That works currently because ALP is based on TW, but that will probably
not work later when ALP is branched from TW. The clean solution would be to provide a
container for that...
To mount a directory over sshfs run
sshfs <user>@<machine>:
Dne 29. 09. 22 v 15:52 Ladislav Slezák napsal(a):
recently I fixed a small bug in cockpit [1]. The fix is rather trivial but it was quite difficult to test it and verify that it really fixes the problem.
I'm adding some more details about the integration tests. Adding a new test was pretty simple (just check whether the switch is enabled or disabled in the browser), but most difficult was to run the test and verify that it really works. I followed their README [2], but I was not successful in openSUSE, I was getting some strange errors. It needs some Python libraries not available in openSUSE, I tried to install them via "pip" but it still failed. I that point I gave up and installed Fedora Server 36. I used Server edition just because you do not need a full desktop for the tests and it is smaller and faster to install. But if you already have a full Fedora 36 system installed you can use it as well. But I highly recommend to use a virtual machine for testing, I'd not dare to run the test on some production machine. Here are the commands which I extracted from my bash history file. The list might not be complete or in correct order. There was quite a lot of trial & error. # first install the needed packages dnf install nodejs dnf-utils python-srpm-macros curl expect xz rpm-build \ chromium-headless libvirt-daemon-driver-storage-core libvirt-daemon-driver-qemu \ libvirt-client python3-libvirt python3-flake8 python3-pyyaml git automake \ autoconf make gcc qemu-kvm # then run these commands as root in a cockpit Git checkout: ./autogen.sh --prefix=/usr make -j `nproc` # I do not know why but I had to make some directories accessible, # maybe you need to create some directories manually or just run that # test/image-prepare command below, it likely fails but it should create this # directory structure chmod a+rx /root/.cache/cockpit-images/ chmod a+rx /root/.cache/ chmod a+rx /root/cockpit/test/images/ chmod a+rx /root/cockpit/test/ chmod a+rx /root/cockpit chmod a+rx /root # build the VM image with the new cockpit # NOTE: you need to run it again after any change in the source code! # (IIRC even after changing the tests!) test/image-prepare # run the selected testsuite test/verify/check-networkmanager-firewall # or run just a single test test/verify/check-networkmanager-firewall TestFirewall.testPkcheckMissing HTH Ladislav [1] https://github.com/cockpit-project/cockpit/pull/17776 [2] https://github.com/cockpit-project/cockpit/blob/main/test/README.md -- Ladislav Slezák YaST Developer SUSE LINUX, s.r.o. Corso IIa Křižíkova 148/34 18600 Praha 8
On Mon, 19 Dec 2022 16:44:02 +0100
Ladislav Slezák
Dne 29. 09. 22 v 15:52 Ladislav Slezák napsal(a):
recently I fixed a small bug in cockpit [1]. The fix is rather trivial but it was quite difficult to test it and verify that it really fixes the problem.
I'm adding some more details about the integration tests.
Adding a new test was pretty simple (just check whether the switch is enabled or disabled in the browser), but most difficult was to run the test and verify that it really works.
I followed their README [2], but I was not successful in openSUSE, I was getting some strange errors. It needs some Python libraries not available in openSUSE, I tried to install them via "pip" but it still failed. I that point I gave up and installed Fedora Server 36.
If we will need to do it more often, we can create reusable VM deployment for cockpit testing at our internal servers and document how to reuse it. Josef
<snip>
participants (2)
-
josef Reidinger
-
Ladislav Slezák