Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EQC model failed #2141

Open
Licenser opened this issue Dec 19, 2022 · 5 comments
Open

EQC model failed #2141

Licenser opened this issue Dec 19, 2022 · 5 comments
Labels
bug Something isn't working

Comments

@Licenser
Copy link
Member

Problem
EQC model failed:

[{model,test_eqc},
 {set,{var,1},{call,test_eqc,let_local,[[],<<"bedebcc">>,{int,1}]}},
 {set,{var,2},
      {call,test_eqc,expr,
            [[{'let',{local,<<"bedebcc">>},1}],
             {array,[{patch,{record,#{<<"Bg==">> => {local,<<"bedebcc">>}}},
                            [{merge,{record,#{<<"Bg==">> => 2}}}]}]}]}}]

test_eqc:let_local([], <<"bedebcc">>, {int, 1}) -> #{<<"emit">> => 1}
test_eqc:expr([{'let', {local, <<"bedebcc">>}, 1}],
    {array,
       [{patch, {record, #{<<"Bg==">> => {local, <<"bedebcc">>}}},
           [{merge, {record, #{<<"Bg==">> => 2}}}]}]}) ->
  #{<<"emit">> => [#{<<"Bg==">> => 2}]}

Reason:
  Post-condition failed:
  {{model, #{<<"emit">> => [#{<<"Bg==">> => 1}]}}, '!=', {rust, #{<<"emit">> => [#{<<"Bg==">> => 2}]}}}
@Licenser Licenser added the bug Something isn't working label Dec 19, 2022
@rushi-12320
Copy link

what is the exact problem

@Licenser
Copy link
Member Author

Licenser commented Jan 3, 2023

The problem is a bug in the model, the expression tested is:

let bedebcc = 1;
patch {"Bg==": bedebcc} of
   merge => {"Bg==": 2}
end

which in the rest version correctly evaluates to:

{"Bg==": 2}

but in the model; evaluates to:

{"Bg==": 1}

So to clarify this is a bug in the test not a bug in the code

@rushi-12320
Copy link

which technology or language is used in this bug

@Licenser
Copy link
Member Author

Licenser commented Jan 6, 2023

Mostly Erlang, @me-diru could probably give some details.

@me-diru
Copy link
Contributor

me-diru commented Jan 7, 2023

Yes, @rushi-12320. The technology used for testing is called EQC or Erlang QuickCheck. It is used here specifically to test the model aka specification of the scripting language called Script/TremorScript (Which is written in Rust but is inspired from Erlang). The one metioned in the above comment i.e

patch {"Bg==": bedebcc} of
   merge => {"Bg==": 2}
end 

is called patch and the documentation can be found here I am not wrong: https://www.tremor.rs/docs/0.12/language/expressions#patch

The tests here generate randomised test cases with respect to the model and check with the Rust version of the same expression to measure it's correctness and if it is working as intended.

In this bug specifically, the Rust version evaluates the expression properly and gives as the desired result

{"Bg==": 2}

But the Script/Model output is not right

{"Bg==": 1}

I highly recommend reading the following blog to understand more about this type of testing and the approach used here.

Do let us know if you have more questions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants