<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Isolating components Archives - Artificial Intelligence</title>
	<atom:link href="https://www.aiuniverse.xyz/tag/isolating-components/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.aiuniverse.xyz/tag/isolating-components/</link>
	<description>Exploring the universe of Intelligence</description>
	<lastBuildDate>Thu, 17 Sep 2020 07:51:49 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>A lesson on how to test microservices locally</title>
		<link>https://www.aiuniverse.xyz/a-lesson-on-how-to-test-microservices-locally/</link>
					<comments>https://www.aiuniverse.xyz/a-lesson-on-how-to-test-microservices-locally/#respond</comments>
		
		<dc:creator><![CDATA[aiuniverse]]></dc:creator>
		<pubDate>Thu, 17 Sep 2020 07:51:40 +0000</pubDate>
				<category><![CDATA[Microservices]]></category>
		<category><![CDATA[applications]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Isolating components]]></category>
		<guid isPermaLink="false">http://www.aiuniverse.xyz/?p=11643</guid>

					<description><![CDATA[<p>Source: searchapparchitecture.techtarget.com In the early days of microservices, a developer wrote 20 lines of code, and then registered a subdomain to an IP address and port. Ten <a class="read-more-link" href="https://www.aiuniverse.xyz/a-lesson-on-how-to-test-microservices-locally/">Read More</a></p>
<p>The post <a href="https://www.aiuniverse.xyz/a-lesson-on-how-to-test-microservices-locally/">A lesson on how to test microservices locally</a> appeared first on <a href="https://www.aiuniverse.xyz">Artificial Intelligence</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Source: searchapparchitecture.techtarget.com</p>



<p>In the early days of microservices, a developer wrote 20 lines of code, and then registered a subdomain to an IP address and port. Ten years later, that process is even easier. With the help of cloud abstraction and&nbsp;serverless, developers can write the code, publish it to a version control environment, and connect a system to that code &#8212; server management, scaling and other back-end processes are all handled in the cloud.</p>



<p>But how do you test these cloud-hosted microservices-based applications locally? You could test on a local machine, or at least a local container, before you push the code into&nbsp;a test environment. However, a typical microservices-based application calls as many as 60 separate services. To test these complex applications locally, you&#8217;ll need to assemble each individual service, and probably the underlying databases, on the local machine. Testing microservices locally often involves running a half-dozen terminal sessions on one machine.</p>



<p>A better option is to separate and isolate services, which is always a good idea when performing either unit testing or integration testing on complex application architectures. First, we&#8217;ll review the process of testing microservices locally, including unit and integration testing. Then, we&#8217;ll take a look at some effective techniques for service isolation, such as service virtualization and private cloud test clusters.</p>



<h3 class="wp-block-heading">Isolating components</h3>



<p>Using a testing framework, like JUnit for Java code, it&#8217;s possible to test pieces of a microservices-based application as individual units. When those small, testable collections of methods run into a dependency, such as a database connection, you can use&nbsp;dependency injection&nbsp;to create the stubs, mocks and fakes needed to accurately test the service. When it comes to simple unit tests, there are easy patterns to learn, such as the&nbsp;Arrange, Act and Assert&nbsp;pattern.&nbsp;<em>Arrange, Act and Assert</em>&nbsp;calls for a setup, action and then validation of a result.</p>



<p>Testing a service while it runs, integrated with other components, is a different matter. Integration testing is a little trickier than unit testing. Instead of creating unit-level mocks, you design tests to mimic the numerous integrations involved, in a realistic way.</p>



<p>Service virtualization&nbsp;is a way to record the response of a service to a certain call, and then play the sequence back on-demand. This approach provides a lightweight, predictable service mock you can test against as needed. And, you likely will&nbsp;mock or stub&nbsp;out the databases and other external components they interact with.</p>



<h3 class="wp-block-heading">When you can&#8217;t isolate microservices</h3>



<p>Service virtualization, changing dependencies and test flags can be difficult to set up. You need expertise in that kind of coding. And architecture groups might want to dictate the &#8220;right&#8221; way to stand up test services, or prevent the development teams from adopting new virtualization tools.</p>



<p>If you can&#8217;t directly change the code to run microservices tests locally as described above, try creating a new environment that contains the entire collection of services you want to test. To do that, implement a mechanism that scans for and identifies every dependency. Pact.io is an open source&nbsp;contract test tool&nbsp;which can do this;&nbsp;Microservice Graph Explorer&nbsp;is another.</p>



<p>Once you&#8217;ve identified the services and their dependencies to test, create containers that can run the service, and connect them all to the same test database. Then, create a test cluster &#8212; use a public or private cloud &#8212; that contains the actual services and mocked data. You might be tempted to perform these tests locally on a desktop, since you won&#8217;t need permissions or licenses to do so. However, simulating multiple services on a desktop, coupled with the overhead of a cluster manager,&nbsp;leads to performance problems.</p>



<p>This technique of creating all the dependencies for a service and mocking what is appropriate is essentially&nbsp;an infrastructure project. It will be time-consuming and a little expensive. However, once it&#8217;s created, you&#8217;ll have an opportunity to truly test microservices in isolation.</p>
<p>The post <a href="https://www.aiuniverse.xyz/a-lesson-on-how-to-test-microservices-locally/">A lesson on how to test microservices locally</a> appeared first on <a href="https://www.aiuniverse.xyz">Artificial Intelligence</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.aiuniverse.xyz/a-lesson-on-how-to-test-microservices-locally/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
