DE 

//Cloudogu EcoSystem Docs

Development of cesappd

Development

To check if cesappd is up and running run systemctl status cesappd. To start cesappd run systemctl start cesappd.

Tools needed

Test

Note: Use IP address for gRPC address (e.g. 192.168.56.1), but not localhost and the like.

To allow clients such as grpcox to use the service discovery feature of the server, cesappd must be configured with the with the --env development parameter. In production mode, the endpoint information is not passed to the outside and must be and must be known to the client accordingly.

Sample calls with grpcurl:

# list available services
./grpcurl -plaintext localhost:50051 list

# send request to logging service
./grpcurl -plaintext -d '{"doguName": "nginx", "lineCount": 10}' localhost:50051 logging.DoguLogMessages/GetByLineNumber

To send a request from inside a dogu you have to add a new firewall rule for the port used by the service.

ufw allow from "$(docker network inspect "cesnet1" -f '{{(index .IPAM.Config 0).Subnet}}')" to any port 50051

If using your own docker container the container must be connected to the cesnet1 docker network.

docker run -it --net cesnet1 alpine bash

Execution of bats tests

A make target has been created with which all bats tests can be executed: make unit-test-shell

Generation of gRPC code

  1. Install additional gRPC tools

    • make install-grpc-tools
  2. generate gRPC code

    • make generate-grpc

Generate code from new protobuf file

  • Set package for new functionality, e.g. newpackage.

    • package is used among other things for structured storage of generated code
    • the package name must contain the complete module name so the imports will be generated correctly
  • create new file in grpc-protobuf/, e.g. grpc-protobuf/newfunction.
syntax = "proto3";
package newpackage;
option go_package = "github.com/cloudogu/cesappd/generated/newpackage";
  • call make generate-grpc; *.pb*.go files

    • *.pb*.go files are created in directory/package `generated/newpackage
    • custom functionality must be placed in directory/package `newpackage

Local execution

The service cesappd reads log files from the predefined directory /var/log/docker. You have to ensure the directory exists and your desired log files are present. Depending on the execution context you may have to adjust the file permissions.

Execution in CES context

  • Build the cesappd with make (gpg key must be configured for this).
  • From cesappd/target directory copy the file cesappd to the root directory of the local CES.
  • Install inside the Vagrant machine using dpkg -i cesappd.deb (this will run the postinst script).

To test the prerm and postrm scripts, cesappd can be deleted using the command dpkg -r cesappd. The scripts will then be executed.

Communicate with etcd inside a local CES

To communicate directly with the etcd inside a local CES you need to apply an additional firewall rule.

ufw allow from 192.168.56.1 to any port 4001

In addition you need to create a minimal cesapp configuration file located at /etc/cesapp/configuration with the following content.

{ 
  "registry": {
    "type": "etcd",
    "endpoints": [
      "http://192.168.56.1:4001"
    ]
  }
}