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

[Task]: Investigate into the ballerina library level 5 failure for PR #43303 #43348

Closed
lochana-chathura opened this issue Sep 3, 2024 · 4 comments
Assignees
Labels
Area/SemtypeIntegration Issue related to integrating semtype engine Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Task userCategory/Compilation

Comments

@lochana-chathura
Copy link
Member

lochana-chathura commented Sep 3, 2024

Description

$subject.

Quoting from #43126 (comment)

Regarding the ballerina library level 5 failure.

It was observed that testInterceptableServiceInterceptors() test in CompilerPluginTest.java class only fails when the other 3 tests quoted here are enabled. When either one of them is disabled, the testInterceptableServiceInterceptors() gets passed.

    @Test
    public void testInValidQueryInfoArgs() {
        Package currentPackage = loadPackage("sample_package_8");
        PackageCompilation compilation = currentPackage.getCompilation();
        DiagnosticResult diagnosticResult = compilation.diagnosticResult();
        Assert.assertEquals(diagnosticResult.errorCount(), 9);
        assertTrue(diagnosticResult, 0, "invalid resource parameter type: 'ballerina/mime", HTTP_106);
        assertError(diagnosticResult, 1, "invalid union type of query param 'a': 'string', 'int', " +
                "'float', 'boolean', 'decimal', 'map<anydata>' type or the array types of them can only be union" +
                " with '()'. Eg: string? or int[]?", HTTP_113);
        assertError(diagnosticResult, 2, "invalid union type of query param 'b': 'string', 'int', " +
                "'float', 'boolean', 'decimal', 'map<anydata>' type or the array types of them can only be union" +
                " with '()'. Eg: string? or int[]?", HTTP_113);
        assertError(diagnosticResult, 3, "invalid union type of query param 'c': 'string', 'int', " +
                "'float', 'boolean', 'decimal', 'map<anydata>' type or the array types of them can only be union" +
                " with '()'. Eg: string? or int[]?", HTTP_113);
        assertError(diagnosticResult, 4, "invalid type of query param 'd': expected one of the " +
                "'string', 'int', 'float', 'boolean', 'decimal', 'map<anydata>' types or the array types of them",
                HTTP_112);
        assertError(diagnosticResult, 5, "invalid type of query param 'a': expected one of the " +
                "'string', 'int', 'float', 'boolean', 'decimal', 'map<anydata>' types or the array types of them",
                HTTP_112);
        assertError(diagnosticResult, 6, "invalid type of query param 'aa': expected one of the " +
                "'string', 'int', 'float', 'boolean', 'decimal', 'map<anydata>' types or the array types of them",
                HTTP_112);
        assertError(diagnosticResult, 7, "invalid type of query param 'd': expected one of the " +
                "'string', 'int', 'float', 'boolean', 'decimal', 'map<anydata>' types or the array types of them",
                HTTP_112);
        assertError(diagnosticResult, 8, "invalid type of query param 'e': expected one of the " +
                "'string', 'int', 'float', 'boolean', 'decimal', 'map<anydata>' types or the array types of them",
                HTTP_112);
    }

    @Test
    public void testCallerInfoAnnotation() {
        Package currentPackage = loadPackage("sample_package_10");
        PackageCompilation compilation = currentPackage.getCompilation();
        DiagnosticResult diagnosticResult = compilation.diagnosticResult();
        Assert.assertEquals(diagnosticResult.errorCount(), 11);
        assertError(diagnosticResult, 0, "incompatible respond method argument type : expected " +
                "'int' according to the 'http:CallerInfo' annotation", HTTP_114);
        assertError(diagnosticResult, 1, "incompatible respond method argument type : expected " +
                "'decimal' according to the 'http:CallerInfo' annotation", HTTP_114);
        assertError(diagnosticResult, 2, "incompatible respond method argument type : expected " +
                "'Person' according to the 'http:CallerInfo' annotation", HTTP_114);
        assertError(diagnosticResult, 3, "incompatible respond method argument type : expected " +
                "'string' according to the 'http:CallerInfo' annotation", HTTP_114);
        assertError(diagnosticResult, 4, "invalid multiple 'http:Caller' parameter: 'xyz'", HTTP_115);
        assertError(diagnosticResult, 5, "incompatible respond method argument type : expected " +
                "'Person' according to the 'http:CallerInfo' annotation", HTTP_114);
        assertError(diagnosticResult, 6, "incompatible respond method argument type : expected " +
                "'Person' according to the 'http:CallerInfo' annotation", HTTP_114);
        assertError(diagnosticResult, 7, "incompatible respond method argument type : expected " +
                "'Person' according to the 'http:CallerInfo' annotation", HTTP_114);
        assertError(diagnosticResult, 8, "incompatible respond method argument type : expected " +
                "'http:Error' according to the 'http:CallerInfo' annotation", HTTP_114);
        assertError(diagnosticResult, 9, "incompatible respond method argument type : expected " +
                "'http:Ok' according to the 'http:CallerInfo' annotation", HTTP_114);
        assertError(diagnosticResult, 10, "incompatible respond method argument type : expected " +
                "'http:StatusCodeResponse' according to the 'http:CallerInfo' annotation", HTTP_114);
    }

    @Test
    public void testAnnotationUsageWithReturnType() {
        Package currentPackage = loadPackage("sample_package_22");
        PackageCompilation compilation = currentPackage.getCompilation();
        DiagnosticResult diagnosticResult = compilation.diagnosticResult();
        Assert.assertEquals(diagnosticResult.errorCount(), 4);
        assertError(diagnosticResult, 0, "invalid usage of cache annotation with return type : " +
                "'error'. Cache annotation only supports return types of anydata and SuccessStatusCodeResponse",
                CompilerPluginTestConstants.HTTP_130);
        assertError(diagnosticResult, 1, "invalid usage of payload annotation with return type : " +
                "'error'", CompilerPluginTestConstants.HTTP_131);
        assertError(diagnosticResult, 2, "invalid usage of payload annotation with return type : " +
                "'error?'", CompilerPluginTestConstants.HTTP_131);
        assertError(diagnosticResult, 3, "invalid usage of cache annotation with return type : " +
                "'error?'. Cache annotation only supports return types of anydata and SuccessStatusCodeResponse",
                CompilerPluginTestConstants.HTTP_130);
    }

    @Test
    public void testInterceptableServiceInterceptors() {
        Package currentPackage = loadPackage("sample_package_39");
        PackageCompilation packageCompilation = currentPackage.getCompilation();
        DiagnosticResult diagnosticResult = packageCompilation.diagnosticResult();
        Assert.assertFalse(diagnosticResult.hasWarnings());
        Assert.assertFalse(diagnosticResult.hasErrors()); // Fails here
    }
