Skip to content

Latest commit

 

History

History
66 lines (64 loc) · 4.54 KB

E2E setup instructions.md

File metadata and controls

66 lines (64 loc) · 4.54 KB

Prerequisites

  • Open docker desktop.
    • Go to settings -> Kubernetes tab.
    • Enable Kubernetes (might take a couple minutes)
    • Double check docker kubernetes is being used: kubectl config get-contexts

  • Install E4K.
    • helm install e4k oci://e4kpreview.azurecr.io/helm/az-e4k --version 0.5.0-rc1

  • Execute 'cert-w.sh' script.
    • bash cert-w.sh
    • kubectl create configmap client-ca --from-file ca.pem=ca.pem
    • kubectl create secret tls e4k-custom-ca-cert --cert=e4k-auth-ca.pem --key=e4k-auth-ca-key.pem
    • kubectl create secret tls e4k-8883-cert --cert=dmqtt-cert.pem --key=dmqtt-cert-key.pem
    • kubectl create serviceaccount azedge-dmqtt-module-client-sa
      The script will create config map client-ca and secrets e4k-8883-cert and e4k-custom-ca-cert in kubernetes. You can view them using commands kubectl get configmap and kubectl get secrets.

  • Create an ACR (Azure container registry).
    • Create token and retreive password and login command.
      -- Repository Permissions -> Tokens -> Add -> Create

  • Login to docker using the command retreived above.

  • Create a kubernetes secret to keep the above info as a secret.
    • kubectl create secret docker-registry e4kacr --docker-server=<your ACR>.azurecr.io --docker-username=<USERNAME> --docker-password={somepassword}

  • Publish the hub-connector and leaf device as an image.
    • dotnet publish test/leaf-device/leaf-device.csproj /t:PublishContainer --os linux --arch x64 /p:ContainerRepository="<your ACR>.azurecr.io" /p:ContainerImageName=<your ACR>.azurecr.io/<IMAGE NAME OF YOUR CHOICE> /p:ContainerImageTags=1.0.0
    • dotnet publish src/hub-connector/hub-connector.csproj /t:PublishContainer --os linux --arch x64 /p:ContainerRepository="<your ACR>.azurecr.io" /p:ContainerImageName=<your ACR>.azurecr.io/<IMAGE NAME OF YOUR CHOICE> /p:ContainerImageTags=1.0.0

  • Push the images (hub-connector & leaf-device).
    • docker push <your ACR>.azurecr.io/<IMAGE NAME USED FOR hub-connector AND leaf device>:1.0.0

  • Go to deploy folder and update the hub-connector and leaf-device yaml files to use the above created images.

  • Create an IoT hub, create an edge device (e4k-edge-1), create a leaf device (leaf-device-1) on the hub. Set the parent of the leaf device to be the edge device.

  • Create kubernetes secret for both edge device and leaf device.
    • kubectl create secret generic e4k-gateway-secrets --from-literal=edgeDevice="<EDGE DEVICE CONNECTION STRING>;UseTls=true;ClientId=hub-connector;MqttVersion=5;CaFile=/certs/ca.pem" --from-literal=Broker=HostName=azedge-dmqtt-frontend
    • kubectl create secret generic leaf-device-secrets --from-literal=cs="<LEAF DEVICE CONNECTION STRING>;MqttGatewayHostName=azedge-dmqtt-frontend;CaFile=/certs/ca.pem"

  • Create a leaf device (non edge device) on the Iot Hub. This leaf device will not have any parent and will be a direct leaf device. This is probably only used in e2e.
    • kubectl create secret generic direct-device-secrets --from-literal=cs="<LEAF DEVICE CONNECTION STRING>"

  • Deploy everything within /deploy/e4k folder. Also deploy the hub-connector and leaf device separately.
    • kubectl apply -f deploy/e4k
    • kubectl apply -f deploy/hub-connector.yaml
    • kubectl apply -f deploy/leaf-device.yaml

  • Execute kubectl get pods and make sure all pods are ready and in running state. (may take a couple minutes)

  • Go to Azure portal and execute a direct method on the leaf device (method name: echo) and confirm that a response is received.

Run E2E tests

  • Copy the file runsettings.template from e4k hub connector repo and update the template with the hub connection string.
    • Go to /test/MqttSdkLite.E2ETests/Properties and paste the file.

  • Copy the contents of file hub-connector launchSettings.json from this repo and update it with the edge device connection string.
    • Go to /src/hub-connector/Properties/ and paste file and rename it to launchSettings.json

  • Copy the contents of file leafDevice launchSettings.json from this repo and update it with the leaf device connection string.
    • Go to /test/leaf-device/Properties/ and paste file and rename it to launchSettings.json

  • Update test files (e.g: DirectDeviceTest.cs, E4KDeviceTest.cs etc) to correspond to respective device.
    • Execute E2E tests to make sure tests work as expected.