-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Grow memory on demand in FastEvaluate
- Loading branch information
1 parent
4a166ea
commit 1ee7db9
Showing
8 changed files
with
88 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package memorytest | ||
|
||
import rego.v1 | ||
|
||
default allow := false | ||
|
||
allow if { input == "open sesame" } |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using NUnit.Framework; | ||
|
||
namespace Opa.Wasm.UnitTests | ||
{ | ||
public class MemoryTests | ||
{ | ||
[Test] | ||
public void parsing_input_exceeds_memory() | ||
{ | ||
using var module = OpaPolicyModule.Load(WasmFiles.MemoryTestExample); | ||
using var opaPolicy = module.CreatePolicyInstance(3, 4); | ||
|
||
string input = new | ||
{ | ||
input = new string('a', 2 * 65536) | ||
}.ToJson(); | ||
|
||
Wasmtime.WasmtimeException ex = Assert.Throws<Wasmtime.WasmtimeException>( | ||
() => | ||
{ | ||
string outputJson = opaPolicy.EvaluateJson(input); | ||
}); | ||
|
||
Assert.That(ex.InnerException.Message, Does.StartWith("opa_malloc: failed")); | ||
} | ||
|
||
[Test] | ||
public void large_input_host_and_guest_grow_successfully() | ||
{ | ||
using var module = OpaPolicyModule.Load(WasmFiles.MemoryTestExample); | ||
using var opaPolicy = module.CreatePolicyInstance(2, 8); | ||
|
||
string input = new | ||
{ | ||
input = new string('a', 2 * 65536) | ||
}.ToJson(); | ||
|
||
string outputJson = opaPolicy.EvaluateJson(input); | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters