Skip to content
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

Merged
merged 31 commits into from
Jul 17, 2020

Conversation

yangcao77
Copy link
Contributor

@yangcao77 yangcao77 commented Jun 22, 2020

What type of PR is this?

Uncomment only one /kind line, and delete the rest.
For example, > /kind bug would simply become: /kind bug

/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 devfile

odo uses this logic to decide which test command to run on odo test:

  • if only one test command is define, use that command regardless of whether that command with isDefault is set to true or not.
  • if more than one test command, execute the one with isDefault set to true
  • 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.
  • if more than one test command but no default is defined(or if multiple default commands are defined), error out if --test-command is not use.

Which issue(s) this PR fixes:

Fixes #3284

How to test changes / Special notes to the reviewer:
Automation:
run make test-cmd-devfile-test and make 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 and odo push.
run odo test
docker exec -it <containerID> ls -la /projects/nodejs-web-app/ should see test1 directory exist

run odo test --test-command test2
docker exec -it <containerID> ls -la /projects/nodejs-web-app/ should see test2 directory exist

Stephanie added 9 commits June 15, 2020 10:56
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>
@openshift-ci-robot openshift-ci-robot added kind/user-story An issue of user-story kind area/devfileV2 labels Jun 22, 2020
@yangcao77 yangcao77 marked this pull request as draft June 22, 2020 19:08
@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. Required by Prow. label Jun 22, 2020
@yangcao77
Copy link
Contributor Author

Mark as a draft pr since this PR is blocked by #3291
Copied some functions from #3291 in order to make it work. Need to rebase after #3291 gets merged.

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. Required by Prow. label Jun 27, 2020
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. Required by Prow. label Jun 29, 2020
@yangcao77 yangcao77 marked this pull request as ready for review June 29, 2020 15:40
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. Required by Prow. label Jun 29, 2020
Signed-off-by: Stephanie <stephanie.cao@ibm.com>
@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. Required by Prow. label Jul 2, 2020
@@ -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) {
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

Comment on lines 166 to 169
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'")
}
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

@mik-dass mik-dass Jul 7, 2020

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.....

Copy link
Contributor

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.

Copy link
Contributor

@mik-dass mik-dass Jul 8, 2020

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated the Kubernetes logic

Comment on lines 102 to 103
Short: "Run test command defined in devfile",
Long: "Run test command defined in devfile",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

run the

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

Comment on lines 326 to 331
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=
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

Stephanie added 2 commits July 14, 2020 09:22
@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Jul 14, 2020
Stephanie added 3 commits July 14, 2020 09:40
Signed-off-by: Stephanie <stephanie.cao@ibm.com>
Signed-off-by: Stephanie <stephanie.cao@ibm.com>
@yangcao77
Copy link
Contributor Author

/unhold

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. Required by Prow. label Jul 14, 2020
Copy link
Contributor

@mik-dass mik-dass left a 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

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Jul 14, 2020
@cdrage
Copy link
Member

cdrage commented Jul 14, 2020

/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?

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. Required by Prow. label Jul 14, 2020
Stephanie added 2 commits July 15, 2020 11:01
Signed-off-by: Stephanie <stephanie.cao@ibm.com>
Signed-off-by: Stephanie <stephanie.cao@ibm.com>
@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Jul 15, 2020
@yangcao77
Copy link
Contributor Author

/retest

1 similar comment
@yangcao77
Copy link
Contributor Author

/retest

@maysunfaisal
Copy link
Contributor

re-adding lgtm after rebase
/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Jul 15, 2020
@yangcao77
Copy link
Contributor Author

@cdrage Do you still have any questions or concerns that you want to discuss?
Can I get an approve label for this PR?

@kadel
Copy link
Member

kadel commented Jul 16, 2020

/hold cancel
/approve

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. Required by Prow. label Jul 16, 2020
@openshift-ci-robot
Copy link
Collaborator

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. Required by Prow. label Jul 16, 2020
@kadel
Copy link
Member

kadel commented Jul 16, 2020

/retest

1 similar comment
@yangcao77
Copy link
Contributor Author

/retest

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit 81adbcc into redhat-developer:master Jul 17, 2020
@maysunfaisal maysunfaisal mentioned this pull request Aug 5, 2020
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. Required by Prow. kind/user-story An issue of user-story kind lgtm Indicates that a PR is ready to be merged. Required by Prow.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support application testing defined in the devfile v2
8 participants