@@ -74,12 +74,12 @@ To generate the server stubs, follow these steps:
Here `swagger-codegen-cli.jar` is the downloaded Swagger Codegen _jar_ file, `oas-file.yaml` is the OAS YAML file and `~/output` is the path to the folder where the server stubs will be generated to.
### Client SDK
The Client SDK source code is generated using [Swagger Codegen](https://github.com/swagger-api/swagger-codegen).
The Client SDK source code is also generated using [Swagger Codegen](https://github.com/swagger-api/swagger-codegen).
The OpenAPI Specifications files available on ETSI Forge use version 3.1 of OAS. Currently this version is not supported on Swagger Codegen or on any other OAS code generator. To generate the server stubs, first the OAS files will need to be converted to OAS version 3.0 via the following steps:
- Change the value of `openapi` field from 3.1.0 to 3.0.0
- Use this VS code extension to see the errors in the downgraded YAML (v3.0)
- Use this [VS code extension](https://marketplace.visualstudio.com/items?itemName=42Crunch.vscode-openapi) to see the errors in the downgraded YAML (v3.0)
- Manually fix the errors
To generate the server stubs, follow these steps:
@@ -98,7 +98,7 @@ To generate the server stubs, follow these steps:
```
Here `swagger-codegen-cli.jar` is the downloaded Swagger Codegen _jar_ file, `oas-file.yaml` is the OAS YAML file and `~/output` is the path to the folder where the server stubs will be generated to.
> **Note:** Both server stubs and client SDK are generated using Swagger Codegen. The Go client SDK is required to develop the testing tool for the MEC030 micro-service (see clause [creating test code](#unit-tests-for-the-new-micro-service)). The Go client SDK is required to develop the backend of a MEC application using MEC030 micro-service.
> **Note:** Both server stubs and client SDK are generated using Swagger Codegen. The Go client SDK is required to develop the testing tool for the MEC micro-service (see clause [creating test code](#unit-tests-for-the-new-micro-service)). The Go client SDK is required to develop the backend of a MEC application using MEC030 micro-service.
## Development of Emulation Logic
@@ -134,7 +134,7 @@ There may be multiple files for `api_<api_tag>` and `model_<model_name>` dependi
Steps to implement server side emulation logic:
1.**Renaming _go_ Folder**
1.**Renaming _Go_ Folder**
Rename the `go` folder to `server` in order to make it consistent with other AdvantEDGE / Sandbox services.
@@ -229,10 +229,10 @@ meep-<mec-identifier>
### Client-side
During the phase of code generation (see [code generation](#generating-server-and-client-side-code)), two stubs of code are generated:
1. The server code
1. The server code (see clause [Server stubs](#server-stubs))
2. The client code (see clause [Client SDK](#client-sdk))
The code is used to create a test module or application for the micro-service.
The client side code is used to create a test module or application for the micro-service.
The test application can be used either in command line or integrated into the AdvantEDGE testing tool.
#### Code organization
@@ -277,7 +277,7 @@ Steps to implement server side emulation logic:
1.**Client package renaming**
The go client package generated by [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) is a package named 'swagger'. This package name is to be renamed to 'client' using the following command:
The _Go_ client package generated by [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) is a package named 'swagger'. This package is to be renamed to _'client'_ using the following command:
@@ -290,7 +290,7 @@ Steps to implement server side emulation logic:
3.**Rename generated constants name**
Sometimes. the Swagger Codegen generates automatic names for constants (e.g. model_transmission_bandwidth_transmission_bandwidth.go). Unfortunately, these names are not compliant with go language (e.g. _1__TransmissionBandwidthTransmissionBandwidth_).
In this case, it is required to rename them properly (e.g. _1__TransmissionBandwidthTransmissionBandwidth_ shall renamed into _bw6_).
In this case, it is required to rename them properly (e.g. _1__TransmissionBandwidthTransmissionBandwidth_ shall be renamed to _bw6_).
4.**Creating _go.mod_ and _go.sum_ files**
@@ -332,19 +332,29 @@ meep-<mec-identifier>
```
## Unit tests for the new micro-service
A micro-service server provides unit tests that will help validation of it.
The steps to achieve it are described below:
Unit tests should be written for a MEC micro-service for its validation. The steps to achieve this are described below:
1.**Create a testing file**
Create a file named <mec-identifier>_test.go
The files will look something like the file/folder structure shown below:
Create a file named `<mec-identifier>_test.go`.
The files in the server stubs folder will look something like the file/folder structure shown below:
```
meep-<mec-identifier>
|
\____ ...
\____ main.go
|
\____ go.mod
|
\____ go.sum
|
\____ api
| |
| \____ swagger.yaml
|
\____ sbi
| |
| \____ <mec-identifier>-sbi.go
|
\____ server
|
@@ -362,20 +372,20 @@ meep-<mec-identifier>
|
\____ <mec-identifier>.go
|
\____ <mec-identifier>_Test.go
\____ <mec-identifier>_test.go
```
2.**Implement tests for unimplemented methods**
For each HTTP methods some tests for valid behavior and unexpected behavior should be created.
For each HTTP method, some tests for valid and unexpected behavior should be created.
3.**Implement tests for implemented methods**
For each HTTP methods some tests for valid behavior and unexpected behavior should be created.
For each HTTP method, some tests for valid and unexpected behavior should be created.
4.**Executing the tests**
4.**Executing the tests for a single MEC service**
In the server folder, execute the following command:
In the server stubs folder, execute the following command:
```sh
$ go test-count=1 ./... -cover
```
@@ -395,16 +405,16 @@ Steps to implement server side emulation logic:
2.**Creating test code**
After the micro-service has been created, a _go_ source file in `/AdvantEDGE/test/system` folder will be created containing the code for testing the HTTP REST APIs.
After the micro-service has been created, a _Go_ source file in `/AdvantEDGE/test/system` folder will need to be created which should contain the code for testing the HTTP REST APIs.