@lochana-chathura lochana-chathura self-assigned this Sep 3, 2024
@lochana-chathura lochana-chathura added Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Area/SemtypeIntegration Issue related to integrating semtype engine labels Sep 3, 2024
@ballerina-bot ballerina-bot added needTriage The issue has to be inspected and labeled manually userCategory/Compilation labels Sep 3, 2024
@lochana-chathura lochana-chathura removed the needTriage The issue has to be inspected and labeled manually label Sep 3, 2024
@lochana-chathura
Copy link
Member Author

Since the test failure depends on the other test cases, suspicion is, this is happening due to shared semtype context/env among the test cases. Ideally we need to have a separate environment for each test case.

@lochana-chathura
Copy link
Member Author

Problem seems to be with the distinctIdSupplier.

  • source: ballerina/http:2.12.1:InterceptableService
    typeIds: [BTypeId { ballerina/http:2.12.1/InterceptableService}, BTypeId { ballerina/http:2.12.1/Service}]
    distinctIdSupplier: 2, 13

  • target: ballerina/http:2.12.1:ServiceContract
    typeIds:[BTypeId { ballerina/http:2.12.1/ServiceContract}, BTypeId { ballerina/http:2.12.1/Service}]
    distinctIdSupplier: 2, 13

In the multiple tests running case, both the types will have the same DISTINCT_ATOM indexes where as in the single test runcase they have different indexes. So in the former case, two types evaluates to be subtypes.

@lochana-chathura
Copy link
Member Author

As you can see both { ballerina/http:2.12.1/InterceptableService} and { ballerina/http:2.12.1/ServiceContract} have the same Id. This is because allocatedIds are shared across multiple tests in this class.

Screenshot 2024-09-03 at 19 24 30

lochana-chathura added a commit to lochana-chathura/ballerina-lang that referenced this issue Sep 3, 2024
lochana-chathura added a commit to lochana-chathura/ballerina-lang that referenced this issue Sep 3, 2024
@lochana-chathura lochana-chathura moved this from In Progress to PR Sent in Ballerina Team Main Board Sep 4, 2024
lochana-chathura added a commit to lochana-chathura/ballerina-lang that referenced this issue Sep 6, 2024
@lochana-chathura
Copy link
Member Author

Fixed in #43303.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area/SemtypeIntegration Issue related to integrating semtype engine Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Task userCategory/Compilation
Projects
Archived in project
Development

No branches or pull requests

2 participants