<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Paweł Płotka</title>
    <description>The latest articles on DEV Community by Paweł Płotka (@plotek).</description>
    <link>https://dev.to/plotek</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F136321%2Fd29d5f95-6b8f-4c6b-ae34-708f0b6512a6.jpg</url>
      <title>DEV Community: Paweł Płotka</title>
      <link>https://dev.to/plotek</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/plotek"/>
    <language>en</language>
    <item>
      <title>A few words of shared understanding, i.e. a review of Jeff Patton's books User Story Mapping</title>
      <dc:creator>Paweł Płotka</dc:creator>
      <pubDate>Wed, 01 Sep 2021 14:11:16 +0000</pubDate>
      <link>https://dev.to/plotek/a-few-words-of-shared-understanding-i-e-a-review-of-jeff-patton-s-books-user-story-mapping-2enl</link>
      <guid>https://dev.to/plotek/a-few-words-of-shared-understanding-i-e-a-review-of-jeff-patton-s-books-user-story-mapping-2enl</guid>
      <description>&lt;p&gt;Recently I have finished &lt;a href="https://www.amazon.com/User-Story-Mapping-Discover-Product/dp/1491904909"&gt;Jeff Patton's books &lt;em&gt;User Story Mapping&lt;/em&gt;&lt;/a&gt;. As we can read in the book summary, Jeff will explain the technique called user story mapping. In practice, in his book, the author shows us plenty of real-world examples, all of which serve another goal of usage story mapping and the consequences of not using it. So, we have the example of Gary, who is a music producer. Thanks to the story mapping, Gary was able to search the big picture and limit the scope of the project.&lt;br&gt;
 &lt;br&gt;
More examples discover other possible usages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;using user story mapping to coordinate work of teams &lt;/li&gt;
&lt;li&gt;using user story mapping to better estimation&lt;/li&gt;
&lt;li&gt;using user stories to choose features for MVP and then faster validate this MVP&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In each example, Jeff smuggles a few tips on how to lead a user story workshop. Despite this, I regard this book too long and its examples too detailed. The actual content could easily fit in half of the book’s length.&lt;/p&gt;

&lt;p&gt;For me, the main takeaway is shared understanding being the most vital. All stakeholders should understand the system goal and its features in the same way, which is more important than good written, detailed documentation. &lt;/p&gt;

&lt;p&gt;On my scale, the book gets &lt;a href="https://www.goodreads.com/review/show/4001253486?book_show_action=false"&gt;3/5&lt;/a&gt;. I recommend these books to every developer that would like to be more than only a coder. &lt;/p&gt;

</description>
      <category>book</category>
      <category>review</category>
      <category>userstorymapping</category>
      <category>userstory</category>
    </item>
    <item>
      <title>Insomnia - transform Collection to Document.</title>
      <dc:creator>Paweł Płotka</dc:creator>
      <pubDate>Wed, 21 Jul 2021 03:19:37 +0000</pubDate>
      <link>https://dev.to/plotek/insomnia-transfom-collection-to-document-931</link>
      <guid>https://dev.to/plotek/insomnia-transfom-collection-to-document-931</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;This post comes from a series of short tips, where I publish brief stories on how I resolve every day small (and sometimes easy) issues.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Some time ago, Insomnia added a new type of project called Document Design. It allows you to group and share API specifications, requests, and unit tests in one application. &lt;/p&gt;

&lt;p&gt;The implementation of this change has brought forth the following result: there are now two types of workspace - &lt;strong&gt;Design Document&lt;/strong&gt; and &lt;strong&gt;Request Collection&lt;/strong&gt;. Having run the research, I discovered that the new features may be attractive for me and might improve my work with APIs. This has encouraged me to try a new type.&lt;/p&gt;

&lt;p&gt;However, I came across one problem: how to transform one project type into another. A built-in feature is nowhere to be found. So, the first thing I did was create a ticket to support. The answer came in immediately (big thanks to Insomnia's support). Next, following the support’s suggestion, I created the &lt;a href="https://github.com/Kong/insomnia/discussions/3833"&gt;issue on Github&lt;/a&gt;. But…I needed solutions for that moment. Thus, I compared two import files and found certain differences, the result of which I‘m presenting the instructions below. &lt;/p&gt;

&lt;p&gt;When you have a project of Request Collection type in Insomnia and you’d like to transform it into Document Design type, you must follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Export current project (Request Collection) with &lt;code&gt;Insomnia v4 JSON&lt;/code&gt; format.&lt;/li&gt;
&lt;li&gt;Remove this project from Insomnia.&lt;/li&gt;
&lt;li&gt;Open the exported file in your favorite text editor. &lt;/li&gt;
&lt;li&gt;Find JSON section where parameter &lt;code&gt;_type&lt;/code&gt; has value &lt;code&gt;workspace&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Change the value of parameter &lt;code&gt;scope&lt;/code&gt; from &lt;code&gt;collection&lt;/code&gt; to &lt;code&gt;design&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Import (go to &lt;strong&gt;Application&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Preferences&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Data&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Import&lt;/strong&gt; -&amp;gt; &lt;strong&gt;From File&lt;/strong&gt;) this document as the new project. &lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>tools</category>
      <category>insomnia</category>
    </item>
    <item>
      <title>Wordpress - Move cron jobs to CLI</title>
      <dc:creator>Paweł Płotka</dc:creator>
      <pubDate>Sun, 20 Jun 2021 19:04:22 +0000</pubDate>
      <link>https://dev.to/plotek/wordpress-move-cron-jobs-to-cli-kgg</link>
      <guid>https://dev.to/plotek/wordpress-move-cron-jobs-to-cli-kgg</guid>
      <description>&lt;p&gt;Some time ago we started to observe performance issues in our company’s site built with WordPress. One of the issues we have observed was calling crons in random user requests. It is realized by calling URL &lt;code&gt;https://yourdomain.com/wp-cron.php&lt;/code&gt;. Although in this file WordPress calls PHP method &lt;code&gt;fastcgi_finish_request&lt;/code&gt;, which sends a response to the user as soon as possible, the cost of calling sub-requests during the main request is worth acknowledging and improving. There are other drawbacks of this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Calling crons in request context means that it is limited, e.g. by php-fpm setting. We often have limited resources (such as memory or time limit) for HTTP requests. &lt;/li&gt;
&lt;li&gt;What’s worse, calling cron as http request utilizes resource (e.g. php-fpm pools that might be necessary to handle our traffic). &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On the Internet, there are a lot of tips on how to disable making subrequest to call crons and move them to CLI. But there is one problem. A lot of these tips suggest calling these scheduled tasks using &lt;code&gt;crontab&lt;/code&gt; by calling curl (or other http callings). This addressed first problem and makes user request free of sub-requests, but does not resolve two abovementioned problems. It is surprising because WordPress comes with &lt;code&gt;wp cron&lt;/code&gt; command, which supports running scheduled tasks in CLI without making HTTP calls. &lt;/p&gt;

&lt;p&gt;In order to do this, you have to add one line to your crontab:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;*/5 * * * * wp cron event run --due-now --path=path_to_your_wp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this case, we call the scheduled task every 5 minutes. WordPress is responsible for choosing a concrete task to run and runs it. &lt;/p&gt;

&lt;p&gt;Of course, you also have to disable calling sub-request to &lt;code&gt;/wp-cron.php&lt;/code&gt; file. In order to do that, add the following to your wp-config.php file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nb"&gt;define&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'DISABLE_WP_CRON'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In my opinion, you should also deny access to &lt;code&gt;wp-cron.php&lt;/code&gt; file (because some bots might DDoS our site requesting this endpoint). I suggest making it on the application server level. For example, if you use Nginx,  add the following to your host configuration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;location = /wp/wp-cron.php { deny all; }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>wordpress</category>
      <category>devops</category>
    </item>
    <item>
      <title>Sylius Behat scenarios in Chrome Headless inside Docker</title>
      <dc:creator>Paweł Płotka</dc:creator>
      <pubDate>Mon, 24 May 2021 18:34:42 +0000</pubDate>
      <link>https://dev.to/plotek/sylius-behat-scenarios-in-chrome-headless-inside-docker-26p1</link>
      <guid>https://dev.to/plotek/sylius-behat-scenarios-in-chrome-headless-inside-docker-26p1</guid>
      <description>&lt;p&gt;Since this &lt;a href="https://github.com/Sylius/Sylius/pull/11505" rel="noopener noreferrer"&gt;PR&lt;/a&gt;, Sylius has started using Chrome Headless to run their Behat scenarios tagged with &lt;code&gt;@javascript&lt;/code&gt; (scenarios that require Javascript engine to run correctly - in short, Javascript suits). After the implementation of this change, it turned out that Javascript suits had sped up from 13 minutes to 8.5 minutes. So, I decided also to run my Javascript suit using Chrome Headless. However, there was one problem, namely my whole environment (development, test on the local machine, and test in CI) is based on Docker. Until now, I’ve been using Selenium image to run Chrome. This short post shows you how to configure your Docker environment to work with Chrome Headless.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You might see this post  when you still want to use Selenium with Docker for Javascript suits: &lt;/p&gt;
&lt;div class="ltag__link"&gt;
  &lt;a href="/kayneth" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F117730%2Fa1840d93-e45a-4dfe-8dc7-7425a320c912.jpg" alt="kayneth"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="/kayneth/how-to-test-your-sylius-plugins-with-selenium-38ci" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;How to test your Sylius plugins with Selenium?&lt;/h2&gt;
      &lt;h3&gt;Dylan Ballandras ・ Mar 12 '20&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#php&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#sylius&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#behat&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#selenium&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;

&lt;/blockquote&gt;

&lt;p&gt;First of all, I assume that you work with Sylius Standard Edition. If you have a custom Docker configuration, there is no problem with adopting this solution, but it will require more effort from you.&lt;br&gt;
Sylius Standard comes with two docker-compose files: one for development purposes and the second for production. For running Behat scenarios, I suggest creating the third one. We might call it &lt;code&gt;docker-compose.behat.yaml&lt;/code&gt;. In this file, we might configure Chrome Headless as a Docker service and (optionally) override or create new services.&lt;/p&gt;

&lt;p&gt;For brevity, in this blog post, we only create a Chrome service and override the environment setting for the application service. So, our &lt;code&gt;docker-compose.behat.yaml&lt;/code&gt; file looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;version&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;3.4"&lt;/span&gt;

&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;php&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;APP_ENV=test_cached&lt;/span&gt;
  &lt;span class="na"&gt;chrome&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;zenika/alpine-chrome&lt;/span&gt;
    &lt;span class="na"&gt;shm_size&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;2gb"&lt;/span&gt;
    &lt;span class="na"&gt;command&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;--enable-automation&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;--disable-background-networking&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;--no-default-browser-check&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;--no-first-run&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;--disable-popup-blocking&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;--disable-default-apps&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;--disable-translate&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;--disable-extensions&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;--no-sandbox&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;--enable-features=Metal&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;--headless&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;--remote-debugging-port=9222&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;--remote-debugging-address=0.0.0.0&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;--window-size=2880,1800&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;--proxy-server='direct://'&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;--proxy-bypass-list='*'"&lt;/span&gt;
    &lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;.:/srv/sylius:rw,cached&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A few lines that require explanation:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;First of all, you have to override the application service (in our case, called &lt;code&gt;php&lt;/code&gt; to run in &lt;code&gt;test_cashed&lt;/code&gt; environment).&lt;/li&gt;
&lt;li&gt;For Chrome, we use &lt;a href="https://github.com/Zenika/alpine-chrome" rel="noopener noreferrer"&gt;zenika/alpine-chrome&lt;/a&gt; image. You might use another one (but not all images work correctly, this one is also well documented) or create your image (but it might be a waste of time).&lt;/li&gt;
&lt;li&gt;It is necessary to change the shm size. Without this change, Chrome crashes during tests. So I suggest setting the &lt;code&gt;shm_size&lt;/code&gt; option to &lt;code&gt;2gb&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The next thing worth noting is the command for the Chrome container. I use the same command as is used in the &lt;a href="https://github.com/Sylius/Sylius/blob/master/.github/workflows/application.yml#L387" rel="noopener noreferrer"&gt;Sylius CI configuration&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Last but not least,  the volume needs the correct setting. It is very important, and remembering about it might save your time for debugging a problem. It is necessary to upload files in the scenario’s steps. Without this line your test execution returns timeout for all scenarios placed after that one that tries to upload a file. In my example, I’m sharing all codebases, but it is possible to share the only directory with fixtures.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The second file we should change is &lt;code&gt;behat.yaml&lt;/code&gt;. We have to configure the MinkExtension's (so we focus only on the &lt;code&gt;Behat\\MinkExtension&lt;/code&gt; section in this file) &lt;code&gt;base_url&lt;/code&gt; option.  In our case, the correct value is &lt;a href="http://nginx/" rel="noopener noreferrer"&gt;&lt;code&gt;http://nginx/&lt;/code&gt;&lt;/a&gt; (it points to the entrypoint of our application).&lt;br&gt;
Since we run Chrome Headless as a service in a container (instead of the same machine or container as an application), it is also necessary to change the option of &lt;code&gt;chrome_headless&lt;/code&gt; sessions. This option refers to url to Chrome API, and for us, it is &lt;code&gt;http://chrome:9222&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;That's all. It's time for testing. For this purpose, run the command below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker-compose &lt;span class="nt"&gt;-f&lt;/span&gt; docker-compose.yml &lt;span class="nt"&gt;-f&lt;/span&gt; docker-compose.behat.yml &lt;span class="nb"&gt;exec &lt;/span&gt;php vendor/bin/behat &lt;span class="nt"&gt;--colors&lt;/span&gt; &lt;span class="nt"&gt;--strict&lt;/span&gt; &lt;span class="nt"&gt;--no-interaction&lt;/span&gt; &lt;span class="nt"&gt;-vvv&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; progress &lt;span class="nt"&gt;-f&lt;/span&gt; pretty &lt;span class="nt"&gt;--tags&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"@javascript &amp;amp;&amp;amp; ~@todo &amp;amp;&amp;amp; ~@cli"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;You might use composer's script or Makefile to alias long commands.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I hope that this configuration allows you to speed up your test, especially in CI (I wish to show you a comparison of Selenium and Chrome Headless in the next blog post).&lt;/p&gt;

</description>
      <category>docker</category>
      <category>sylius</category>
      <category>behat</category>
    </item>
  </channel>
</rss>
