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
Add tutorial for running tests with Docker #2768
Add tutorial for running tests with Docker #2768
Conversation
It is okay but you do not need different accounts for different PRs. You can simply create different branches and create a PR for each of the branches. See https://help.github.com/en/articles/creating-a-pull-request |
Why is the build failing this time?! I haven't changed any code in the PR..... I added the release note. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice tutorial.
@@ -0,0 +1,109 @@ | |||
# Introduction | |||
|
|||
Running all the tests like the build server does it requires to have multiple dependencies preinstalled. To overcome this problem, instead of trying to install all the necessary dependencies on your own, an appropriate Docker image should be used. This way you can easily and quickly run all the tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running all the tests like the build server does it requires to have multiple dependencies preinstalled. To overcome this problem, instead of trying to install all the necessary dependencies on your own, an appropriate Docker image should be used. This way you can easily and quickly run all the tests. | |
Running all the tests like the build server requires to have multiple dependencies installed. To overcome this problem, instead of trying to install all the necessary dependencies on your own, an appropriate Docker image can be used. This way you can easily and quickly run all the tests. |
|
||
## Who is this guide for? | ||
|
||
For anyone who wants to run all the tests, like it is done by the build server, once changes are pushed to the repository. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For anyone who wants to run all the tests, like it is done by the build server, once changes are pushed to the repository. | |
For anyone who wants to run all the tests, like it is done by the build server. |
|
||
### 1. Pick a Docker image and pull it | ||
|
||
Pick one of the available Docker images of Elektra. If you do not know the difference, just pick this one --> "build-elektra-debian-stretch". Unfortunately, it will take some time to download it, since it is pretty big, but you can be sure you'll have all the needed dependencies. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe also suggest some alpine image as alternative for slow connections.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I thought it was not possible to run all tests with the alpine image. If it is possible, then I can suppest using it in the tutorial.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes you are right but you can also mention this limitation in the tutorial.
docker pull <image_name>:<tag_name> | ||
``` | ||
|
||
EXAMPLE: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EXAMPLE: | |
Example: |
<image_name>:<tag_name> | ||
``` | ||
|
||
EXAMPLE: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EXAMPLE: | |
Example: |
### 3. Build | ||
|
||
|
||
After starting the contrainer, you should be automatically inside it in the working directory we set --> /home/jenkins/workspace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After starting the contrainer, you should be automatically inside it in the working directory we set --> /home/jenkins/workspace | |
After starting the container, you should be automatically inside it in the working directory `/home/jenkins/workspace`. |
|
||
After starting the contrainer, you should be automatically inside it in the working directory we set --> /home/jenkins/workspace | ||
|
||
Create folder for building project |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sentence incomplete? Or should this be a header?
Finally run the tests | ||
```sh | ||
make run_all | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also describe how to install Elektra and run the installed tests (kdb run_all
). Please also link to doc/TESTING.md.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean? Elektra is built within the container anyway. Why do we need to install it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To also install Elektra make install
and run then the installed tests. The build server also does this and it is possible that the installed tests have different results (e.g. if test data is missing). See scripts/jenkins/Jenkinsfile
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I didn't know it. So basically before executing make run_all
make install
should be executed first?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, some tests only run if Elektra is installed.
And there is a second set of tests to be executed with:
kdb run_all
These tests also need an installed Elektra.
If your tutorial should cover how to execute all tests, you should mention this.
Simply read what the build server tells you. (You might need to change between the pipeline steps, as not always the faulty one opens). The problem seems that you need to reformat markdown. Will you describe the reformatting in a separate tutorial? |
|
||
### 1. Pick a Docker image and pull it | ||
|
||
Pick one of the available Docker images of Elektra. If you do not know the difference, just pick this one --> "build-elektra-debian-stretch". Unfortunately, it will take some time to download it, since it is pretty big, but you can be sure you'll have all the needed dependencies. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I thought it was not possible to run all tests with the alpine image. If it is possible, then I can suppest using it in the tutorial.
Finally run the tests | ||
```sh | ||
make run_all | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean? Elektra is built within the container anyway. Why do we need to install it?
Now these tests in mac fail
The Cirrurs CI say it failed due to following error:
What does it have to do with my tiny change that does not even involve code? If I get that many errors after trying to push a text file, I wonder if it is even possible to finish resolving my other issue with a lot of code changes... |
Those tests are known to fail quite regularly. I restarted the failing build job |
Oh, thank you very much! It is good to hear. |
@markus2330 I took into consideration all your comments and pushed some more changes. Before I did this, I saw all the build checks finally succeeded. Can you please merge this PR then? |
We need to wait for the build server and maybe other reviewers. I did not check if the code actually works yet. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I followed the steps described in the tutorial. My computer reported a few failing tests:
testshell_markdown_tutorial_cascading
,testshell_markdown_tutorial_validation
,testkdb_error
, andtestkdb_ensure
, and minor problems with the install procedure. Those problems might be related to my host OS (macOS 10.14.5
) though.
make install | ||
``` | ||
|
||
The number 10 can be changed as follows: number of supported simultaneous threads by your CPU + 2. But don't worry, this can only affect the speed of the building, it cannot really break it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would make sense to move these instructions closer to the command make -j 10
. Right below the command would be one good option in my opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done it. Thank you!
Just run this command: | ||
|
||
```sh | ||
make install |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This step fails on my machine with the error:
-- Install configuration: "RelWithDebInfo"
CMake Error at cmake_install.cmake:36 (file):
file cannot create directory: /usr/local/share/doc/elektra. Maybe need
administrative privileges.
Makefile:72: recipe for target 'install' failed
make: *** [install] Error 1
. It might make sense to add the option -DINSTALL_SYSTEM_FILES=OFF
to the cmake
command above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your comment! Now I am getting this error too... Unfortunately, adding -DINSTALL_SYSTEM_FILES=OFF did not help. Does anyone have a suggestion on how to solve it? @markus2330
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think setting CMAKE_INSTALL_PREFIX
to a newly created folder inside the repository (e.g. "$PWD/install"
) should help.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am sorry, but I don't understand what do you mean. Can you make an example?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make an example?
Just replace the current cmake
command with:
cmake .. \
-DBINDINGS="ALL;-DEPRECATED;-haskell" \
-DPLUGINS="ALL;-DEPRECATED" \
-DTOOLS="ALL" \
-DENABLE_DEBUG=ON \
-DKDB_DB_HOME="$PWD" \
-DKDB_DB_SYSTEM="$PWD/.config/kdb/system" \
-DKDB_DB_SPEC="$PWD/.config/kdb/system" \
-DCMAKE_INSTALL_PREFIX="$PWD/install" \
-DINSTALL_SYSTEM_FILES=OFF
, and installing should work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am using Ubuntu 18.04 in a virtual machine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am using Ubuntu 18.04 in a virtual machine.
Interesting. Would it not make more sense to just use Docker directly? Anyway, it would be great, if someone who uses Linux as main OS, could check if the tests also fail on their machine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could not install Elektra on Windows, so I decided to work entirely in a Linux virtual machine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could not install Elektra on Windows, so I decided to work entirely in a Linux virtual machine.
What did you try? Can you write an issue about that please?
Interesting. Would it not make more sense to just use Docker directly?
Yes, I also wonder why you do not use docker directly?
Anyway, it would be great, if someone who uses Linux as main OS, could check if the tests also fail on their machine.
I can reproduce the same problem (3 failed tests:testshell_markdown_tutorial_cascading testshell_markdown_tutorial_validation testkdb_ensure). Something is tidy inside the docker image.
Please report these three issues separately, they seems to be unrelated to this tutorial.
@sanssecours any idea why our build server does not catch this problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sanssecours any idea why our build server does not catch this problem?
Nope.
Thank you for the review! @oleksandr-shabelnyk please fix the CMake command so that the tutorial actually works as described. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
|
||
```sh | ||
mkdir build-docker && cd build-docker | ||
mkdir build-docker && cd build-docker && mkdir install |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mkdir -p build-docker/install && cd build-docker
is shorter and more fail-safe
But, in any way, I get:
mkdir: cannot create directory ‘build-docker’: Permission denied
because the folder is owned by uid/gid 1000, which is not the user in docker (id -u
47110)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I am going to fix it.
Just run this command: | ||
|
||
```sh | ||
make install |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could not install Elektra on Windows, so I decided to work entirely in a Linux virtual machine.
What did you try? Can you write an issue about that please?
Interesting. Would it not make more sense to just use Docker directly?
Yes, I also wonder why you do not use docker directly?
Anyway, it would be great, if someone who uses Linux as main OS, could check if the tests also fail on their machine.
I can reproduce the same problem (3 failed tests:testshell_markdown_tutorial_cascading testshell_markdown_tutorial_validation testkdb_ensure). Something is tidy inside the docker image.
Please report these three issues separately, they seems to be unrelated to this tutorial.
@sanssecours any idea why our build server does not catch this problem?
|
||
Finally run the tests. There are two sets of tests. Run the first one with this command: | ||
|
||
```sh | ||
make run_all | ||
``` | ||
|
||
For the second set to run remember to execute `make install` from the previous step. Run the second set with this command: | ||
For the second set to run, remember to execute `make install` from the previous step. Run the second set with this command: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make kdb run_all
work more than setting the PATH is needed. (Also export LD_LIBRARY_PATH="$PWD/install/lib:$PATH"
).
But even then the testkdb_ensure fails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What did you try? Can you write an issue about that please?
It was 4 months ago. I really do not remember what I did back then.
Yes, I also wonder why you do not use docker directly?
My whole dev environment is inside this VM. On my host OS, Windows, it is hard to map volumes. And there sometimes problems with the rights.
Please report these three issues separately, they seems to be unrelated to this tutorial.
Ok, you mean
- Failing tests
- Windows installation problems
- What is the 3rd issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make
kdb run_all
work more than setting the PATH is needed. (Alsoexport LD_LIBRARY_PATH="$PWD/install/lib:$PATH"
).But even then the testkdb_ensure fails.
Thank you! I will add it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As 3rd issue, you probably meant failing tests with kdb run_all. I added it as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed everything you requested. Is it OK now? I am really running extremely out of time with all these changes...
The building seems to get stuck. Can you restart it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still not fixed?
@@ -67,7 +66,7 @@ So from your root project folder run the following: | |||
docker run -it --rm \ | |||
-v "$PWD:/home/jenkins/workspace" \ | |||
-w /home/jenkins/workspace \ | |||
<image_name>:<tag_name> | |||
hub-public.libelektra.org/<image_name>:<tag_name> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here the user discussed in the issue #2781 is still missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The proposed solution introduces other problems. If running with the current user, not just 1 test fails, but around 20 of them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like the problem can only be fixed if you build the docker container correctly. See scripts/docker/README.md
|
||
Example: | ||
|
||
```sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you remove the example?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It showed how to run a container created from a public image. Since we do not recommend it, I thought it is not needed anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought you will simply leave this part and say it is not recommended.
@markus2330 As suggested today by you, I inspected the jenkinsfile. I saw some mismatches in the cmake options and corrected/added some. This fixed the
I literally have no idea at all how to fix it. |
These are very good news! I think lua needs |
Perfect! It solved the problem! Thank you very much! All tests run with |
Just tried to run another batch of the tests with |
Great job! |
@markus2330 Please review this tutorial. Unfortunately, since a I have a lot of pending changes for another issue, I could not create a separate PR just for this tutorial, so I had to do it from my different account, not from @alexsaber . I hope it is OK for you.
Basics
doc/news/_preparation_next_release.md
which contains_(my name)_
)Please always add something to the the release notes.
(first line should have
module: short statement
syntax)close #X
, should be in the commit messages.Checklist
Check relevant points but please do not remove entries.
For docu fixes, spell checking, and similar none of these points below
need to be checked.
Review
Reviewers will usually check the following:
Labels
say that everything is ready to be merged.