mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-12 19:32:48 -06:00
Deterministic order of rules for optimized bundles
Before this fix, an optimized bundle would get non-deterministic order of the support rules. One example use case where it is necessary for the optimized bundle to be deterministic is when a hash of the bundle is used for version tag. Fixes: #3453 Signed-off-by: Andre Håland <andre.haland@gmail.com>
This commit is contained in:
committed by
Torin Sandall
parent
ee115dba41
commit
4b5f53b548
@@ -350,9 +350,9 @@ func TestCompilerOptimizationL1(t *testing.T) {
|
||||
optimizedExp := ast.MustParseModule(`
|
||||
package test
|
||||
|
||||
q { input.x = 1 }
|
||||
p { data.test.q = X; X }
|
||||
default p = false
|
||||
p { data.test.q = X; X }
|
||||
q { input.x = 1 }
|
||||
`)
|
||||
|
||||
// NOTE(tsandall): PE generates vars with wildcard prefix. Instead of
|
||||
@@ -409,8 +409,8 @@ func TestCompilerOptimizationL2(t *testing.T) {
|
||||
optimizedExp := ast.MustParseModule(`
|
||||
package test
|
||||
|
||||
p { input.x = 1 }
|
||||
default p = false
|
||||
p { input.x = 1 }
|
||||
`)
|
||||
|
||||
if len(compiler.bundle.Modules) != 2 {
|
||||
@@ -872,10 +872,11 @@ func TestOptimizerOutput(t *testing.T) {
|
||||
"optimized/test.rego": `
|
||||
package test
|
||||
|
||||
default p = false
|
||||
|
||||
p = true { 1 = input.x }
|
||||
p = true { 2 = input.x }
|
||||
|
||||
default p = false
|
||||
`,
|
||||
"test.rego": `
|
||||
package test
|
||||
|
||||
Reference in New Issue
Block a user