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

[Bug]: C2C plugin throws an error during bal test when flag to generate k8s artifacts is enabled #7621

Open
Dilhasha opened this issue Feb 21, 2025 · 1 comment · May be fixed by ballerina-platform/module-ballerina-c2c#834

Comments

@Dilhasha
Copy link

Description

C2C plugin throws an error message and discontinues test execution when flag to generate k8s artifacts is enabled during bal test for 2201.10.x and higher versions. We must maintain the earlier behavior for the code to cloud artifact generation for k8s. The fix needs to be added to the C2C plugin.

Steps to Reproduce

  • Create a ballerina package with an http service
import ballerina/http;

listener http:Listener httpListener = new (8080);
service / on httpListener {
    resource function get greeting() returns string { 
        return "Hello, World!"; 
    }
}

Add tests to the tests directory of the package as follows.

import ballerina/test;
import ballerina/http;


http:Client helloClient = check new("http://localhost:8080");
@test:Config
function testMain() {
    string|error response = helloClient->get("/greeting");
    if response is error {
        test:assertFail("Error occurred: " + response.message());
    }
    // Test the main function
    test:assertEquals("Hello, World!", response);
}

Add the C2C functionality in the Ballerina.toml.

[build-options]
cloud = "k8s"

Add a Cloud.toml with the below content.

[container.image]
repository="wso2inc" # Docker hub repository name.
name="greetings" # container name
tag="latest"

Then do bal test with 2201.9.x version.

The test gets executed without any complaints.

Repeat after switching to 2201.10.x or higher version. This gives an error as follows.

error [k8s plugin]: k8s cloud build only supported for build
Feb 21, 2025 5:21:24 AM io.ballerina.c2c.tasks.C2CCodeGeneratedTask perform
SEVERE: k8s cloud build only supported for build

Affected Version(s)

2201.10.0 onwards

OS, DB, other environment details and versions

No response

Related area

-> Other Area

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

@Dilhasha
Copy link
Author

Workaround:

To avoid this error during bal test, comment out the cloud build option as follows.

[build-options]
# cloud = "k8s"

@Dilhasha Dilhasha transferred this issue from ballerina-platform/ballerina-lang Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants