New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to run deamon for use of test on mock environment #137

Closed
junaruga opened this Issue Nov 24, 2017 · 3 comments

Comments

Projects
None yet
2 participants
@junaruga

junaruga commented Nov 24, 2017

Hi,

I want to run daemon service (MariaDB = MySQL) in %check section on mock environment to test below Ruby MySQL connecter.
https://src.fedoraproject.org/fork/jaruga/rpms/rubygem-mysql2/blob/feature/update-to-0.4.10-for-report/f/rubygem-mysql2.spec
Also the build log for the scratch build.
https://kojipkgs.fedoraproject.org//work/tasks/5922/23345922/build.log

I am using the last version mock. Maybe.

$ rpm -q mock
mock-1.4.7-2.fc26.noarch

The situation is.

the MySQL daemon's default port is listen status though I have not run the daemon by myself, when I entered with mock environment.

<mock-chroot> sh-4.4# ss -ltnp
State       Recv-Q Send-Q  Local Address:Port                 Peer Address:Port              
LISTEN      0      128           0.0.0.0:111                       0.0.0.0:*                  
LISTEN      0      5       192.168.122.1:53                        0.0.0.0:*                  
LISTEN      0      5           127.0.0.1:631                       0.0.0.0:*                  
LISTEN      0      128         127.0.0.1:27017                     0.0.0.0:*                  
LISTEN      0      128              [::]:111                          [::]:*                  
LISTEN      0      5               [::1]:631                          [::]:*                  
LISTEN      0      128             [::1]:27017                        [::]:*                  
LISTEN      0      80                  *:3306                            *:* 
<mock-chroot> sh-4.4# ps -wwef | grep mysqld

=> No result

Regardless of that my below local host environment is like this.

$ ps -wwef | grep mysqld
mysql    14066     1  0 Nov23 ?        00:00:28 /usr/libexec/mysqld --basedir=/usr

The mysqld service looks not started normally.

<mock-chroot> sh-4.4# mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

systemctl is something wrong.

<mock-chroot> sh-4.4# systemctl status mysqld
Failed to connect to bus: No such file or directory

<mock-chroot> sh-4.4# systemctl --user
Failed to connect to bus: No such file or directory

How to run systemd's service in %check section?
We only have to run the deamon (mysqld) directly without using systemd to use it in %check section?

@xsuchy

This comment has been minimized.

Show comment
Hide comment
@xsuchy

xsuchy Nov 24, 2017

Member

This is an example I just have stolen from glpi package:

: Running a MariaDB server
MYSQL_TEST_HOST=127.0.0.1
MYSQL_TEST_PORT=3308
MYSQL_TEST_SOCKET=$PWD/mysql.sock
MYSQL_PID_FILE=$PWD/mysql.pid

rm -rf data
mkdir  data
: Create the Database
%{_bindir}/mysql_install_db \
   --log-error=$PWD/mysql.log \
   --datadir=$PWD/data

: Launch the Server
%{_libexecdir}/mysqld \
   --socket=$MYSQL_TEST_SOCKET \
   --log-error=$PWD/mysql.log \
   --pid-file=$MYSQL_PID_FILE \
   --port=$MYSQL_TEST_PORT \
   --datadir=$PWD/data &

n=15
while [ $n -gt 0 ]; do
  RESPONSE=$(%{_bindir}/mysqladmin --no-defaults --socket="$MYSQL_TEST_SOCKET" --user=root ping 2>&1 || :)
  if [ "$RESPONSE" == "mysqld is alive" ]; then
    break
  fi
  n=$(expr $n - 1)
  sleep 1
done

:Do some tests here

: Cleanup
if [ -s $MYSQL_PID_FILE ]; then
  kill $(cat $MYSQL_PID_FILE)
fi
kill $PHPPID || :
Member

xsuchy commented Nov 24, 2017

This is an example I just have stolen from glpi package:

: Running a MariaDB server
MYSQL_TEST_HOST=127.0.0.1
MYSQL_TEST_PORT=3308
MYSQL_TEST_SOCKET=$PWD/mysql.sock
MYSQL_PID_FILE=$PWD/mysql.pid

rm -rf data
mkdir  data
: Create the Database
%{_bindir}/mysql_install_db \
   --log-error=$PWD/mysql.log \
   --datadir=$PWD/data

: Launch the Server
%{_libexecdir}/mysqld \
   --socket=$MYSQL_TEST_SOCKET \
   --log-error=$PWD/mysql.log \
   --pid-file=$MYSQL_PID_FILE \
   --port=$MYSQL_TEST_PORT \
   --datadir=$PWD/data &

n=15
while [ $n -gt 0 ]; do
  RESPONSE=$(%{_bindir}/mysqladmin --no-defaults --socket="$MYSQL_TEST_SOCKET" --user=root ping 2>&1 || :)
  if [ "$RESPONSE" == "mysqld is alive" ]; then
    break
  fi
  n=$(expr $n - 1)
  sleep 1
done

:Do some tests here

: Cleanup
if [ -s $MYSQL_PID_FILE ]; then
  kill $(cat $MYSQL_PID_FILE)
fi
kill $PHPPID || :

@xsuchy xsuchy closed this Nov 24, 2017

@junaruga

This comment has been minimized.

Show comment
Hide comment
@junaruga

junaruga Nov 24, 2017

We only have to run the deamon (mysqld) directly without using systemd to use it in %check section?

Thanks for the answer. The code is helpful.
So, your answer means that we only can run the daemon with anther port without using systemd.

junaruga commented Nov 24, 2017

We only have to run the deamon (mysqld) directly without using systemd to use it in %check section?

Thanks for the answer. The code is helpful.
So, your answer means that we only can run the daemon with anther port without using systemd.

@xsuchy

This comment has been minimized.

Show comment
Hide comment
@xsuchy

xsuchy Nov 25, 2017

Member

Yes.

Member

xsuchy commented Nov 25, 2017

Yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment