juspay / fencer

Fencer is a port of https://github.com/lyft/ratelimit into Haskell.
https://hub.docker.com/r/juspayin/fencer
Other
9 stars 2 forks source link

Issue #26: Add a test for rule loading from a dot-directory #77

Closed mdimjasevic closed 5 years ago

mdimjasevic commented 5 years ago

This confirms that "Would it look at .foo/bar.yaml if RUNTIME_IGNOREDOTFILES is enabled?" has a positive answer. Ratelimit does the same.

neongreen commented 5 years ago

How did you test lyft/ratelimits behavior? I tested it too and it seems to ignore dot-directories:

$ tree -a examples

examples
├── root -> root2
└── root2
    └── ratelimit
        └── config
            └── .blah
                └── config.yaml
$ RUNTIME_IGNOREDOTFILES=false \
  RUNTIME_ROOT=examples/root \
  RUNTIME_SUBDIRECTORY=ratelimit \
  LOG_LEVEL=DEBUG \
  bin/ratelimit

DEBU[0000] runtime changed. loading new snapshot at examples/root/ratelimit
DEBU[0000] runtime: processing examples/root/ratelimit
DEBU[0000] runtime: processing examples/root/ratelimit/config
DEBU[0000] runtime: processing examples/root/ratelimit/config/.blah
DEBU[0000] runtime: processing examples/root/ratelimit/config/.blah/config.yaml
DEBU[0000] runtime: adding key=config..blah.config.yaml value=---
domain: mongo_cps2
descriptors:
  - key: database
    value: default
    rate_limit:
      unit: hour
      requests_per_unit: 4
 uint=false
WARN[0000] connecting to redis on unix /var/run/nutcracker/ratelimit.sock with pool size 10
$ RUNTIME_IGNOREDOTFILES=true \
  RUNTIME_ROOT=examples/root \
  RUNTIME_SUBDIRECTORY=ratelimit \
  LOG_LEVEL=DEBUG \
  bin/ratelimit

DEBU[0000] runtime changed. loading new snapshot at examples/root/ratelimit
DEBU[0000] runtime: processing examples/root/ratelimit
DEBU[0000] runtime: processing examples/root/ratelimit/config
DEBU[0000] runtime: processing examples/root/ratelimit/config/.blah
WARN[0000] connecting to redis on unix /var/run/nutcracker/ratelimit.sock with pool size 10
mdimjasevic commented 5 years ago

How did you test lyft/ratelimits behavior? I tested it too and it seems to ignore dot-directories:

I guess I had an example where the top-level directory given by the RUNTIME_ROOT environment variable had a name starting with a dot, which lyft/ratelimit happily loads rules from regardless of the RUNTIME_IGNOREDOTFILES flag.

Ok, I'll update this PR per your observation.

mdimjasevic commented 5 years ago

@neongreen , at least one other PR of mine depends on this one so it'd be great if you can take a look again.

neongreen commented 5 years ago

In case you're waiting on me – this can be merged.