Loading

Docker with DotNet Core and Jmeter

Jesús Estévez

This is a live streamed presentation. You will automatically follow the presenter and see the slide they're currently on.

Docker with DotNet Core and Jmeter

About Felipe Cruz

About Jesús Estévez

Why Docker?

Please puts your hands up if some times your code was working fine in Dev but not in Production

Index

  1. Welcome
  2. Dotnet Core
  3. Docker
  4. Jmter

Docker

  • Introduction

    • Quick overview

  • Basic:

    • DockerFile

    • Docker build -> docker images

    • Docker run -> container

    • Docker-compose

  •  Advanced:

    • Docker Swarm

      • Setup

        • Scalability

        • Resources

      • Deploy

Docker and JMeter

  • JMeter Básic Test Plan
  • Docker image to run Jmeter
  • Run Test in Docker container

.Net Core

by Jesús Estévez

DotNet Core Tips

  • Cache
  • Compression
  • Middleware
  • so much things !!! 

For other Month

bit.ly/malagaAzureBootcamp2019

Docker

by Felipe Cruz

Docker Introduction

Docker Workflow

Docker File

FROM microsoft/dotnet:2.2-aspnetcore-runtime AS base

Docker File

FROM microsoft/dotnet:2.2-aspnetcore-runtime AS base
WORKDIR /app

Docker File

FROM microsoft/dotnet:2.2-aspnetcore-runtime AS base
WORKDIR /app

FROM microsoft/dotnet:2.2-sdk AS build
WORKDIR /src

Docker File

FROM microsoft/dotnet:2.2-aspnetcore-runtime AS base
WORKDIR /app

FROM microsoft/dotnet:2.2-sdk AS build
WORKDIR /src
COPY ["HeatMeterWebApi/HeatMeterWebApi.csproj", "HeatMeterWebApi/"]

Docker File

FROM microsoft/dotnet:2.2-aspnetcore-runtime AS base
WORKDIR /app

FROM microsoft/dotnet:2.2-sdk AS build
WORKDIR /src
COPY ["HeatMeterWebApi/HeatMeterWebApi.csproj", "HeatMeterWebApi/"]
RUN dotnet restore "HeatMeterWebApi/HeatMeterWebApi.csproj"

Docker File

FROM microsoft/dotnet:2.2-aspnetcore-runtime AS base
WORKDIR /app

FROM microsoft/dotnet:2.2-sdk AS build
WORKDIR /src
COPY ["HeatMeterWebApi/HeatMeterWebApi.csproj", "HeatMeterWebApi/"]
RUN dotnet restore "HeatMeterWebApi/HeatMeterWebApi.csproj"

COPY . .
WORKDIR /src/HeatMeterWebApi
RUN dotnet build "HeatMeterWebApi.csproj" -c Release -o /app

Docker File

FROM microsoft/dotnet:2.2-aspnetcore-runtime AS base
WORKDIR /app

FROM microsoft/dotnet:2.2-sdk AS build
WORKDIR /src
COPY ["HeatMeterWebApi/HeatMeterWebApi.csproj", "HeatMeterWebApi/"]
RUN dotnet restore "HeatMeterWebApi/HeatMeterWebApi.csproj"

COPY . .
WORKDIR /src/HeatMeterWebApi
RUN dotnet build "HeatMeterWebApi.csproj" -c Release -o /app

FROM build AS publish
RUN dotnet publish "HeatMeterWebApi.csproj" -c Release -o /app

Docker File

FROM microsoft/dotnet:2.2-aspnetcore-runtime AS base
WORKDIR /app

FROM microsoft/dotnet:2.2-sdk AS build
WORKDIR /src
COPY ["HeatMeterWebApi/HeatMeterWebApi.csproj", "HeatMeterWebApi/"]
RUN dotnet restore "HeatMeterWebApi/HeatMeterWebApi.csproj"

