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

Adds "odo service create --context" feature #1997

Merged
merged 8 commits into from Aug 29, 2019
Merged

Adds "odo service create --context" feature #1997

merged 8 commits into from Aug 29, 2019

Conversation

dharmit
Copy link
Member

@dharmit dharmit commented Aug 7, 2019

What is the purpose of this change? What does it change?

This PR enables the users to create a service with odo service create --context /path/to/component/dir command. This allows service creation from anywhere in the system.

Was the change discussed in an issue?

fixes #1872

How to test changes?

  • Build the binary
  • Using nodejs-ex as an example, perform following:
    $ git clone https://github.com/sclorg/nodejs-ex /tmp/nodejs-ex
    $ cd /tmp/nodejs-ex
    $ odo create nodejs
    $ cd # this takes you to home dir
    $ odo service create dh-postgresql-apb --plan dev -p postgresql_user=luke -p postgresql_password=secret -p postgresql_database=my_data -p postgresql_version=9.6 --context /tmp/nodejs-ex
    
    # Use the --context from /tmp/nodejs-ex/ to list the service
    $ odo service list --context /tmp/nodejs-ex
    
    # Use the --context from /tmp/nodejs-ex/ to delete the service
    $ odo service delete --context /tmp/nodejs-ex
    
    # Bonus points for testing with --app and --project flag along with --context
    # I think the project should exist on the cluster. If app doesn't exist, odo will create it.
    $ odo service create dh-prometheus-apb --plan ephemeral --context /tmp/nodejs-ex --app myapp --project myproject

@dharmit
Copy link
Member Author

dharmit commented Aug 8, 2019

I'll add tests for failure scenario. Missed adding that in the initial PR.

@dharmit
Copy link
Member Author

dharmit commented Aug 9, 2019

I'll add tests for failure scenario. Missed adding that in the initial PR.

Added this as well as added --context flag to odo service list and odo service delete commands as that seemed like a logical thing to do since we're adding the flag to odo service create command.

@surajnarwade
Copy link
Contributor

code wise LGTM

I will wait for CI and then approve it 😄

