kubevela / kubevela

The Modern Application Platform.
https://kubevela.io
Apache License 2.0
6.45k stars 892 forks source link

[Feature] Add test case for checking consistency of policy spec between CUE and Golang #5507

Open chivalryq opened 1 year ago

chivalryq commented 1 year ago

For now we have some policy spec in golang stored in apis/core.oam.dev/v1alpha1. The corresponding CUE spec are stored in vela-templates/definitions/internal/policy.

Although these files are trying to describe the same specifications like apis/core.oam.dev/v1alpha1/readonly_policy_types.go and vela-templates/definitions/internal/policy/read-only.cue, there is no source of truth. None of them is generated from each other. So we need some test cases to check if they are consistent.


we need some test case to cover

Originally posted by @wonderflow in https://github.com/kubevela/kubevela/pull/5498#pullrequestreview-1296976654

swastik959 commented 1 year ago

@chivalryq can you please tell me the location to where the test case is to be made

rhzx3519 commented 1 year ago

Please provide some clues about how to verify the consistency between cue and go. Thank you.

chivalryq commented 1 year ago

Hi @rhzx3519 @swastik959 This is a kinda tricky problem. There are two ways to do that.

  1. Make one is generated from another.
  2. Use some mock data to test it fits both the Go struct and CUE schema.

Considering the generating problems I think it's easier take the second method to implement this. You can add test in apis/core.oam.dev/v1alpha1

rhzx3519 commented 1 year ago

Hi @rhzx3519 @swastik959 This is a kinda tricky problem. There are two ways to do that.

  1. Make one is generated from another.
  2. Use some mock data to test it fits both the Go struct and CUE schema.

Considering the generating problems I think it's easier take the second method to implement this. You can add test in apis/core.oam.dev/v1alpha1

Yep, I agree the second method would be an easy way to implement. I'll take this issue.

swastik959 commented 1 year ago

@rhzx3519 sorry but I have already started working on this issue

rhzx3519 commented 1 year ago

@swastik959 Okay, I'll look for other issues.

swastik959 commented 1 year ago

@chivalryq I have tried to make a example test case please check if this is what you want