<?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: Nenad Stojanovikj</title>
    <description>The latest articles on DEV Community by Nenad Stojanovikj (@nenad).</description>
    <link>https://dev.to/nenad</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%2F282240%2Fa414efc8-80df-4a0e-be43-c20bf1a9aded.jpeg</url>
      <title>DEV Community: Nenad Stojanovikj</title>
      <link>https://dev.to/nenad</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nenad"/>
    <language>en</language>
    <item>
      <title>Speed up your integration tests in one line</title>
      <dc:creator>Nenad Stojanovikj</dc:creator>
      <pubDate>Sat, 07 Dec 2019 16:04:43 +0000</pubDate>
      <link>https://dev.to/nenad/speed-up-your-integration-tests-in-one-line-49d7</link>
      <guid>https://dev.to/nenad/speed-up-your-integration-tests-in-one-line-49d7</guid>
      <description>&lt;p&gt;If you are using Docker to run your integration tests, and they use a real database (MySQL, PostgreSQL, MongoDB, etc), you are in luck. By simply mounting the directory of the database files on &lt;a href="https://en.wikipedia.org/wiki/Tmpfs"&gt;&lt;code&gt;tmpfs&lt;/code&gt;&lt;/a&gt; in the containers, you will be able to reduce the execution time by a substantial amount[1]. In my case, I reduced the tests from 17 minutes execution time, to just 4 minutes.&lt;/p&gt;

&lt;p&gt;This &lt;code&gt;tmpfs&lt;/code&gt; flag is supported also in &lt;a href="https://docs.docker.com/compose/compose-file/#tmpfs"&gt;docker-compose&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Example &lt;code&gt;docker-compose&lt;/code&gt; file for MySQL, PostgreSQL and MongoDB:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;version: '3'
services:
  mongo_db:
    image: mongo:3.4.6
    ports:
      - "27017"
    tmpfs:
      - /var/lib/mongodb

  mysql_db:
    image: mysql:5.6.34
    ports:
      - "3306"
    tmpfs:
      - /var/lib/mysql

  postgres_db:
    image: postgres:11
    ports:
      - "5432"
    tmpfs:
      - /var/lib/postgresql/data

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;To launch a container with a &lt;code&gt;tmpfs&lt;/code&gt; from the CLI, use the &lt;code&gt;--tmpfs&lt;/code&gt; flat, just like it's described in the &lt;a href="https://docs.docker.com/storage/tmpfs/"&gt;docs&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ docker run -d -it --name tmptest --tmpfs /app nginx:latest&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;[1]: This will vary depending on the usage of the database during the test runs. If you don't utilize the database a lot, you might not even notice any improvements.&lt;/p&gt;

</description>
      <category>testing</category>
      <category>docker</category>
    </item>
  </channel>
</rss>
