-
Notifications
You must be signed in to change notification settings - Fork 156
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
Add test for executing K8S_SYNC stage at the kubernetes plugin #5431
Conversation
Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev>
Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev>
Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev>
assert.Equal(t, "simple", deployment.GetName()) | ||
assert.Equal(t, "simple", deployment.GetLabels()["app"]) | ||
assert.Equal(t, "piped", deployment.GetAnnotations()["pipecd.dev/managed-by"]) | ||
assert.Equal(t, "piped-id", deployment.GetAnnotations()["pipecd.dev/piped"]) | ||
assert.Equal(t, "app-id", deployment.GetAnnotations()["pipecd.dev/application"]) | ||
assert.Equal(t, "apps/v1", deployment.GetAnnotations()["pipecd.dev/original-api-version"]) | ||
assert.Equal(t, "apps/v1:Deployment:default:simple", deployment.GetAnnotations()["pipecd.dev/resource-key"]) | ||
assert.Equal(t, "0123456789", deployment.GetAnnotations()["pipecd.dev/commit-hash"]) |
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.
these assertions are copied from #5399
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5431 +/- ##
==========================================
+ Coverage 26.11% 26.24% +0.13%
==========================================
Files 451 452 +1
Lines 48823 48860 +37
==========================================
+ Hits 12749 12825 +76
+ Misses 35057 35011 -46
- Partials 1017 1024 +7 ☔ View full report in Codecov by Sentry. |
if k.Namespace == "" { | ||
k.Namespace = DefaultNamespace | ||
} |
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.
There was an incompatibility between the current Kubernetes platform provider and the Kubernetes plugin, so I fixed this.
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 quite tricky and could lead to some issues because logic which depends on resource key need the ns be set carefully. Say, if the resource is cluster resource, we should not force setting ns value to it cc @ffjlabo
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.
IMO: it is quite tricky as @khanhtc1202 said. So at first, we might be good to implement the same as pipedv0. And later fix the resource key problem.
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.
|
||
// newTestLogPersister creates a new testLogPersister for testing. | ||
// | ||
// TODO: move to a common package |
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 good to move this to logpersister package itself. Just like git package provides gittest for testing
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.
Thank you. I moved these to pkg/plugin/logpersister/logpersistertest
.
3c0a57d
} | ||
} | ||
|
||
// TODO: move to a common package |
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 is okay to be here since it's kubernetes specific
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.
Thank you. I removed the TODO comment.
8fe9dad
if k.Namespace == "" { | ||
k.Namespace = DefaultNamespace | ||
} |
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 quite tricky and could lead to some issues because logic which depends on resource key need the ns be set carefully. Say, if the resource is cluster resource, we should not force setting ns value to it cc @ffjlabo
Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev>
Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev> This reverts commit 098d1da.
Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev>
Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev>
@@ -189,7 +189,7 @@ func (a *DeploymentService) loadManifests(ctx context.Context, deploy *model.Dep | |||
manifests, err := a.loader.LoadManifests(ctx, provider.LoaderInput{ | |||
PipedID: deploy.GetPipedId(), | |||
AppID: deploy.GetApplicationId(), | |||
CommitHash: deploy.GetTrigger().GetCommit().GetHash(), | |||
CommitHash: deploymentSource.GetRevision(), |
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 could be the same but I like the previous version more. How about to rename GetRevision
to GetCommitHash
🤔
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.
First, I also like commit hash
more than revision
.
However, this is not the same because the deploymentSource
can be the running deploy source, not the target deploy source.
The naming GetRevision
comes from proto definition, so how about renaming this field as commit_hash
?
pipecd/pkg/plugin/api/v1alpha1/deployment/api.proto
Lines 142 to 143 in 17a5007
// The git commit revision of the source code. | |
string revision = 2; |
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.
I got your point. Also, it's a commit hash, so it should be named directly as a commit hash to reduce confusion. Let's address it by another PR (change proto and update this)
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.
LGTM 👍
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.
LGTM 🚀
What this PR does:
Implement the test in the same way as #5399 at the Kubernetes plugin, then fix the failure about the resource key.
Why we need it:
To ensure compatibility between the current Kubernetes platform provider and the Kubernetes plugin.
Which issue(s) this PR fixes:
Part of #4980
Does this PR introduce a user-facing change?: No