In pr we built model conversion unit tests for sources including nacos, eureka, and zookeeper. The tests focus on the validation of the registry's raw service model data to the expected istio ServiceEntry.
As requirements were created and changed, we continued to extend the source parameters that influenced what the raw service model would look like transformed into the target ServiceEntry. Historically, we validated new requirements by building actual registry registration demo services, which was very time and effort consuming. Using the unit test approach in pr, it is possible to quickly validate the new logic.
The coverage is increased as follows:
# before
$ go test -timeout 30s -cover slime.io/slime/modules/meshregistry/pkg/source/...
? slime.io/slime/modules/meshregistry/pkg/source/eureka [no test files]
? slime.io/slime/modules/meshregistry/pkg/source/k8s [no test files]
? slime.io/slime/modules/meshregistry/pkg/source/k8s/fs [no test files]
? slime.io/slime/modules/meshregistry/pkg/source/nacos [no test files]
ok slime.io/slime/modules/meshregistry/pkg/source 0.021s coverage: 47.6% of statements
ok slime.io/slime/modules/meshregistry/pkg/source/zookeeper 0.018s coverage: 1.8% of statements
# after
$ go test -timeout 30s -cover slime.io/slime/modules/meshregistry/pkg/source/...
ok slime.io/slime/modules/meshregistry/pkg/source 0.021s coverage: 47.6% of statements
? slime.io/slime/modules/meshregistry/pkg/source/k8s [no test files]
? slime.io/slime/modules/meshregistry/pkg/source/k8s/fs [no test files]
ok slime.io/slime/modules/meshregistry/pkg/source/eureka 0.032s coverage: 45.0% of statements
ok slime.io/slime/modules/meshregistry/pkg/source/nacos 0.030s coverage: 26.5% of statements
ok slime.io/slime/modules/meshregistry/pkg/source/sourcetest 0.020s coverage: 13.3% of statements
ok slime.io/slime/modules/meshregistry/pkg/source/zookeeper 0.047s coverage: 37.3% of statements
In pr we built model conversion unit tests for sources including nacos, eureka, and zookeeper. The tests focus on the validation of the registry's raw service model data to the expected istio ServiceEntry.
As requirements were created and changed, we continued to extend the source parameters that influenced what the raw service model would look like transformed into the target ServiceEntry. Historically, we validated new requirements by building actual registry registration demo services, which was very time and effort consuming. Using the unit test approach in pr, it is possible to quickly validate the new logic.
The coverage is increased as follows: