Skip to content

Commit

Permalink
Merge pull request #346 from fastly/jake/erl-test
Browse files Browse the repository at this point in the history
⏫ Bump up the Fastly SDK to latest version and uncomment the test for the Edge Rate Limiting API
  • Loading branch information
Jake Champion authored Feb 23, 2024
2 parents 10f3d45 + ba4473e commit cf68271
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 30 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ bytesize = "^1.1.0"
cfg-if = "^1.0"
clap = { workspace = true }
cranelift-entity = "^0.88.1"
fastly-shared = "^0.9.3"
fastly-shared = "^0.9.11"
flate2 = "^1.0.24"
futures = { workspace = true }
http = "^0.2.8"
Expand Down
6 changes: 3 additions & 3 deletions test-fixtures/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ publish = false

[dependencies]
base64 = "0.21.2"
fastly = "^0.9.7"
fastly-shared = "^0.9.7"
fastly-sys = "^0.9.8"
fastly = "0.9.11"
fastly-shared = "0.9.11"
fastly-sys = "0.9.11"
bytes = "1.0.0"
http = "0.2.9"
rustls-pemfile = "1.0.3"
Expand Down
40 changes: 20 additions & 20 deletions test-fixtures/src/bin/edge-rate-limiting.rs
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
//! A guest program to test that edge-rate-limiting API is implemented.

//use std::time::Duration;
use std::time::Duration;

//use fastly::erl::{CounterDuration, Penaltybox, RateCounter, RateWindow, ERL};
use fastly::erl::{CounterDuration, Penaltybox, RateCounter, RateWindow, ERL};

fn main() {
// let entry = "entry";
let entry = "entry";

// let rc = RateCounter::open("rc");
// let pb = Penaltybox::open("pb");
// let erl = ERL::open(rc, pb);
let rc = RateCounter::open("rc");
let pb = Penaltybox::open("pb");
let erl = ERL::open(rc, pb);

// let not_blocked = erl
// .check_rate(entry, 1, RateWindow::TenSecs, 100, Duration::from_secs(300))
// .unwrap();
// assert_eq!(not_blocked, false);
let not_blocked = erl
.check_rate(entry, 1, RateWindow::TenSecs, 100, Duration::from_secs(300))
.unwrap();
assert_eq!(not_blocked, false);

// let rc2 = RateCounter::open("rc");
// let rate_1 = rc2.lookup_rate(entry, RateWindow::OneSec).unwrap();
// assert_eq!(rate_1, 0);
let rc2 = RateCounter::open("rc");
let rate_1 = rc2.lookup_rate(entry, RateWindow::OneSec).unwrap();
assert_eq!(rate_1, 0);

// let count10 = rc2.lookup_count(entry, CounterDuration::TenSec).unwrap();
// assert_eq!(count10, 0);
let count10 = rc2.lookup_count(entry, CounterDuration::TenSec).unwrap();
assert_eq!(count10, 0);

// assert!(rc2.increment(entry, 600).is_ok());
assert!(rc2.increment(entry, 600).is_ok());

// let pb2 = Penaltybox::open("pb");
// let not_in_pb = pb2.has(entry).unwrap();
// assert_eq!(not_in_pb, false);
let pb2 = Penaltybox::open("pb");
let not_in_pb = pb2.has(entry).unwrap();
assert_eq!(not_in_pb, false);

// assert!(pb2.add(entry, Duration::from_secs(300)).is_ok());
assert!(pb2.add(entry, Duration::from_secs(300)).is_ok());
}

0 comments on commit cf68271

Please sign in to comment.