-
Notifications
You must be signed in to change notification settings - Fork 243
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
Odo test cmd for devfile 2.0 #3400
Odo test cmd for devfile 2.0 #3400
Conversation
Signed-off-by: Stephanie <stephanie.cao@ibm.com>
Signed-off-by: Stephanie <stephanie.cao@ibm.com>
Signed-off-by: Stephanie <stephanie.cao@ibm.com>
Signed-off-by: Stephanie <stephanie.cao@ibm.com>
Signed-off-by: Stephanie <stephanie.cao@ibm.com>
Signed-off-by: Stephanie <stephanie.cao@ibm.com>
@@ -140,6 +141,27 @@ func (a Adapter) Push(parameters common.PushParameters) (err error) { | |||
return nil | |||
} | |||
|
|||
func (a Adapter) Test(testcmd versionsCommon.DevfileCommand, show bool) (err error) { |
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.
Please add some comments for the function
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.
updated
componentExists := utils.ComponentExists(a.Client, a.ComponentName) | ||
if !componentExists { | ||
return fmt.Errorf("component does not exist, a valid component is required to run 'odo test'") | ||
} |
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.
Do we really need this call since we are getting the pod just after it? Won't that be enough?
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 checks if the deployment exist; and we should show different error message if there is a problem when getting pod.
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.
But on a slow cluster both calls will cause performance problems. Since without the pod, it won't run anyways, just check for the pod and error out with a message like the component is not running....
.
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.
Since this PR does both docker and kube; docker logic cannot be applied with the above logic since an odo component in docker can have multiple containers. So if a devfile has 2 components, that translates to 2 containers in docker. But if one of the containers is down; we cannot say a component exist with at least one container in our example.
I can honestly see where your argument is but i think even odo watch
and odo push
have these logic which can be refactored more optimally.
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.
Since this PR does both docker and kube; docker logic cannot be applied with the above logic since an odo component in docker can have multiple containers.
For docker, we can write it separately in the docker adapter. Logic in the Kubernetes should be independent of that. Otherwise performance of kubernetes components will be impacted unnecessarily.
@yangcao77 with #3400 (comment) implemented, we can remove this call as the pod check is necessary anyways. So only check for the pod and if not running, just error out with a message like component is not running
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.
updated the Kubernetes logic
pkg/odo/cli/component/test.go
Outdated
Short: "Run test command defined in devfile", | ||
Long: "Run test command defined in devfile", |
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.
run the
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.
updated
vendor/k8s.io/kubectl/go.sum
Outdated
k8s.io/api v0.17.1 h1:i46MidoDOE9tvQ0TTEYggf3ka/pziP1+tHI/GFVeJao= | ||
k8s.io/api v0.17.1/go.mod h1:zxiAc5y8Ngn4fmhWUtSxuUlkfz1ixT7j9wESokELzOg= | ||
k8s.io/apimachinery v0.17.1 h1:zUjS3szTxoUjTDYNvdFkYt2uMEXLcthcbp+7uZvWhYM= | ||
k8s.io/apimachinery v0.17.1/go.mod h1:b9qmWdKlLuU9EBh+06BtLcSf/Mu89rWL33naRxs1uZg= | ||
k8s.io/cli-runtime v0.17.1/go.mod h1:e5847Iy85W9uWH3rZofXTG/9nOUyGKGTVnObYF7zSik= | ||
k8s.io/client-go v0.17.1 h1:LbbuZ5tI7OYx4et5DfRFcJuoojvpYO0c7vps2rgJsHY= |
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 think these changes need to be removed
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.
removed
Signed-off-by: Stephanie <stephanie.cao@ibm.com>
Signed-off-by: Stephanie <stephanie.cao@ibm.com>
Signed-off-by: Stephanie <stephanie.cao@ibm.com>
/unhold |
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.
Works for me
/lgtm
/hold Honestly, we haven't had much discussion with regards to this command in the issue: #3284 Perhaps we can make 100% sure we want this command before we merge? |
Signed-off-by: Stephanie <stephanie.cao@ibm.com>
Signed-off-by: Stephanie <stephanie.cao@ibm.com>
/retest |
1 similar comment
/retest |
re-adding lgtm after rebase |
@cdrage Do you still have any questions or concerns that you want to discuss? |
/hold cancel |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: kadel The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest |
1 similar comment
/retest |
/retest Please review the full test history for this PR and help us cut down flakes. |
What type of PR is this?
/kind user-story
/area devfileV2
What does does this PR do / why we need it:
odo test
will run test command specified in the command that belongs to the group test defined in the devfileodo uses this logic to decide which test command to run on odo test:
odo test --test-command <command name>
will execute the command with the given command name regardless of a default test command is defined or not.Which issue(s) this PR fixes:
Fixes #3284
How to test changes / Special notes to the reviewer:
Automation:
run
make test-cmd-devfile-test
andmake test-cmd-docker-devfile-test
Manual:
(The following shows docker scenario, kube scenario should be similar)
Use the devfile.yaml within this PR:
devfile-with-testgroup.yaml
run
odo create
andodo push
.run
odo test
docker exec -it <containerID> ls -la /projects/nodejs-web-app/
should see test1 directory existrun
odo test --test-command test2
docker exec -it <containerID> ls -la /projects/nodejs-web-app/
should see test2 directory exist