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

GRPC - cannot simulate gRPC error status, false positive mock response #188

Open
szokebarnabas opened this issue Sep 2, 2022 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@szokebarnabas
Copy link

szokebarnabas commented Sep 2, 2022

Describe the bug
Hi, apologies in advance if the answer to my question is trivial but I don't have any experience with gRpc and protobufs.

What I would like to achieve is:

To Reproduce
Steps to reproduce the behavior:

  1. Mock File Content
https://github.com/stargate/stargate/tree/master/grpc-proto/proto
  1. File structure:

mocks:

./mocks/stargate/Stargate/ExecuteBatch.mock

protos:

./protos/query.proto
./protos/stargate.proto
  1. Docker-compose:
version: "3.9"
networks:
  camouflage:
    driver: bridge

volumes:
  prometheus_data: {}
  grafana_data: {}
  camouflage_data: {}

services:
  camouflage_ui:
    image: shubhendumadhukar/camouflage-filemanager:latest
    container_name: camouflage_ui_2
    volumes:
      - camouflage_data:/opt/virtual_services
    environment:
      FS_ROOT: /opt/virtual_services
      WRITE_PROTECTED: "false"
      PORT: 3001
    ports:
      - "3001:3001"
    labels:
      org.label-schema.group: "camouflage"

  camouflage:
    image: shubhendumadhukar/camouflage:latest
    container_name: camouflage_2
    volumes:
       - ./protos:/app/grpc/protos
       - ./mocks:/app/grpc/mocks
       - ./config/config.yml:/app/config.yml
       - ./config/.protoignore:/app/.protoignore
    restart: unless-stopped
    ports:
      - "8080:8080"
      - "8443:8443"
      - "8081:8081"
      - "4312:4312"
      - "8082:8082"
      - "5555:5555"
    networks:
      - camouflage
    labels:
      org.label-schema.group: "camouflage"

  1. ExecuteBatch.mock:
{
  "warnings": [
    "hello"
  ],
  "schema_change": {
    "change_type": "CREATED"
  },
  "result_set": {
    "columns": [
      {
        "name": "my column",
        "type": {
          "basic": "ASCII"
        }
      }
    ],
    "rows": [
      {
        "values": [
          {
            "string": "hello world"
          }
        ]
      }
    ]
  }
}
  1. Execute the following gRpc request:
grpcurl -v -d '{"queries":[{"cql":"UPDATE bookmarking.bookmarks USING TTL :ttl AND TIMESTAMP :timestamp SET streamPosition = :streamposition, created = :created WHERE pvid = :pvid AND providerterritory = :providerterritory AND provider = :provider AND householdId = :householdid AND timeBucket = :timebucket and personaId = :personaid;"}]}' -proto query.proto -proto stargate.proto -plaintext localhost:4312 stargate.Stargate/ExecuteBatch

Response:

Resolved method descriptor:
// Executes a batch of CQL queries.
rpc ExecuteBatch ( .stargate.Batch ) returns ( .stargate.Response );

Request metadata to send:
(empty)

Response headers received:
content-type: application/grpc+proto
date: Fri, 02 Sep 2022 07:38:52 GMT
grpc-accept-encoding: identity,deflate,gzip

Response contents:
{
  "warnings": [
    "hello"
  ],
  "schemaChange": {
    "changeType": "DROPPED"
  }
}

Response trailers received:
(empty)
Sent 1 request and received 1 response

Expected behavior
It's should be possible to define request matchers and return responses accordingly.

Thanks,
Barnabas

@szokebarnabas szokebarnabas added the bug Something isn't working label Sep 2, 2022
@shubhendumadhukar
Copy link
Contributor

Hi @szokebarnabas,

It's should be possible to define request matchers and return responses accordingly.

Could you please elaborate with an example, what kind of request matchers are you referring to?

@scvnc
Copy link

scvnc commented Oct 3, 2022

I'm unsure if this is a bug or if this isn't documented or supported.

Take HTTP: Camouflage mocks HTTP by having you provide the entire HTTP response in your *.mock file, including status code headers, etc. This would allow me to test scenarios like when the server responds with a HTTP 400, then I can verify my app behaves accordingly.

Similarly in gRPC we have status codes and I may want to do the same thing where I configure camouflage to return GRPC 16 "Unauthorized" so that I can verify my app behaves accordingly when such a thing happens. I don't see it documented.

Since I'm proxying with envoy to camouflage, I also would like to set headers but I know I may be asking for too much there.

shubhendumadhukar added a commit that referenced this issue Nov 22, 2022
* fix: lazy loading the validation modules #203 (#206)
* feat: state helper (#207)
* feat: cookie support for the capture helper (#209)
* implement basic error response and metadata. #188
* docs: grpc documentation
* fix: race condition with lazy loading of the validation adapters (#210)
richardruiter pushed a commit to richardruiter/camouflage that referenced this issue Nov 28, 2022
* fix: lazy loading the validation modules testinggospels#203 (testinggospels#206)
* feat: state helper (testinggospels#207)
* feat: cookie support for the capture helper (testinggospels#209)
* implement basic error response and metadata. testinggospels#188
* docs: grpc documentation
* fix: race condition with lazy loading of the validation adapters (testinggospels#210)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Development

No branches or pull requests

3 participants