Skip to content
5 changes: 5 additions & 0 deletions examples/counter/f.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
counter = 0
def f(event):
global counter
counter += 1
return counter
5 changes: 5 additions & 0 deletions examples/counter/ol.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
triggers:
http:
- method: POST

reuse-sandbox: false
12 changes: 12 additions & 0 deletions scripts/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,15 @@ def max_mem_alloc():
# the function returns the MB that was able to be allocated
assert limit-16 <= int(result) <= limit

@test
def fresh_sandbox_test():
open_lambda = OpenLambda()

num_calls = 2
for _ in range(num_calls):
result = open_lambda.run("counter", {})
assert_eq(result, 1) # fresh sandbox each call, counter always resets to 0 and increments to 1

@test
def ping_test():
open_lambda = OpenLambda()
Expand Down Expand Up @@ -485,6 +494,9 @@ def run_tests():
fork_bomb()
max_mem_alloc()

# test sandbox-reuse flag behavior
fresh_sandbox_test()

# numpy pip install needs a larger memory cap.
# numpy also spawns threads using OpenBLAS, so a higher
# process limit is needed.
Expand Down
Loading