diff --git a/specs/valkey/SOURCES/sentinel-72-config.patch b/specs/valkey/SOURCES/sentinel-72-config.patch new file mode 100644 index 00000000..8893030d --- /dev/null +++ b/specs/valkey/SOURCES/sentinel-72-config.patch @@ -0,0 +1,27 @@ +diff --color -urN valkey-7.2.7-orig/sentinel.conf valkey-7.2.7/sentinel.conf +--- valkey-7.2.7-orig/sentinel.conf 2024-10-02 23:11:08.000000000 +0300 ++++ valkey-7.2.7/sentinel.conf 2024-12-20 15:59:42.000000000 +0300 +@@ -1,5 +1,3 @@ +-# Example sentinel.conf +- + # By default protected mode is disabled in sentinel mode. Sentinel is reachable + # from interfaces different than localhost. Make sure the sentinel instance is + # protected from the outside world via firewalling or other means. +@@ -17,7 +15,7 @@ + # When running daemonized, Valkey Sentinel writes a pid file in + # /var/run/valkey-sentinel.pid by default. You can specify a custom pid file + # location here. +-pidfile /var/run/valkey-sentinel.pid ++pidfile /var/run/valkey/sentinel.pid + + # Specify the server verbosity level. + # This can be one of: +@@ -31,7 +29,7 @@ + # Specify the log file name. Also the empty string can be used to force + # Sentinel to log on the standard output. Note that if you use standard + # output for logging but daemonize, logs will be sent to /dev/null +-logfile "" ++logfile /var/log/valkey/sentinel.log + + # To enable logging to the system logger, just set 'syslog-enabled' to yes, + # and optionally update the other syslog parameters to suit your needs. diff --git a/specs/valkey/SOURCES/sentinel-limit-systemd b/specs/valkey/SOURCES/sentinel-limit-systemd new file mode 100644 index 00000000..8003c2fc --- /dev/null +++ b/specs/valkey/SOURCES/sentinel-limit-systemd @@ -0,0 +1,7 @@ +# If you need to change max open file limit +# for example, when you change maxclient in configuration +# you can change the LimitNOFILE value below +# see "man systemd.exec" for information + +[Service] +LimitNOFILE=10240 diff --git a/specs/valkey/SOURCES/sentinel.logrotate b/specs/valkey/SOURCES/sentinel.logrotate new file mode 100644 index 00000000..4b553903 --- /dev/null +++ b/specs/valkey/SOURCES/sentinel.logrotate @@ -0,0 +1,9 @@ +/var/log/redis/sentinel.log { + weekly + rotate 10 + copytruncate + delaycompress + compress + notifempty + missingok +} diff --git a/specs/valkey/SOURCES/sentinel.service b/specs/valkey/SOURCES/sentinel.service new file mode 100644 index 00000000..4b41cf1d --- /dev/null +++ b/specs/valkey/SOURCES/sentinel.service @@ -0,0 +1,14 @@ +[Unit] +Description=Valkey Sentinel +Documentation=https://valkey.io/docs +After=syslog.target network.target + +[Service] +ExecStart=/usr/bin/valkey-sentinel /etc/sentinel.conf --daemonize no +KillSignal=SIGTERM +User=valkey +Group=valkey +PIDFile=/var/run/valkey/sentinel.pid + +[Install] +WantedBy=multi-user.target diff --git a/specs/valkey/SOURCES/valkey-72-config.patch b/specs/valkey/SOURCES/valkey-72-config.patch new file mode 100644 index 00000000..e72acb27 --- /dev/null +++ b/specs/valkey/SOURCES/valkey-72-config.patch @@ -0,0 +1,57 @@ +diff --color -urN valkey-7.2.7-orig/valkey.conf valkey-7.2.7/valkey.conf +--- valkey-7.2.7-orig/valkey.conf 2024-10-02 23:11:08.000000000 +0300 ++++ valkey-7.2.7/valkey.conf 2024-12-20 15:56:04.000000000 +0300 +@@ -84,7 +84,7 @@ + # You will also need to set a password unless you explicitly disable protected + # mode. + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +-bind 127.0.0.1 -::1 ++# bind 127.0.0.1 -::1 + + # By default, outgoing connections (from replica to master, from Sentinel to + # instances, cluster bus, etc.) are not bound to a specific local address. In +@@ -335,7 +335,7 @@ + # + # Note that on modern Linux systems "/run/valkey.pid" is more conforming + # and should be used instead. +-pidfile /var/run/valkey_6379.pid ++pidfile /var/run/valkey/valkey.pid + + # Specify the server verbosity level. + # This can be one of: +@@ -349,7 +349,7 @@ + # Specify the log file name. Also the empty string can be used to force + # the server to log on the standard output. Note that if you use standard + # output for logging but daemonize, logs will be sent to /dev/null +-logfile "" ++logfile /var/log/valkey/valkey.log + + # To enable logging to the system logger, just set 'syslog-enabled' to yes, + # and optionally update the other syslog parameters to suit your needs. +@@ -374,7 +374,7 @@ + # Set the number of databases. The default database is DB 0, you can select + # a different one on a per-connection basis using SELECT where + # dbid is a number between 0 and 'databases'-1 +-databases 16 ++databases 96 + + # By default the server shows an ASCII art logo only when started to log to the + # standard output and if the standard output is a TTY and syslog logging is +@@ -433,7 +433,7 @@ + # + # You can set these explicitly by uncommenting the following line. + # +-# save 3600 1 300 100 60 10000 ++save 3600 1 300 100 60 10000 + + # By default the server will stop accepting writes if RDB snapshots are enabled + # (at least one save point) and the latest background save failed. +@@ -504,7 +504,7 @@ + # The Append Only File will also be created inside this directory. + # + # Note that you must specify a directory here, not a file name. +-dir ./ ++dir /var/lib/valkey/ + + ################################# REPLICATION ################################# + diff --git a/specs/valkey/SOURCES/valkey-limit-systemd b/specs/valkey/SOURCES/valkey-limit-systemd new file mode 100644 index 00000000..8003c2fc --- /dev/null +++ b/specs/valkey/SOURCES/valkey-limit-systemd @@ -0,0 +1,7 @@ +# If you need to change max open file limit +# for example, when you change maxclient in configuration +# you can change the LimitNOFILE value below +# see "man systemd.exec" for information + +[Service] +LimitNOFILE=10240 diff --git a/specs/valkey/SOURCES/valkey.logrotate b/specs/valkey/SOURCES/valkey.logrotate new file mode 100644 index 00000000..f7c19605 --- /dev/null +++ b/specs/valkey/SOURCES/valkey.logrotate @@ -0,0 +1,9 @@ +/var/log/valkey/valkey.log { + weekly + rotate 10 + copytruncate + delaycompress + compress + notifempty + missingok +} diff --git a/specs/valkey/SOURCES/valkey.service b/specs/valkey/SOURCES/valkey.service new file mode 100644 index 00000000..8cb40588 --- /dev/null +++ b/specs/valkey/SOURCES/valkey.service @@ -0,0 +1,17 @@ +[Unit] +Description=Valkey +Documentation=https://valkey.io/docs +After=syslog.target network.target + +[Service] +Type=notify +ExecStart=/usr/bin/valkey-server /etc/valkey.conf --supervised systemd +KillSignal=SIGTERM +User=valkey +Group=valkey +PIDFile=/var/run/valkey/valkey.pid +TimeoutStartSec=15 +TimeoutStopSec=90 + +[Install] +WantedBy=multi-user.target diff --git a/specs/valkey/valkey.spec b/specs/valkey/valkey.spec new file mode 100644 index 00000000..c3f928ca --- /dev/null +++ b/specs/valkey/valkey.spec @@ -0,0 +1,195 @@ +################################################################################ + +%global crc_check pushd ../SOURCES ; sha512sum -c %{SOURCE100} ; popd + +################################################################################ + +%{!?_without_check: %define _with_check 1} + +################################################################################ + +%define major_ver 7 +%define minor_ver 2 + +################################################################################ + +Summary: A persistent key-value database +Name: valkey +Version: 7.2.7 +Release: 0%{?dist} +License: BSD +Group: Applications/Databases +URL: https://valkey.io + +Source0: https://github.com/valkey-io/%{name}/archive/%{version}.tar.gz +Source1: %{name}.logrotate +Source2: sentinel.logrotate +Source3: %{name}.service +Source4: sentinel.service +Source5: %{name}-limit-systemd +Source6: sentinel-limit-systemd + +Source100: checksum.sha512 + +Patch0: valkey-%{major_ver}%{minor_ver}-config.patch +Patch1: sentinel-%{major_ver}%{minor_ver}-config.patch + +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) + +BuildRequires: make gcc tcl systemd-devel + +Requires: %{name}-cli >= %{version} +Requires: logrotate + +Requires(pre): shadow-utils +Requires(post): systemd +Requires(preun): systemd +Requires(postun): systemd + +Conflicts: redis valkey72 + +Provides: %{name} = %{version}-%{release} +Provides: %{name}-server = %{version}-%{release} +Provides: %{name}-sentinel = %{version}-%{release} + +################################################################################ + +%description +Valkey is a high-performance data structure server that primarily serves +key/value workloads. It supports a wide range of native structures and an +extensible plugin system for adding new data structures and access patterns. + +################################################################################ + +%package cli + +Summary: Client for working with Valkey from console +Group: Applications/Databases + +%description cli +Client for working with Valkey from console + +################################################################################ + +%package devel + +Summary: Development header for Valkey module development +Group: Development/Libraries + +Provides: %{name}-static = %{version}-%{release} + +%description devel +Header file required for building loadable Valkey modules. + +################################################################################ + +%prep +%crc_check +%autosetup -p1 -n %{name}-%{version} + +%build +export BUILD_WITH_SYSTEMD=yes + +%{__make} %{?_smp_mflags} MALLOC=jemalloc + +%install +rm -rf %{buildroot} + +%{__make} install PREFIX=%{buildroot}%{_prefix} + +install -dm 755 %{buildroot}%{_sysconfdir} +install -dm 755 %{buildroot}%{_sysconfdir}/logrotate.d +install -dm 755 %{buildroot}%{_sysconfdir}/sysconfig + +install -pm 644 %{SOURCE1} %{buildroot}%{_sysconfdir}/logrotate.d/%{name} +install -pm 644 %{SOURCE2} %{buildroot}%{_sysconfdir}/logrotate.d/sentinel + +install -pm 640 %{name}.conf %{buildroot}%{_sysconfdir}/ +install -pm 640 sentinel.conf %{buildroot}%{_sysconfdir}/ + +install -dm 755 %{buildroot}%{_localstatedir}/lib/%{name} +install -dm 755 %{buildroot}%{_localstatedir}/log/%{name} +install -dm 755 %{buildroot}%{_localstatedir}/run/%{name} + +install -dm 755 %{buildroot}%{_unitdir} +install -dm 755 %{buildroot}%{_sysconfdir}/systemd/system/%{name}.service.d +install -dm 755 %{buildroot}%{_sysconfdir}/systemd/system/sentinel.service.d +install -pm 644 %{SOURCE3} %{buildroot}%{_unitdir}/ +install -pm 644 %{SOURCE4} %{buildroot}%{_unitdir}/ +install -pm 644 %{SOURCE5} %{buildroot}%{_sysconfdir}/systemd/system/%{name}.service.d/limit.conf +install -pm 644 %{SOURCE6} %{buildroot}%{_sysconfdir}/systemd/system/sentinel.service.d/limit.conf + +install -dm 755 %{buildroot}%{_includedir} +install -pm 644 src/redismodule.h %{buildroot}%{_includedir}/redismodule.h + +chmod 755 %{buildroot}%{_bindir}/%{name}-* + +rm -f %{buildroot}%{_bindir}/%{name}-sentinel + +install -dm 755 %{buildroot}%{_sbindir} + +ln -sf %{_bindir}/%{name}-server %{buildroot}%{_bindir}/%{name}-sentinel +ln -sf %{_bindir}/%{name}-server %{buildroot}%{_sbindir}/%{name}-server + +%check +%if %{?_with_check:1}%{?_without_check:0} +%{__make} %{?_smp_mflags} test +%{__make} %{?_smp_mflags} test-sentinel +%endif + +%pre +getent group %{name} &> /dev/null || groupadd -r %{name} &> /dev/null +getent passwd %{name} &> /dev/null || \ +useradd -r -g %{name} -d %{_sharedstatedir}/%{name} -s /sbin/nologin \ + -c 'Valkey Server' %{name} &> /dev/null + +%post +if [[ $1 -eq 1 ]] ; then + systemctl enable %{name}.service &>/dev/null || : +fi + +%preun +if [[ $1 -eq 0 ]] ; then + systemctl --no-reload disable %{name}.service &>/dev/null || : + systemctl --no-reload disable sentinel.service &>/dev/null || : + systemctl stop %{name}.service &>/dev/null || : + systemctl stop sentinel.service &>/dev/null || : +fi + +%postun +systemctl daemon-reload &>/dev/null || : + +################################################################################ + +%files +%defattr(-,root,root,-) +%doc 00-RELEASENOTES BUGS COPYING README.md +%attr(-,%{name},%{name}) %config(noreplace) %{_sysconfdir}/*.conf +%config(noreplace) %{_sysconfdir}/logrotate.d/%{name} +%config(noreplace) %{_sysconfdir}/logrotate.d/sentinel +%dir %attr(0755,%{name},root) %{_localstatedir}/lib/%{name} +%dir %attr(0755,%{name},root) %{_localstatedir}/log/%{name} +%dir %attr(0755,%{name},root) %{_localstatedir}/run/%{name} +%{_unitdir}/%{name}.service +%{_unitdir}/sentinel.service +%{_sysconfdir}/systemd/system/%{name}.service.d/limit.conf +%{_sysconfdir}/systemd/system/sentinel.service.d/limit.conf +%{_bindir}/%{name}-* +%{_bindir}/redis-* +%{_sbindir}/%{name}-server + +%files cli +%defattr(-,root,root,-) +%doc 00-RELEASENOTES BUGS COPYING README.md +%{_bindir}/%{name}-cli + +%files devel +%doc COPYING +%defattr(-,root,root,-) +%{_includedir}/redismodule.h + +################################################################################ + +%changelog +* Fri Dec 20 2024 Anton Novojilov - 7.2.7-0 +- https://github.com/valkey-io/valkey/blob/7.2.7/00-RELEASENOTES diff --git a/specs/valkey/valkey72.spec b/specs/valkey/valkey72.spec new file mode 100644 index 00000000..b59b710e --- /dev/null +++ b/specs/valkey/valkey72.spec @@ -0,0 +1,196 @@ +################################################################################ + +%global crc_check pushd ../SOURCES ; sha512sum -c %{SOURCE100} ; popd + +################################################################################ + +%{!?_without_check: %define _with_check 1} + +################################################################################ + +%define realname valkey +%define major_ver 7 +%define minor_ver 2 + +################################################################################ + +Summary: A persistent key-value database +Name: %{realname}%{major_ver}%{minor_ver} +Version: 7.2.7 +Release: 0%{?dist} +License: BSD +Group: Applications/Databases +URL: https://valkey.io + +Source0: https://github.com/valkey-io/%{realname}/archive/%{version}.tar.gz +Source1: %{realname}.logrotate +Source2: sentinel.logrotate +Source3: %{realname}.service +Source4: sentinel.service +Source5: %{realname}-limit-systemd +Source6: sentinel-limit-systemd + +Source100: checksum.sha512 + +Patch0: %{realname}-%{major_ver}%{minor_ver}-config.patch +Patch1: sentinel-%{major_ver}%{minor_ver}-config.patch + +BuildRoot: %{_tmppath}/%{realname}-%{version}-%{release}-root-%(%{__id_u} -n) + +BuildRequires: make gcc tcl systemd-devel + +Requires: %{name}-cli >= %{version} +Requires: logrotate + +Requires(pre): shadow-utils +Requires(post): systemd +Requires(preun): systemd +Requires(postun): systemd + +Conflicts: redis + +Provides: %{name} = %{version}-%{release} +Provides: %{name}-server = %{version}-%{release} +Provides: %{name}-sentinel = %{version}-%{release} + +################################################################################ + +%description +Valkey is a high-performance data structure server that primarily serves +key/value workloads. It supports a wide range of native structures and an +extensible plugin system for adding new data structures and access patterns. + +################################################################################ + +%package cli + +Summary: Client for working with Valkey from console +Group: Applications/Databases + +%description cli +Client for working with Valkey from console + +################################################################################ + +%package devel + +Summary: Development header for Valkey module development +Group: Development/Libraries + +Provides: %{name}-static = %{version}-%{release} + +%description devel +Header file required for building loadable Valkey modules. + +################################################################################ + +%prep +%crc_check +%autosetup -p1 -n %{realname}-%{version} + +%build +export BUILD_WITH_SYSTEMD=yes + +%{__make} %{?_smp_mflags} MALLOC=jemalloc + +%install +rm -rf %{buildroot} + +%{__make} install PREFIX=%{buildroot}%{_prefix} + +install -dm 755 %{buildroot}%{_sysconfdir} +install -dm 755 %{buildroot}%{_sysconfdir}/logrotate.d +install -dm 755 %{buildroot}%{_sysconfdir}/sysconfig + +install -pm 644 %{SOURCE1} %{buildroot}%{_sysconfdir}/logrotate.d/%{realname} +install -pm 644 %{SOURCE2} %{buildroot}%{_sysconfdir}/logrotate.d/sentinel + +install -pm 640 %{realname}.conf %{buildroot}%{_sysconfdir}/ +install -pm 640 sentinel.conf %{buildroot}%{_sysconfdir}/ + +install -dm 755 %{buildroot}%{_localstatedir}/lib/%{realname} +install -dm 755 %{buildroot}%{_localstatedir}/log/%{realname} +install -dm 755 %{buildroot}%{_localstatedir}/run/%{realname} + +install -dm 755 %{buildroot}%{_unitdir} +install -dm 755 %{buildroot}%{_sysconfdir}/systemd/system/%{realname}.service.d +install -dm 755 %{buildroot}%{_sysconfdir}/systemd/system/sentinel.service.d +install -pm 644 %{SOURCE3} %{buildroot}%{_unitdir}/ +install -pm 644 %{SOURCE4} %{buildroot}%{_unitdir}/ +install -pm 644 %{SOURCE5} %{buildroot}%{_sysconfdir}/systemd/system/%{realname}.service.d/limit.conf +install -pm 644 %{SOURCE6} %{buildroot}%{_sysconfdir}/systemd/system/sentinel.service.d/limit.conf + +install -dm 755 %{buildroot}%{_includedir} +install -pm 644 src/redismodule.h %{buildroot}%{_includedir}/redismodule.h + +chmod 755 %{buildroot}%{_bindir}/%{realname}-* + +rm -f %{buildroot}%{_bindir}/%{realname}-sentinel + +install -dm 755 %{buildroot}%{_sbindir} + +ln -sf %{_bindir}/%{realname}-server %{buildroot}%{_bindir}/%{realname}-sentinel +ln -sf %{_bindir}/%{realname}-server %{buildroot}%{_sbindir}/%{realname}-server + +%check +%if %{?_with_check:1}%{?_without_check:0} +%{__make} %{?_smp_mflags} test +%{__make} %{?_smp_mflags} test-sentinel +%endif + +%pre +getent group %{realname} &> /dev/null || groupadd -r %{realname} &> /dev/null +getent passwd %{realname} &> /dev/null || \ +useradd -r -g %{realname} -d %{_sharedstatedir}/%{realname} -s /sbin/nologin \ + -c 'Valkey Server' %{realname} &> /dev/null + +%post +if [[ $1 -eq 1 ]] ; then + systemctl enable %{realname}.service &>/dev/null || : +fi + +%preun +if [[ $1 -eq 0 ]] ; then + systemctl --no-reload disable %{realname}.service &>/dev/null || : + systemctl --no-reload disable sentinel.service &>/dev/null || : + systemctl stop %{realname}.service &>/dev/null || : + systemctl stop sentinel.service &>/dev/null || : +fi + +%postun +systemctl daemon-reload &>/dev/null || : + +################################################################################ + +%files +%defattr(-,root,root,-) +%doc 00-RELEASENOTES BUGS COPYING README.md +%attr(-,%{realname},%{realname}) %config(noreplace) %{_sysconfdir}/*.conf +%config(noreplace) %{_sysconfdir}/logrotate.d/%{realname} +%config(noreplace) %{_sysconfdir}/logrotate.d/sentinel +%dir %attr(0755,%{realname},root) %{_localstatedir}/lib/%{realname} +%dir %attr(0755,%{realname},root) %{_localstatedir}/log/%{realname} +%dir %attr(0755,%{realname},root) %{_localstatedir}/run/%{realname} +%{_unitdir}/%{realname}.service +%{_unitdir}/sentinel.service +%{_sysconfdir}/systemd/system/%{realname}.service.d/limit.conf +%{_sysconfdir}/systemd/system/sentinel.service.d/limit.conf +%{_bindir}/%{realname}-* +%{_bindir}/redis-* +%{_sbindir}/%{realname}-server + +%files cli +%defattr(-,root,root,-) +%doc 00-RELEASENOTES BUGS COPYING README.md +%{_bindir}/%{realname}-cli + +%files devel +%doc COPYING +%defattr(-,root,root,-) +%{_includedir}/redismodule.h + +################################################################################ + +%changelog +* Fri Dec 20 2024 Anton Novojilov - 7.2.7-0 +- https://github.com/valkey-io/valkey/blob/7.2.7/00-RELEASENOTES diff --git a/tests/valkey/valkey.recipe b/tests/valkey/valkey.recipe new file mode 100644 index 00000000..265a4b2b --- /dev/null +++ b/tests/valkey/valkey.recipe @@ -0,0 +1,91 @@ +# Bibop recipe for Valkey +# See more: https://kaos.sh/bibop + +pkg valkey valkey-cli + +require-root yes +unsafe-actions yes + +var service_user valkey +var service_group valkey +var service_name valkey + +var valkey_config /etc/valkey.conf +var sentinel_config /etc/sentinel.conf +var valkey_logrotate /etc/logrotate.d/valkey +var sentinel_logrotate /etc/logrotate.d/sentinel + +var dump_file /var/lib/valkey/dump.rdb +var log_file /var/log/valkey/valkey.log + +command "-" "Check environment" + app valkey-server + app valkey-sentinel + app valkey-benchmark + app valkey-check-aof + app valkey-check-rdb + app valkey-cli + + service-present valkey + service-present sentinel + + user-exist {service_user} + group-exist {service_group} + + exist {valkey_config} + mode {valkey_config} 640 + exist {sentinel_config} + mode {sentinel_config} 640 + + exist {valkey_logrotate} + mode {valkey_logrotate} 644 + exist {sentinel_logrotate} + mode {sentinel_logrotate} 644 + + exist /var/lib/{service_name} + owner /var/lib/{service_name} {service_user} + + exist /var/run/{service_name} + owner /var/run/{service_name} {service_user} + + exist /var/log/{service_name} + owner /var/log/{service_name} {service_user} + +command "systemctl start {service_name}" "Start Valkey service" + wait-service {service_name} 5 + connect tcp :6379 + +command "systemctl status {service_name}" "Check status of Valkey service" + expect "active (running)" + +command "systemctl restart {service_name}" "Restart Valkey service" + wait-service {service_name} 5 + connect tcp :6379 + +command "valkey-cli SET TEST ACBD1234" "Set test key" + exit 0 + +command "valkey-cli GET TEST" "Get test key" + exit 0 + output-contains "ACBD1234" + +command "valkey-cli CONFIG GET logfile" "Check Valkey Client" + exit 0 + output-contains "{log_file}" + +command "valkey-cli SAVE" "Create database dump" + exit 0 + ++command "-" "Check created dump file" + wait-fs {dump_file} 5 + + exist {dump_file} + mode {dump_file} 644 + owner {dump_file} {service_user} + +command "systemctl stop {service_name}" "Stop Valkey service" + !wait-service {service_name} 5 + !connect tcp :6379 + +command "-" "Cleanup" + remove {dump_file} diff --git a/tests/valkey/valkey72.recipe b/tests/valkey/valkey72.recipe new file mode 100644 index 00000000..6705f18b --- /dev/null +++ b/tests/valkey/valkey72.recipe @@ -0,0 +1,90 @@ +# Bibop recipe for Valkey 7.2.x +# See more: https://kaos.sh/bibop + +pkg valkey72 valkey72-cli + +require-root yes +unsafe-actions yes + +var service_user valkey +var service_group valkey +var service_name valkey + +var valkey_config /etc/valkey.conf +var sentinel_config /etc/sentinel.conf +var valkey_logrotate /etc/logrotate.d/valkey +var sentinel_logrotate /etc/logrotate.d/sentinel + +var dump_file /var/lib/valkey/dump.rdb +var log_file /var/log/valkey/valkey.log + +command "-" "Check environment" + app valkey-server + app valkey-sentinel + app valkey-benchmark + app valkey-check-aof + app valkey-check-rdb + app valkey-cli + + service-present valkey + service-present sentinel + + user-exist {service_user} + group-exist {service_group} + + exist {valkey_config} + mode {valkey_config} 640 + exist {sentinel_config} + mode {sentinel_config} 640 + + exist {valkey_logrotate} + mode {valkey_logrotate} 644 + exist {sentinel_logrotate} + mode {sentinel_logrotate} 644 + + exist /var/lib/{service_name} + owner /var/lib/{service_name} {service_user} + + exist /var/run/{service_name} + owner /var/run/{service_name} {service_user} + + exist /var/log/{service_name} + owner /var/log/{service_name} {service_user} + +command "systemctl start {service_name}" "Start Valkey service" + wait-service {service_name} 5 + connect tcp :6379 + +command "systemctl status {service_name}" "Check status of Valkey service" + expect "active (running)" + +command "systemctl restart {service_name}" "Restart Valkey service" + wait-service {service_name} 5 + connect tcp :6379 + +command "valkey-cli SET TEST ACBD1234" "Set test key" + exit 0 + +command "valkey-cli GET TEST" "Get test key" + exit 0 + output-contains "ACBD1234" + +command "valkey-cli CONFIG GET logfile" "Check Valkey Client" + exit 0 + output-contains "{log_file}" + +command "valkey-cli SAVE" "Create database dump" + exit 0 + ++command "-" "Check created dump file" + wait-fs {dump_file} 5 + exist {dump_file} + mode {dump_file} 644 + owner {dump_file} {service_user} + +command "systemctl stop {service_name}" "Stop Valkey service" + !wait-service {service_name} 5 + !connect tcp :6379 + +command "-" "Cleanup" + remove {dump_file}