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

add proxy handler for PUT request #543

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

siminyou
Copy link
Member

@siminyou siminyou commented Nov 7, 2024

Description

add handler for PUT request, which will be used in some trino distributions such as SEP. For instance, a PUT request is made to ui/api/insights/openWorksheets to save worksheets

Additional context and related issues

Release notes

(x) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
( ) Release notes are required, with the following suggested text:

Copy link

cla-bot bot commented Nov 7, 2024

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@willmostly
Copy link
Contributor

@siminyou please add a test

Copy link

cla-bot bot commented Nov 7, 2024

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@siminyou
Copy link
Member Author

siminyou commented Nov 7, 2024

added test: TestPutRequestHandler

Copy link
Contributor

@willmostly willmostly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Please address my comment on the test then this should be good to merge, once we get your CLA figured out.

@cla-bot cla-bot bot added the cla-signed label Nov 14, 2024
Copy link
Member

@ebyhr ebyhr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please squash commits into one and capitalize the commit message. https://trino.io/development/process.html#pull-request-and-commit-guidelines-

* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.trino.gateway.ha;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to io.trino.gateway.proxyserver.

import static org.assertj.core.api.Assertions.assertThat;

@TestInstance(Lifecycle.PER_CLASS)
public class TestPutRequestHandler
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, consider renaming to TestProxyRequestHandler. A test class per HTTP method is overkill.

public class TestPutRequestHandler
{
private final OkHttpClient httpClient = new OkHttpClient();
private MockWebServer mockTrinoServer = new MockWebServer();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add final.

throws Exception
{
RequestBody requestBody =
RequestBody.create(MediaType.parse("application/json; charset=utf-8"), "SELECT 1");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix deprecation warning.

.build();

try (Response response = httpClient.newCall(putRequest).execute()) {
assertThat(response.body().string()).isEqualTo(OK);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix NPE warning.

public void cleanup()
throws Exception
{
if (mockTrinoServer != null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think mockTrinoServer is nullable.

}

@Test
public void testPutRequestHandler()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make test method package-private. https://trino.io/docs/current/develop/tests.html

Same for setup and cleanup methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants