-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PoC] Launch test YAMLs directly #1487
Conversation
df67e12
to
3f6195f
Compare
Signed-off-by: jose.vazquez <jose.vazquez@mongodb.com>
|
||
const ( | ||
ExpectedContext = "kind-kind" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stylistic nit: remove those extra newlines, const blocks are tight.
// Launch will try to launch the operator and apply the given YAML for it to handle | ||
func (l *Launcher) Launch(yml string, waitCfg *WaitConfig) error { | ||
if err := l.ensureK8sCluster(); err != nil { | ||
return err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrap all errors below. In this case:
return err | |
return fmt.Errorf("error ensuring k8s cluster: %w", err) |
@josvazg I see you are inventing your own testing framework here. What about just using https://kuttl.dev/ ? |
This is not a testing framework, it is a simple testing helper. It could be used as a framework maybe, but it is NOT the intent here and for that I agree that KUTTL is a better option. Think of this as the function I call in Go to get the Atlas infrastructure in the state I need to run a contract test, which is defined in Go code, not in YAML. A test that calls our translation layer that talks to the API using the same code that the reconcile logic uses. If KUTTL could be used in the same unobtrusive way, then maybe we could use it for all, I am not 100% convinced yet. Sample custom test: l := launcher.NewFromEnv(testVersion) // instantiate a launcher
l.Launch(testYml, launcher.WaitReady("atlasprojects/my-project", 30*time.Second))) // launch the YAML and wait for it
// run custom test code - might not be part of KUTTLE, like a custom go code driven contract test
l.Cleanup()) // optionally cleanup the infrastructure required for the test (does KUTTL allow for optional cleanup?) |
@josvazg I am leaving the final assertion to you 👍 I didn't have a deeper look at kuttl, just worried about NIH implementations. Again, final call is yours :-) |
I think the best way forward now is to actually force myself to use KUTTL for some real Contract tests, for Atlas Search. If I see no blockers, then we can probably use for everything and forget about this PoC for good. |
|
||
func (cfg *WaitConfig) waitArgs() []string { | ||
args := []string{"wait", fmt.Sprintf("--for=%s", cfg.Condition), cfg.Target} | ||
if cfg.Timeout == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a mistake or do you really want to set timeout only when it's zero?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a mistake, the logic had to be reversed
@josvazg This PoC links well to my comment on the CI Revamp document regarding GitHub Actions. Why didn't you write a Github action workflow for it? I'd say we probably won't need any code for it. |
const ( | ||
ExpectedContext = "kind-kind" | ||
|
||
LauncherTestInstall = "test-ako" | ||
|
||
HelmRepoURL = "https://mongodb.github.io/helm-chart" | ||
|
||
RepoRef = "mongodb" | ||
|
||
OperatorChart = "mongodb-atlas-operator" | ||
|
||
AtlasURI = "https://cloud-qa.mongodb.com" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const ( | |
ExpectedContext = "kind-kind" | |
LauncherTestInstall = "test-ako" | |
HelmRepoURL = "https://mongodb.github.io/helm-chart" | |
RepoRef = "mongodb" | |
OperatorChart = "mongodb-atlas-operator" | |
AtlasURI = "https://cloud-qa.mongodb.com" | |
) | |
const ( | |
ExpectedContext = "kind-kind" | |
LauncherTestInstall = "test-ako" | |
HelmRepoURL = "https://mongodb.github.io/helm-chart" | |
RepoRef = "mongodb" | |
OperatorChart = "mongodb-atlas-operator" | |
AtlasURI = "https://cloud-qa.mongodb.com" | |
) |
I want us to be able to do our development without any Github involvement, using the GitHub CI actions or workflow only to automatically re-run tests at the proper time to ensure what we release is correct and did not include any regressions. The idea is to be able to write contract tests in Go that look like this:
During development, in your laptop and before any code reaches GitHub, you iterate with steps 1-2 until you test all APIs you needed to verify. Then do step 3, when you are done. It is only later on you send a PR and then the CI might also want to run those tests at some point, maybe at merge time only. This might be doable with KUTTL, because it seems to have a programmatic interface. I will need to test it. BTW, even if KUTTL could not do the job fully and this simple launcher would be required, I have the impression it would be able to replace a lot of our current test helper code, which would mean a net removal of code and thus reduced liability instead. |
Going to close this PoC now:
|
PoC not to merge but to be used for API testing.
All Submissions: