Upgrade to Pro — share decks privately, control downloads, hide ads and more …

MICROSERVICES: BETTER FOR DEVS OR QA'S?

ymkocv
September 08, 2017

MICROSERVICES: BETTER FOR DEVS OR QA'S?

ymkocv

September 08, 2017
Tweet

More Decks by ymkocv

Other Decks in Programming

Transcript

  1. ABOUT MYSELF  7-8 years in QA  Leading teams

     BI testing  WS testing  Back-end auto-tests writing & maintaining  Java, Groovy
  2. Microservice applications are composed of small, independently versioned, and scalable

    customer-focused services that communicate with each other over standard protocols with well- defined interfaces. MICROSERVICE
  3. In short, the microservice architectural style is an approach to

    developing a single application as a suite of small services, each running in its own process and communicating with lightweight mechanisms, often an HTTP resource API. These services are built around business capabilities and independently deployable by fully automated deployment machinery. There is a bare minimum of centralized management of these services, which may be written in different programming languages and use different data storage technologies. -- James Lewis and Martin Fowler
  4. DIFFERENCES  A monolithic app contains domain-specific functionality and is

    normally divided by functional layers, such as web, business, and data.  You scale a monolithic app by cloning it on multiple servers/virtual machines/containers.  A microservice application separates functionality into separate smaller services.  The microservices approach scales out by deploying each service independently, creating instances of these services across servers/virtual machines/containers. https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-overview-microservices
  5. private static class EventDetails { private static final String eventHubName

    = "Hub"; private static final String sasKeyName = "KeyName"; private static final String sasKey = "Key"; public static EventDetailsDto getEventDetails() { final URI endpoint; try { endpoint = new URI("http://url.com"); } catch (URISyntaxException e) { throw new RuntimeException("URI is not correct. Cause: " + e.getLocalizedMessage(), e); } EventDetailsDto eventDetailsDto = new EventDetailsDto(); eventDetailsDto.setEndpoint(endpoint); eventDetailsDto.setEventHubName(eventHubName); eventDetailsDto.setSasKeyName(sasKeyName); eventDetailsDto.setSasKey(sasKey); return eventDetailsDto; } } JAVA CODE
  6. public class EventDetailsDto{ private URI endpoint; private String eventHubName; private

    String sasKeyName; private String sasKey; public EventDetailsDto() {} public URI getEndpoint() { return endpoint; } public void setEndpoint(URI endpoint) { this.endpoint = endpoint; } public String getEventHubName() { return eventHubName; } public void setEventHubName(String eventHubName) { this.eventHubName = eventHubName; } JAVA CODE
  7. JAVA CODE public String getSasKeyName() { return sasKeyName; } public

    void setSasKeyName(String sasKeyName) { this.sasKeyName = sasKeyName; } public String getSasKey() { return sasKey; } public void setSasKey(String sasKey) { this.sasKey = sasKey; } @Override public String toString() { return "EventDetailsDto{" + "endpoint=" + endpoint + ", eventHubName='" + eventHubName + '\'' + ", sasKeyName='" + sasKeyName + '\'' + ", sasKey='" + sasKey + '\'' + '}'; } }
  8. public static void sendEvent(final EventDetailsDto detailsDto, String partitionKey, byte[] payloadBytes,

    String streamNamespace) { EventHubClient ehClient = null; EventDetailsDto eventDetailsDto = detailsDto; try { if (eventDetailsDto == null) { eventDetailsDto = EventDetails.getEventDetails(); } ConnectionStringBuilder connStr = new ConnectionStringBuilder(eventDetailsDto.getEndpoint(), eventDetailsDto.getEventHubName(), eventDetailsDto.getSasKeyName(), eventDetailsDto.getSasKey()); EventData eventData = new EventData(payloadBytes); eventData.getProperties().put("StreamNamespace", streamNamespace); ehClient = EventHubClient.createFromConnectionStringSync(connStr.toString()); ehClient.sendSync(eventData, partitionKey); } catch (Throwable throwable) { throw new RuntimeException("There was a trouble building connection to Azure: " + throwable.getLocalizedMessage(), throwable); } finally { try { ehClient.closeSync(); } catch (ServiceBusException e) { throw new RuntimeException("Event to Azure Event Hub was not sent. Cause: " + e.getLocalizedMessage(), e); } } } JAVA CODE
  9. SOAP UI SCRIPT import lib.PushEvent; def eventHubName = context.getTestCase().getTestSuite().project.getPropertyValue("eventHubName"); def

    sasKeyName = "Key"; def sasKey = "Blahblahblah"; endpoint = new URI("http://blah.net"); EventDetailsDto eventDetailsDto = new EventDetailsDto(); eventDetailsDto.setEndpoint(endpoint); eventDetailsDto.setEventHubName(eventHubName); eventDetailsDto.setSasKeyName(sasKeyName); eventDetailsDto.setSasKey(sasKey); String partitionKey = "uuid"; byte[] payloadBytes = "[{\"EmailAddress\":\"[email protected]\",\"TemplateId\":\"WelcomeEmail\",\"TimeStamp\":\" 2017-04-20T13:26:25\",\"Parameters\":{\"SenderName\":\“John Doe\"},\"Random\":\"Random\"}]".getBytes("UTF-8"); String streamNamespace = "Email"; PushEvent.sendEvent(eventDetailsDto, partitionKey,payloadBytes, streamNamespace);
  10. CONCLUSIONS  Microservices are more expensive  More difficult for

    development  More time for settings  Easier to test when having OOP knowledge or desire to know OOP  More difficult to test manually because of configurations  More progress
  11. LINKS  Microsoft docs  Martin Fowler: microservices  Microservices

    and Rules Engines – a blast from the past - Udi Dahan