COPY . .
WORKDIR /src/HeatMeterWebApi
RUN dotnet build "HeatMeterWebApi.csproj" -c Release -o /app

FROM build AS publish
RUN dotnet publish "HeatMeterWebApi.csproj" -c Release -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .

Docker File

FROM microsoft/dotnet:2.2-aspnetcore-runtime AS base
WORKDIR /app

FROM microsoft/dotnet:2.2-sdk AS build
WORKDIR /src
COPY ["HeatMeterWebApi/HeatMeterWebApi.csproj", "HeatMeterWebApi/"]
RUN dotnet restore "HeatMeterWebApi/HeatMeterWebApi.csproj"

COPY . .
WORKDIR /src/HeatMeterWebApi
RUN dotnet build "HeatMeterWebApi.csproj" -c Release -o /app

FROM build AS publish
RUN dotnet publish "HeatMeterWebApi.csproj" -c Release -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .


ENTRYPOINT ["dotnet", "HeatMeterWebApi.dll"]

Docker File

FROM microsoft/dotnet:2.2-aspnetcore-runtime AS base
WORKDIR /app

FROM microsoft/dotnet:2.2-sdk AS build
WORKDIR /src
COPY ["HeatMeterWebApi/HeatMeterWebApi.csproj", "HeatMeterWebApi/"]
RUN dotnet restore "HeatMeterWebApi/HeatMeterWebApi.csproj"

COPY . .
WORKDIR /src/HeatMeterWebApi
RUN dotnet build "HeatMeterWebApi.csproj" -c Release -o /app

FROM build AS publish
RUN dotnet publish "HeatMeterWebApi.csproj" -c Release -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .


ENTRYPOINT ["dotnet", "HeatMeterWebApi.dll"]

Docker-Compose.yml


version: '3.5'

Docker-Compose.yml


version: '3.5'

services:
  heatmeterwebapi:

Docker-Compose.yml


version: '3.5'

services:
  heatmeterwebapi:
    container_name: heatmeterwebapi
    image: heatmeterwebapi:latest

Docker-Compose.yml


version: '3.5'

services:
  heatmeterwebapi:
    container_name: heatmeterwebapi
    image: heatmeterwebapi:latest
    build:
      context: HeatMeterWebApi/
      dockerfile: Dockerfile
  

Docker-Compose


version: '3.5'

services:
  heatmeterwebapi:
    container_name: heatmeterwebapi
    image: heatmeterwebapi:latest
    build:
      context: HeatMeterWebApi/
      dockerfile: Dockerfile
    environment:
      - ASPNETCORE_ENVIRONMENT=Development

Docker-Compose


version: '3.5'

services:
  heatmeterwebapi:
    container_name: heatmeterwebapi
    image: kamstrupmalaga/heatmeterwebapi:latest
    build:
      context: HeatMeterWebApi/
      dockerfile: Dockerfile
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
    ports:
      - "44318:80"

Docker-Compose

version: '3.5'

services:
  heatmeterwebapi:
    image: kamstrupmalaga/heatmeterwebapi:latest
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
    ports:
      - "44000:80"
    deploy:
      replicas: 3

Docker-Compose

version: '3.5'

services:
  heatmeterwebapi:
    image: kamstrupmalaga/heatmeterwebapi:latest
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
    ports:
      - "44000:80"
    deploy:
      replicas: 3
      restart_policy:
        condition: on-failure
        delay: 5s
        max_attempts: 3
        window: 120s

Docker-Compose

version: '3.5'

services:
  heatmeterwebapi:
    image: kamstrupmalaga/heatmeterwebapi:latest
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
    ports:
      - "44000:80"
    deploy:
      replicas: 3
      restart_policy:
        condition: on-failure
        delay: 5s
        max_attempts: 3
        window: 120s
      resources:
        limits:
          cpus: '0.50'
          memory: 500M

Docker-Compose

version: '3.5'

