testinggospels / camouflage

Camouflage is a backend mocking tool for HTTP, gRPC, Websockets and Thrift protocols, which helps you carry out your front end prototyping, unit testing, functional/performance testing in silos, in absence of one or more Microservices/APIs.
https://testinggospels.github.io/camouflage/
MIT License
270 stars 26 forks source link

startup fails with backup error; backup.enable config ignored #74

Closed ctoomey closed 2 years ago

ctoomey commented 3 years ago

Describe the bug With the default configuration (backup.enable: true), the server fails with this error at startup:

2021-07-26 13:43:05 debug: Creating a new back up. 
/usr/local/lib/node_modules/camouflage-server/node_modules/fs-extra/lib/util/stat.js:51
    throw new Error('Source and destination must not be the same.')
    ^

Error: Source and destination must not be the same.
    at Object.checkPathsSync (/usr/local/lib/node_modules/camouflage-server/node_modules/fs-extra/lib/util/stat.js:51:11)
    at copyDirItem (/usr/local/lib/node_modules/camouflage-server/node_modules/fs-extra/lib/copy-sync/copy-sync.js:121:29)
    at /usr/local/lib/node_modules/camouflage-server/node_modules/fs-extra/lib/copy-sync/copy-sync.js:115:39
    at Array.forEach (<anonymous>)
    at copyDir (/usr/local/lib/node_modules/camouflage-server/node_modules/fs-extra/lib/copy-sync/copy-sync.js:115:23)
    at onDir (/usr/local/lib/node_modules/camouflage-server/node_modules/fs-extra/lib/copy-sync/copy-sync.js:105:10)
    at getStats (/usr/local/lib/node_modules/camouflage-server/node_modules/fs-extra/lib/copy-sync/copy-sync.js:45:37)
    at startCopy (/usr/local/lib/node_modules/camouflage-server/node_modules/fs-extra/lib/copy-sync/copy-sync.js:38:10)
    at handleFilterAndCopy (/usr/local/lib/node_modules/camouflage-server/node_modules/fs-extra/lib/copy-sync/copy-sync.js:33:10)
    at Object.copySync (/usr/local/lib/node_modules/camouflage-server/node_modules/fs-extra/lib/copy-sync/copy-sync.js:26:10)
2021-07-26 13:43:05 warn: [42197] Worker Stopped Mon Jul 26 2021 13:43:05 GMT-0700 (Pacific Daylight Time) 

Since there's some problem w/ the backup implementation, I tried to disable backups by setting backup.enable: false in my config.yaml, but surprisingly still got the same startup error, indicating the backup enable config. was ignored.

To Reproduce Steps to reproduce the behavior:

  1. Add any new .proto file to grpc/protos. In my case I added the one given in #73 .
  2. Start the server: camoflauge --config config.yml

Expected behavior

  1. Backup should not fail when enabled
  2. Configuring backup.enable: false should disable backup

Desktop (please complete the following information):

Additional context Here's a patch to camouflage-server/bin/camoflauge.js to stop ignoring the backup.enable config:

207c207
<   config.backup.enable || true,
---
>   config.backup.enable,
ctoomey commented 3 years ago

@shubhendumadhukar thanks for fixing the config. part of this. There's still the other part though -- when I have backup enabled, I get the startup error shown at the top of the ticket -- apparently it's attempting to copy a file on top of itself.

shubhendumadhukar commented 3 years ago

My apologies.

This should not happen since backup functionality copies the necessary folders to a new folder under $HOME/.camouflage_backup. But I do see an issue on fs-extra project with similar issue.

Could you please let me know the node version you are on and absolute path of your grpc/mocks directory? (Please strip sensitive data if any)

ctoomey commented 3 years ago

Could you please let me know the node version you are on and absolute path of your grpc/mocks directory? (Please strip sensitive data if any)

Sorry had overlooked this request. Using node v16.5.0. The base directory containing everything where I ran camouflage init is /Users/christoomey/unix/dev/camouflageGrpcMock which contains grpc/mocks. In config.yml I've left the default setting

protocols:
...
  grpc:
...
    mocks_dir: "./grpc/mocks"
...
github-actions[bot] commented 2 years ago

Stale issue message