@openshift-ci-robot openshift-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. Required by Prow. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. Required by Prow. labels Aug 17, 2019
@@ -107,6 +108,7 @@ var _ = Describe("odoServiceE2e", func() {
project = helper.CreateRandProject()
Copy link
Contributor

Choose a reason for hiding this comment

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

To avoid preference conflict in parallel run, use format of context and project create

context = helper.CreateNewContext()
os.Setenv("GLOBALODOCONFIG", filepath.Join(context, "config.yaml"))
project = helper.CreateRandProject()

Also in JsutAfterEach unset the env var

os.Unsetenv("GLOBALODOCONFIG")

It("should be able to create, list and delete a service using a given value for --context", func() {
// create a component by copying the example
helper.CopyExample(filepath.Join("source", "nodejs"), context)
helper.CmdShouldPass("odo", "create", "nodejs", "--app", app, "--project", project)
Copy link
Contributor

Choose a reason for hiding this comment

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

We have already one nodejs component create in this test file. Can you try with some other component

$ odo catalog list components
NAME        PROJECT       TAGS
dotnet      openshift     2.0,latest
httpd       openshift     2.4,latest
nginx       openshift     1.10,1.12,1.8,latest
nodejs      openshift     10,6,8,8-RHOAR,latest
perl        openshift     5.24,5.26,latest
php         openshift     7.0,7.1,latest
python      openshift     2.7,3.5,3.6,latest
ruby        openshift     2.3,2.4,2.5,latest
wildfly     openshift     10.0,10.1,11.0,12.0,13.0,8.1,9.0,latest

It("should fail to create a service when given directory doesn't contain a context", func() {
// cd to the originalDir to create service using --context
helper.Chdir(originalDir)
stdOut := helper.CmdShouldFail("odo", "service", "create", "dh-postgresql-apb", "--plan", "dev",
Copy link
Contributor

Choose a reason for hiding this comment

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

Pleas add SetDefaultConsistentlyDuration(30 * time.Second) in BeforeEach(func(){} block because CmdShouldFail has been implemented in a different way, otherwise later it will be flaky

See http://onsi.github.io/gomega/#making-asynchronous-assertions for more details.

Expect(stdOut).To(ContainSubstring(serviceName))

// now check if deleting the service using --context works
stdOut = helper.CmdShouldPass("odo", "service", "delete", "-f", "serviceName", "--context", context)
Copy link
Contributor

Choose a reason for hiding this comment

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

"serviceName" -> serviceName

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the catch!

@cdrage
Copy link
Member

cdrage commented Aug 21, 2019

/retest
(travis failed due to a flake)

@dharmit
Copy link
Member Author

dharmit commented Aug 23, 2019

Made changes as per @amitkrout's review feedback.

@kadel @girishramnani @mohammedzee1000 @cdrage can I please have a review on this? I have already demo'd this and have made numerous requests in the past on slack for reviewing this!

@amitkrout
Copy link
Contributor

Travis is failing
/hold

@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 Aug 23, 2019
@amitkrout
Copy link
Contributor

/test integration

@amitkrout
Copy link
Contributor

/hold cancel

@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 Aug 29, 2019
@amitkrout
Copy link
Contributor

/approve

@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: amitkrout

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 Aug 29, 2019
@dharmit dharmit requested review from kadel, cdrage and mik-dass and removed request for surajnarwade August 29, 2019 12:21
Copy link
Member

@cdrage cdrage left a comment

Choose a reason for hiding this comment

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

Thanks for adding these tests. All of this works 👍

Great job @dharmit !

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Aug 29, 2019
@openshift-bot
Copy link

/retest

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

1 similar comment
@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 ff6f5de into redhat-developer:master Aug 29, 2019
cdrage added a commit to cdrage/odo that referenced this pull request Sep 3, 2019
- Lists all URLs even if they are undeployed or not
(redhat-developer#2034)

- Added json output for `odo project delete -o json`
(redhat-developer#2037)

- Fixed service integration test that was previously failing
(redhat-developer#2022)

- `odo push` will now only push changed files
(redhat-developer#2030)
- We now use relative paths within the file indexer
(redhat-developer#2003)
- You can now create list and edit services using --app and --project
(redhat-developer#2001)
- Deleted files will now propagate to the OpenShift container
(redhat-developer#1999)
- Added `odo service create --context` functionality
(redhat-developer#1997)
- Making cross-compile independant of gox vendor package
(redhat-developer#2047)
- `odo-supervisord-image` has been renamed to `odo-init-image`
(redhat-developer#2027)
- Releases now use .tar.gz (redhat-developer#2009)
- If there is an error creating a service, it will fail quicker
(redhat-developer#2008)

- We now have a Google Group!
(redhat-developer#2007)
- Added documentation on how to manage environment
variables(redhat-developer#2026)
- Badges added to the README
(redhat-developer#2060)
- Updated documentation on uninstallation
(redhat-developer#2053)
- Added documentation for default parameters
(redhat-developer#2038)
- Minor update to help output
(redhat-developer#2006)
- Updated documentation regarding bootstrapper image
(redhat-developer#1991)
@cdrage cdrage mentioned this pull request Sep 3, 2019
openshift-merge-robot pushed a commit that referenced this pull request Sep 3, 2019
- Lists all URLs even if they are undeployed or not
(#2034)

- Added json output for `odo project delete -o json`
(#2037)

- Fixed service integration test that was previously failing
(#2022)

- `odo push` will now only push changed files
(#2030)
- We now use relative paths within the file indexer
(#2003)
- You can now create list and edit services using --app and --project
(#2001)
- Deleted files will now propagate to the OpenShift container
(#1999)
- Added `odo service create --context` functionality
(#1997)
- Making cross-compile independant of gox vendor package
(#2047)
- `odo-supervisord-image` has been renamed to `odo-init-image`
(#2027)
- Releases now use .tar.gz (#2009)
- If there is an error creating a service, it will fail quicker
(#2008)

- We now have a Google Group!
(#2007)
- Added documentation on how to manage environment
variables(#2026)
- Badges added to the README
(#2060)
- Updated documentation on uninstallation
(#2053)
- Added documentation for default parameters
(#2038)
- Minor update to help output
(#2006)
- Updated documentation regarding bootstrapper image
(#1991)
@dharmit dharmit deleted the fix-1872 branch September 10, 2019 05:57
@rm3l rm3l added the estimated-size/M (10-20) Rough sizing for Epics. About 1 sprint of work for one person label Jun 18, 2023
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. estimated-size/M (10-20) Rough sizing for Epics. About 1 sprint of work for one person 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.

Missing context flag in service create command
8 participants