services:
  heatmeterwebapi:
    image: kamstrupmalaga/heatmeterwebapi:latest
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
    ports:
      - "44000:80"
    deploy:
      replicas: 3
      restart_policy:
        condition: on-failure
        delay: 5s
        max_attempts: 3
        window: 120s
      resources:
        limits:
          cpus: '0.50'
          memory: 500M
        reservations:
          cpus: '0.25'
          memory: 20M

JMeter

by Jesús Estévez

JMeter

Why integration Testing?

Why not UI testing?

Create JMeter Test

Defining a simple Test Case 

Create JMeter Test

Variables

Create JMeter Test

HTTP Default values

Create JMeter Test

Using Variable and default HTTP values

Run Jmeter Test

Jmeter bla bla ...

Docker-Compose


version: '3.5'

services:
  heatmeterwebapi:
    container_name: heatmeterwebapi
    image: kamstrupmalaga/heatmeterwebapi:latest
    build:
      context: HeatMeterWebApi/
      dockerfile: Dockerfile
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
    ports:
      - "44318:80"

Docker-Compose


version: '3.5'

services:
  heatmeterwebapi:
    container_name: heatmeterwebapi
    image: kamstrupmalaga/heatmeterwebapi:latest
    build:
      context: HeatMeterWebApi/
      dockerfile: Dockerfile
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
    ports:
      - "44318:80"
    healthcheck:
      test: curl --fail -s http://localhost:44318/api/values || exit 1
      interval: 1m30s
      timeout: 10s
      retries: 3

Health

check

Docker-Compose


version: '3.5'

services:
  heatmeterwebapi:
    container_name: heatmeterwebapi
    image: kamstrupmalaga/heatmeterwebapi:latest
    build:
      context: HeatMeterWebApi/
      dockerfile: Dockerfile
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
    ports:
      - "44318:80"
  jmeter:
    container_name: jmeter
    image: vmarrazzo/jmeter

Docker-Compose


version: '3.5'

services:
  heatmeterwebapi:
    container_name: heatmeterwebapi
    image: kamstrupmalaga/heatmeterwebapi:latest
    build:
      context: HeatMeterWebApi/
      dockerfile: Dockerfile
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
    ports:
      - "44318:80"
  jmeter:
    container_name: jmeter
    image: vmarrazzo/jmeter
    volumes:
        - .:/mnt/jmeter

Docker-Compose


version: '3.5'

services:
  heatmeterwebapi:
    container_name: heatmeterwebapi
    image: kamstrupmalaga/heatmeterwebapi:latest
    build:
      context: HeatMeterWebApi/
      dockerfile: Dockerfile
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
    ports:
      - "44318:80"
  jmeter:
    container_name: jmeter
    image: vmarrazzo/jmeter
    volumes:
        - .:/mnt/jmeter
    entrypoint: jmeter  -n -t /mnt/jmeter/Jmeter/TestPlan.jmx 
                -j /mnt/jmeter/Jmeter/TestPlan.log -l /mnt/jmeter/Jmeter/TestPlan.jtl
                -JSERVERNAME=heatmeterwebapi -JPORTNUMBER=80 

Docker-Compose


version: '3.5'

services:
  heatmeterwebapi:
    container_name: heatmeterwebapi
    image: kamstrupmalaga/heatmeterwebapi:latest
    build:
      context: HeatMeterWebApi/
      dockerfile: Dockerfile
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
    ports:
      - "44318:80"
  jmeter:
    container_name: jmeter
    image: vmarrazzo/jmeter
    volumes:
        - .:/mnt/jmeter
    entrypoint: jmeter  -n -t /mnt/jmeter/Jmeter/TestPlan.jmx 
                -j /mnt/jmeter/Jmeter/TestPlan.log -l /mnt/jmeter/Jmeter/TestPlan.jtl
                -JSERVERNAME=heatmeterwebapi -JPORTNUMBER=80 
    depends_on:
      - heatmeterwebapi

Thanks for coming

and remember

Made with Slides.com