Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-37042

Eventing CLI tools (cURL and couchbase-cli) should be able import Functions exported by the other tool

    XMLWordPrintable

Details

    Description

      As alluded to MB-37040 all modes of exporting a function UI, cURL and couchbase-cli should be cross compatible.

      In other words an export via the on of the following UI, cURL or couchbase-cli  should be able to be imported by any of  the other two other methods.

      Given a function/handler for Eventing Function/Handler named "once_daily" it could be any Function - we then export the function 3 ways to three different files

      1. UI button to "once_daily.ui.export.json"
       
      Use the UI's export button in the Eventing tab and rename this file to once_daily.ui.export.json
       
      2. CURL CLI method to "once_daily.curl.export.json"
       
      curl -X GET  -s http://${CB_USERNAME}:${CB_PASSWORD}@localhost:8096/api/v1/functions/once_daily --output once_daily.curl.export.json
       
      3. couchbase-cli CLI method to "once_daily.couchbase-cli.export.json"
       
      couchbase-cli eventing-function-setup -c localhost -u $CB_USERNAME -p $CB_PASSWORD --export --name once_daily --file once_daily.couchbase-cli.export.json
      

      Here we see that the UI and the cURL exports are identical

      	# ls -ltr *.json
      	-rw-r--r--@ 1 jon.strabala  staff  5565 Nov 23 13:19 once_daily.ui.export.json
      	-rw-r--r--  1 jon.strabala  staff  5565 Nov 23 13:36 once_daily.couchbase-cli.export.json
      	-rw-r--r--  1 jon.strabala  staff  5814 Nov 23 16:22 once_daily.curl.export.json
      	# sum *.json
      	25681 6 once_daily.couchbase-cli.export.json
      	21396 6 once_daily.curl.export.json
      	25681 6 once_daily.ui.export.json
      	# diff once_daily.couchbase-cli.export.json once_daily.couchbase-cli.export.json
      	# 
      

      So we see two unique formats #1 (the UI and couchbase-cli format) and #2 (the cURL format).

      Now lets try a 'cross import' via the UI, cURL, and couchbase-cli

      1. The UI seems to work for both variants, e.g. it can import any of the files we just made.
       
              Use the UI's import button in the Eventing tab across all three files (and delete)
       
      	  once_daily.couchbase-cli.export.json 
      	  once_daily.ui.export.json
      	  once_daily.curl.export.json 
       
      2. CURL CLI try to "cross load" either once_daily.couchbase-cli.export.json or once_daily.ui.export.jso
       
      	curl -s -X POST -d @./once_daily.couchbase-cli.export.json  -s http://${CB_USERNAME}:${CB_PASSWORD}@localhost:8096/api/v1/functions/once_daily
      	{
      	 "name": "ERR_UNMARSHAL_PLD",
      	 "code": 16,
      	 "description": "Unable to unmarshal payload",
      	 "attributes": null,
      	 "runtime_info": {
      	  "code": 16,
      	  "info": "Failed to unmarshal payload err: json: cannot unmarshal array into Go value of type servicemanager.application"
      	 }
      	}
       
      3. couchbase-cli CLI try to "cross load" once_daily.curl.export.json
       
      	couchbase-cli eventing-function-setup -c localhost -u $CB_USERNAME -p $CB_PASSWORD --import --name verifier_01w_inst01 --file once_daily.curl.export.json
      	ERROR: name - ERR_UNMARSHAL_PLD
      	ERROR: code - 16
      	ERROR: description - Unable to unmarshal payload
      	ERROR: attributes - None
      	ERROR: runtime_info - {'code': 16, 'info': 'Failed to unmarshal payload err: json: cannot unmarshal object into Go value of type []servicemanager.application'}
      

      Summary

      The UI seems capable of importing either format (all exported files), however the CLI tools cURL and couchbase-cli can not "cross load" the other format.

      Attachments

        Issue Links

          Activity

            People

              ankit.prabhu Ankit Prabhu
              jon.strabala Jon Strabala
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                PagerDuty