blob: 753182d065100f55bc0920fec7f5f715061d849c [file] [log] [blame]
<!DOCTYPE HTML>
<html lang="" >
<head>
<meta charset="UTF-8">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>QA process · Eclipse Kapua™ Developer Guide</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="description" content="">
<meta name="generator" content="GitBook 3.2.2">
<link rel="stylesheet" href="gitbook/style.css">
<link rel="stylesheet" href="gitbook/gitbook-plugin-hints/plugin-hints.css">
<link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
<link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
<link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
<meta name="HandheldFriendly" content="true"/>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
<link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">
<link rel="prev" href="client.html" />
</head>
<body>
<div class="book">
<div class="book-summary">
<div id="book-search-input" role="search">
<input type="text" placeholder="Type to search" />
</div>
<nav role="navigation">
<ul class="summary">
<li class="chapter " data-level="1.1" data-path="./">
<a href="./">
Introduction
</a>
</li>
<li class="chapter " data-level="1.2" data-path="building.html">
<a href="building.html">
Building
</a>
<ul class="articles">
<li class="chapter " data-level="1.2.1" data-path="building.html">
<a href="building.html#kapua">
Kapua
</a>
</li>
<li class="chapter " data-level="1.2.2" data-path="building.html">
<a href="building.html#documentation">
Documentation
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.3" data-path="running.html">
<a href="running.html">
Running
</a>
<ul class="articles">
<li class="chapter " data-level="1.3.1" data-path="running.html">
<a href="running.html#docker-containers">
Docker
</a>
</li>
<li class="chapter " data-level="1.3.2" data-path="running.html">
<a href="running.html#openshift">
OpenShift
</a>
</li>
<li class="chapter " data-level="1.3.3" data-path="running.html">
<a href="running.html#vagrant">
Vagrant
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.4" data-path="ide.html">
<a href="ide.html">
Setting up an IDE
</a>
<ul class="articles">
<li class="chapter " data-level="1.4.1" data-path="ide.html">
<a href="ide.html#eclipse">
Eclipse IDE
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.5" >
<span>
Configuration
</span>
<ul class="articles">
<li class="chapter " data-level="1.5.1" data-path="sso.html">
<a href="sso.html">
Single sign-on
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.6" data-path="database.html">
<a href="database.html">
Working with database
</a>
</li>
<li class="chapter " data-level="1.7" data-path="client.html">
<a href="client.html">
Client generation
</a>
</li>
<li class="chapter active" data-level="1.8" data-path="qa.html">
<a href="qa.html">
QA process
</a>
</li>
<li class="divider"></li>
<li>
<a href="https://www.gitbook.com" target="blank" class="gitbook-link">
Published with GitBook
</a>
</li>
</ul>
</nav>
</div>
<div class="book-body">
<div class="body-inner">
<div class="book-header" role="navigation">
<!-- Title -->
<h1>
<i class="fa fa-circle-o-notch fa-spin"></i>
<a href="." >QA process</a>
</h1>
</div>
<div class="page-wrapper" tabindex="-1" role="main">
<div class="page-inner">
<div id="book-search-results">
<div class="search-noresults">
<section class="normal markdown-section">
<h1 id="kapua-qa-process">Kapua QA process</h1>
<p>This chapter describes a quality assurance process of Kapua. Before you commit changes to the <code>develop</code> branch, be sure that you have followed those steps:</p>
<ol>
<li>Run <code>mvn clean install -DskipTests -Pconsole,docker</code> and then <code>mvn clean install</code> command to see if all the tests pass correctly</li>
<li>Push changes to you remote repository and wait for the Travis to complete successfully (there should be no test failures, CI environments should always be green):<ul>
<li>Travis CI <a href="https://travis-ci.org/eclipse/kapua/" target="_blank"><img src="https://api.travis-ci.org/eclipse/kapua.svg" alt="Build"></a> </li>
<li>Jenkins CI <a href="https://ci.eclipse.org/kapua/" target="_blank"><img src="https://img.shields.io/jenkins/build/https/ci.eclipse.org/kapua/job/Develop.svg" alt="Jenkins"></a></li>
</ul>
</li>
</ol>
<h2 id="cucumber-specifics-in-kapua-project">Cucumber Specifics In Kapua project</h2>
<p>Before you dive deeper into this document, you should have basic knowledge of java, maven, BDD (Behaviour Driven Development), understading of basic QA processes and what is the difference between Unit, integration and all other types of tests. Basic descriptions are bellow, but it is always good to have deeper understanding of testing procedures. There are links to external websites for every topic, so you can check out specifics if you need/want to.</p>
<p>Usefull links:</p>
<ul>
<li><a href="http://softwaretestingfundamentals.com/unit-testing/" target="_blank">Unit testing explained</a></li>
<li><a href="https://www.geeksforgeeks.org/types-software-testing/" target="_blank">Types of tests explained in 5 minutes</a></li>
<li><a href="https://codeutopia.net/blog/2015/04/11/what-are-unit-testing-integration-testing-and-functional-testing/" target="_blank">Integration vs. Functional testing</a></li>
<li><a href="https://cucumber.io/docs/guides/10-minute-tutorial/" target="_blank">Cucumber 10 minute tutorial</a></li>
<li><a href="https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html" target="_blank">Maven explained</a></li>
</ul>
<h3 id="prerequisites-java-maven-cucumber">Prerequisites (Java, Maven, Cucumber)</h3>
<p>If you are already using Kapua, you can jump straight to section 4), otherwise follow the steps 1), 2) and also 3). These steps are also described in other documents (and Internet), but we are adding them nevertheless. </p>
<p>1) Download And Install IDE (This tutorial uses IntelliJ)</p>
<p>Go to <a href="https://www.jetbrains.com/idea/download/download-thanks.html?platform=mac" target="_blank">IntelliJ website</a> and download the Community Edition IntelliJ. After the installation, we have to install some plugins also, but not before we install Java and Maven.</p>
<p>2) Installing Java</p>
<p>Go to <a href="https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html" target="_blank">Java official website</a> and download Java SE Development Kit 8u211. After the installation check if java has been successfully installed by typing &quot;java -v&quot; in terminal. </p>
<p>3) Installing Maven</p>
<p>Now that we have IDE and JDK, we still need Maven. Go to <a href="https://maven.apache.org/download.cgi" target="_blank">official Maven website</a>, select the proper package (it can either ZIP archive or tar.gz archive). Click on download link and save the file (to e.g. Desktop) and after that unzip it to a specific folder in the directory structure (you should never move or delete this maven file once is in this place). An example path is &quot;/opt/apache-maven-3.5.0.&quot;
When the file is in place, we have to add its path to &quot;PATH&quot; environmental variable. Open Terminal and type: &quot;export PATH=$PATH:~/opt/apache-maven-3.5.0&quot;
Verify that maven is in place with &quot;mvn -v&quot; command in terminal.</p>
<p>4) Configuring Cucumber (pom.xml files, plugins)</p>
<p>When you have your IDE, Java and Maven, it is time to setup plugins. As said in the beginning, this tutorial uses IntelliJ, but this can all be achieved on Eclipse IDE also (plugin names are a bit different).
In IntelliJ, go to Preferences -&gt; Plugins -&gt; Marketplace. Search an install the following plugins:</p>
<ul>
<li>Cucumber for Java</li>
<li><p>Gherkin (<strong>Do not install &quot;Substep IntelliJ plugin&quot; as it will interfere with other two and Cucumber syntax will not be recognized.</strong>) </p>
<p>After this is achieved, you have everything that you need to start writing your own tests.</p>
</li>
</ul>
<p>5) Cloning Kapua project</p>
<p>Final step is to clone Kapua from GitHub repository. This is done with command &quot;git clone <a href="https://github.com/eclipse/kapua.git" target="_blank">https://github.com/eclipse/kapua.git</a> &quot;.</p>
<h3 id="testing-in-general">Testing In General</h3>
<h4 id="unit-testing">Unit testing</h4>
<p>Unit testing is simple testing, that tests small chunks of code (for example user creation), that do not use other services (permissions, devices...). These tests are tipically done by developers as they know the functionality best.</p>
<h4 id="integration-testing">Integration testing</h4>
<p>These tests do not test one method at a time, but rather try to simulate a real scenario (user creation, adding permissions, deleting user...). This way we test multiple services/methods/pieces of code so we can see, if the code behaves as it should. Integration tests are usually written by QA engineers. </p>
<h4 id="cucumber-testing">Cucumber testing</h4>
<p>Cucumber tests use Gherkin syntax to simulate functional tests. This are not &#xBB;pure&#xAB; integration tests, but the similarities are obvious: Code is tested through various scenarios to check if it works as intended. Cucumber has two important components: so called &#xBB;.feature&#xAB; files and &#xBB;steps&#xAB; files. In &#xBB;.feature&#xAB; files we have all the scenarios written in Gherkin syntax and in &#xBB;steps&#xAB; files we have implementation of these steps from feature files. This way the code in &#xBB;.feature&#xAB; files is easily readable, can be written virtually by anyone and can be easily changed. </p>
<h4 id="cucumber-general-settings">Cucumber General Settings</h4>
<p>Every project that uses Cucumber as framework for integration testing, needs some specifics inside pom.xml files. All of these settings can be found on the websites listed bellow. </p>
<h5 id="kapua-specifics">Kapua Specifics</h5>
<p>Kapua project has integration and some unit tests written in cucumber. The biggest difference is the location of these tests. Because Unit tests are isolated tests and do not need &quot;external&quot; components, they are located in:</p>
<ul>
<li>&quot;Service&quot; folder. In test-steps subfolder there are also &quot;steps&quot; files, that contain implementation from &quot;.feature&quot; files - but more on this later.</li>
</ul>
<pre><code>{
Service
Account
test
src
java
org.eclipse.kapua-service.account.test
CucumberWithPropertiesForAccount
RunAccountUnitTest
resources
features
AccountService.feature
test-steps
src
main
java
org.eclipse.kapua.service.account.steps
AccountServiceSteps
}
</code></pre><p>On the other hand, we have &quot;qa&quot; folder, that contains &quot;.feature&quot; files for integration tests (see code tree bellow). As stated above, there is &quot;test-steps&quot; folder in &quot;Service&quot; part of the code. This is because of Unit tests, that need all the steps in their package, but we can easily access to them from qa folder as well. This way we do not have two &quot;test-steps&quot; files but only one.</p>
<ul>
<li>qa root folder (&quot;.feature&quot; files of integration tests)</li>
<li>service root folder (&quot;test-steps&quot; files - see the code tree above).</li>
</ul>
<pre><code>{
QA
integration
src
test
Resource
features
account
authorization
broker
.
.
.
}
</code></pre><p>Besides these two files (&quot;.feature&quot; and &quot;steps&quot; files), there is another one, that is crucial for running a cucumber integration test - Run&lt;&quot;service-name&quot;&gt;I9nTest. These scripts contain Cucumber options (feature files, &quot;glue&quot; files, used plugins etc), that are crucial for running the tests. As we have stated before, Cucumber tests are functional tests and because of this they need additional methods and classes so this file provides everything that the tests need, to be properly executed.</p>
<pre><code>{
qa
integration
src
test
java
org.eclipse.kapua.integration
misc
rest
service
account
RunAccountServiceI9nTest
authorization
connection
datastore
datastreJunit
device
job
user
}
</code></pre><p>One example of these file is shown bellow:</p>
<pre><code>{
@RunWith(CucumberWithProperties.class)
@CucumberOptions(
features = {
&quot;classpath:features/user/UserServiceI9n.feature&quot;,
&quot;classpath:features/user/UserRoleServiceI9n.feature&quot;
},
glue = {&quot;org.eclipse.kapua.qa.common&quot;,
&quot;org.eclipse.kapua.service.account.steps&quot;,
&quot;org.eclipse.kapua.service.user.steps&quot;,
&quot;org.eclipse.kapua.service.authorization.steps&quot;
},
plugin = {&quot;pretty&quot;,
&quot;html:target/cucumber/UserServiceI9n&quot;,
&quot;json:target/UserServiceI9n_cucumber.json&quot;
},
strict = true,
monochrome = true)
@CucumberProperty(key=&quot;broker.ip&quot;, value=&quot;192.168.33.10&quot;)
@CucumberProperty(key=&quot;kapua.config.url&quot;, value=&quot;&quot;)
@CucumberProperty(key=&quot;datastore.elasticsearch.provider&quot;, value=&quot;org.eclipse.kapua.service.elasticsearch.client.rest.RestElasticsearchClientProvider&quot;)
@CucumberProperty(key=&quot;org.eclipse.kapua.qa.datastore.extraStartupDelay&quot;, value=&quot;5&quot;)
@CucumberProperty(key=&quot;org.eclipse.kapua.qa.broker.extraStartupDelay&quot;, value=&quot;5&quot;)
public class RunUserServiceI9nTest {}
</code></pre><p>}</p>
<h5 id="pomxml-file">POM.xml file</h5>
<p>The root POM.xml file includes all the dependencies, plugins and properties regarding Cucumber needed for running Cucumber tests. Bellow there are snippets from POM.xml file, that are relevant for our functional testing. </p>
<pre><code>{
&lt;dependency&gt;
&lt;groupId&gt;info.cukes&lt;/groupId&gt;
&lt;artifactId&gt;cucumber-core&lt;/artifactId&gt;
&lt;/dependency&gt;
</code></pre><p>}</p>
<pre><code>}
&lt;dependency&gt;
&lt;groupId&gt;info.cukes&lt;/groupId&gt;
&lt;artifactId&gt;cucumber-java&lt;/artifactId&gt;
&lt;version&gt;${cucumber.version}&lt;/version&gt;
&lt;/dependency&gt;
</code></pre><p>}</p>
<pre><code>}
&lt;dependency&gt;
&lt;groupId&gt;info.cukes&lt;/groupId&gt;
&lt;artifactId&gt;cucumber-junit&lt;/artifactId&gt;
&lt;version&gt;${cucumber.version}&lt;/version&gt;
&lt;/dependency&gt;
</code></pre><p>}</p>
<pre><code>}
&lt;dependency&gt;
&lt;groupId&gt;info.cukes&lt;/groupId&gt;
&lt;artifactId&gt;cucumber-guice&lt;/artifactId&gt;
&lt;version&gt;${cucumber.version}&lt;/version&gt;
&lt;/dependency&gt;
</code></pre><p>}</p>
<p>Inside org.apache.maven.plugins plugin there has to be Cucumber listed: </p>
<pre><code> &lt;plugin&gt;
&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
.
.
.
&lt;argLine&gt;@{argLine} -Xmx1024m&lt;/argLine&gt;
&lt;systemPropertyVariables&gt;
&lt;cucumber.options&gt;--tags ~@rest&lt;/cucumber.options&gt;
.
.
.
&lt;/systemPropertyVariables&gt;
&lt;/configuration&gt;
&lt;/plugin&gt;
</code></pre><p>In <code>&lt;properties&gt;</code>: </p>
<p><cucumber.version>1.2.4&lt;/cucumber.version&gt;</cucumber.version></p>
<h3 id="running-the-integration-tests">Running the (integration) tests</h3>
<p>Bellow there is a sample command, which is used to run the tests. </p>
<pre><code>mvn verify -Dcommons.db.schema=kapuadb -Dcommons.settings.hotswap=true -Dbroker.host=localhost -Dgroups=&apos;!org.eclipse.kapua.qa.markers.junit.JUnitTests&apos; -Dcucumber.options=&quot;--tags ~@rest&quot;
</code></pre><p>First part is clear: mvn verify command runs any integration tests that maven finds in the project.
Parameters that follow (kapuadb, hotswap and broker) are neccessary options for all the tests and after that we have options for the tests themselves.</p>
<p>Bottom command specifies that JUnit tests should (in this specific case) not be run:</p>
<pre><code>-Dgroups=&apos;!org.eclipse.kapua.qa.markers.junit.JUnitTests&apos;
</code></pre><p>And the last part of the command (see bellow) specifies that Rest tests should also be skipped. All other tests will start when executing this command.</p>
<pre><code>-Dcucumber.options=&quot;--tags ~@rest&quot;
</code></pre><h3 id="cucumber-reports">Cucumber reports</h3>
<p>After every exceution of cucumber integration tests, there is a test report generated, that is located in /dev-tools/cucumber-reports/target.
Every service has its own folder, so if all the integration tests are run, there should be structure as shown bellow: </p>
<pre><code>dev-tools
cucumber-reports
target
kapua-cuucmber-report
account-service
broker-ACL-i9n
connection-user-coupling-i9n
datastore-rest-i9n
datastore-transport-i9n
device-broker-i9n
device-data-i9n
device-lifecycle-service-i9n
device-manager-ACL-i9n
device-registry-service
device-service-i9n
job-service
tag-service
user-service
user-service-i9n
user-service-lockout-i9n
</code></pre><p>Every folder should contain the following files:</p>
<ul>
<li>formatter.js</li>
<li>index.html</li>
<li>jquery-1.8.2.min.js</li>
<li>report.js</li>
<li>style.css</li>
</ul>
<p>If you open root index.html file (located in /dev-tools/cucumber-reports/target) with your preferable browser, main page of cucumber reports will open (screenshot bellow).</p>
<p><img src="images/kapua-reports-main-page.png" alt="kapua reports main page"></p>
<p>From here you can navigate to any of the specific reports - bellow there is a sample screenshot of a page like this, where you can see all the details for every test. </p>
<p><img src="kapua-sample-test-report.png" alt="kapua sample test report"></p>
</section>
</div>
<div class="search-results">
<div class="has-results">
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
<ul class="search-results-list"></ul>
</div>
<div class="no-results">
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
</div>
</div>
</div>
</div>
</div>
</div>
<a href="client.html" class="navigation navigation-prev navigation-unique" aria-label="Previous page: Client generation">
<i class="fa fa-angle-left"></i>
</a>
</div>
<script>
var gitbook = gitbook || [];
gitbook.push(function() {
gitbook.page.hasChanged({"page":{"title":"QA process","level":"1.8","depth":1,"previous":{"title":"Client generation","level":"1.7","depth":1,"path":"client.md","ref":"client.md","articles":[]},"dir":"ltr"},"config":{"plugins":["hints"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"hints":{"danger":"fa fa-exclamation-circle","info":"fa fa-info-circle","tip":"fa fa-mortar-board","working":"fa fa-wrench"},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"github":"eclipse/kapua","theme":"default","githubHost":"https://github.com/","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Eclipse Kapua™ Developer Guide","links":{"home":"http://eclipse.org/kapua"},"gitbook":"3.x.x","description":"Eclipse Kapua™ Developer Guide"},"file":{"path":"qa.md","mtime":"2020-11-26T08:22:34.016Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2020-11-26T08:23:27.237Z"},"basePath":".","book":{"language":""}});
});
</script>
</div>
<script src="gitbook/gitbook.js"></script>
<script src="gitbook/theme.js"></script>
<script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
<script src="gitbook/gitbook-plugin-search/search.js"></script>
<script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
<script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
<script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
<script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
</body>
</html>