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

Update integration tests for gRPC APIs #2488

Merged
merged 3 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,7 @@ func createRoutes(params *routeCreateParams) (routes []*routev3.Route, err error
temp := removeFirstOccurrence(basePath, "."+version)
newRoutePath = "/" + strings.TrimPrefix(resourcePath, temp+".")
}
action.Route.RegexRewrite = generateRegexMatchAndSubstitute(rewritePath, newRoutePath, pathMatchType)
// action.Route.RegexRewrite = generateRegexMatchAndSubstitute(rewritePath, newRoutePath, pathMatchType)
}
route := generateRouteConfig(xWso2Basepath, match, action, nil, metaData, decorator, perRouteFilterConfigs,
nil, requestHeadersToRemove, nil, nil) // general headers to add and remove are included in this methods
Expand Down
2 changes: 0 additions & 2 deletions adapter/internal/operator/controllers/dp/api_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import (
"strings"
"sync"

"github.com/sirupsen/logrus"
"github.com/wso2/apk/adapter/config"
"github.com/wso2/apk/adapter/internal/controlplane"
"github.com/wso2/apk/adapter/internal/discovery/xds"
Expand Down Expand Up @@ -1517,7 +1516,6 @@ func (apiReconciler *APIReconciler) getAPIForGRPCRoute(ctx context.Context, obj
}

apiList := &dpv1alpha3.APIList{}
logrus.Info("=============GETTING API FOR GRPC ROUTE================")

if err := apiReconciler.client.List(ctx, apiList, &k8client.ListOptions{
FieldSelector: fields.OneTermEqualSelector(grpcRouteAPIIndex, utils.NamespacedName(grpcRoute).String()),
Expand Down
18 changes: 4 additions & 14 deletions test/cucumber-tests/CRs/artifacts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1740,7 +1740,7 @@ spec:
ports:
- protocol: TCP
port: 6565
targetPort: 6565
targetPort: 9090
---
apiVersion: apps/v1
kind: Deployment
Expand All @@ -1761,20 +1761,10 @@ spec:
spec:
containers:
- name: grpc-backend
image: ddh13/dineth-grpc-demo-server:1.0.0
image: sega1234/student-service:1.0.0
imagePullPolicy: Always
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
resources:
requests:
cpu: 10m
ports:
- containerPort: 9090
---

apiVersion: dp.wso2.com/v1alpha3
Expand Down
2 changes: 2 additions & 0 deletions test/cucumber-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ dependencies {
implementation 'io.grpc:grpc-netty-shaded:1.57.0'
implementation 'io.grpc:grpc-protobuf:1.57.0'
implementation 'io.grpc:grpc-stub:1.57.0'
implementation 'io.grpc:grpc-stub:1.57.0'
implementation 'com.google.protobuf:protobuf-java:4.28.2'
}

test {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,10 @@
import org.wso2.apk.integration.utils.Utils;
import org.wso2.apk.integration.utils.clients.SimpleGRPCStudentClient;
import org.wso2.apk.integration.utils.clients.SimpleHTTPClient;
import org.wso2.apk.integration.utils.clients.studentGrpcClient.StudentResponse;
import org.wso2.apk.integration.utils.clients.student_service.StudentResponse;
import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.ContentType;
import org.wso2.apk.integration.utils.clients.studentGrpcClient.StudentResponse;
import org.wso2.apk.integration.utils.clients.SimpleGRPCStudentClient;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -196,7 +195,29 @@ public void theStudentResponseBodyShouldContainNameAndAge(String arg0, int arg1)

@Then("the response body should contain endpoint definition for student.proto")
public void theResponseBodyShouldContainEndpointDefinition() throws IOException {
String expectedText = "{\"apiDefinition\":\"syntax = \\\"proto3\\\";\\n\\noption java_multiple_files = true;\\noption java_package = \\\"org.example\\\";\\npackage dineth.grpc.api.v1.student;\\n\\nservice StudentService {\\n rpc GetStudent(StudentRequest) returns (StudentResponse) {};\\n rpc GetStudentStream(StudentRequest) returns (stream StudentResponse) {};\\n rpc SendStudentStream(stream StudentRequest) returns (StudentResponse) {};\\n rpc SendAndGetStudentStream(stream StudentRequest) returns (stream StudentResponse) {}\\n}\\n\\nmessage StudentRequest {\\n int32 id = 3;\\n}\\n\\nmessage StudentResponse {\\n string name = 1;\\n int32 age = 2;\\n}\\n\"}";
String expectedText = "{\"apiDefinition\":\"syntax = \\\"proto3\\\";\\n" + //
"\\n" + //
"package org.apk.v1.student_service;\\n" + //
"\\n" + //
"option java_multiple_files = true;\\n" + //
"option java_package = \\\"org.apk.v1.student_service\\\";\\n" + //
"\\n" + //
"service StudentService {\\n" + //
" rpc GetStudent(StudentRequest) returns (StudentResponse) {};\\n" + //
" rpc GetStudentStream(StudentRequest) returns (stream StudentResponse) {};\\n" + //
" rpc SendStudentStream(stream StudentRequest) returns (StudentResponse) {};\\n" + //
" rpc SendAndGetStudentStream(stream StudentRequest) returns (stream StudentResponse) {}\\n" + //
"}\\n" + //
"\\n" + //
"message StudentRequest {\\n" + //
" int32 id = 3;\\n" + //
"}\\n" + //
"\\n" + //
"message StudentResponse {\\n" + //
" string name = 1;\\n" + //
" int32 age = 2;\\n" + //
"}\\n" + //
"\"}";
Assert.assertTrue(sharedContext.getResponseBody().contains(expectedText),
"Actual response body: " + sharedContext.getResponseBody());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import org.apache.http.HttpResponse;
import org.wso2.apk.integration.utils.clients.SimpleHTTPClient;
import org.wso2.apk.integration.utils.clients.studentGrpcClient.StudentResponse;
import org.wso2.apk.integration.utils.clients.student_service.StudentResponse;

import java.security.KeyManagementException;
import java.security.KeyStoreException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import io.grpc.ManagedChannel;
import org.wso2.apk.integration.utils.GenericClientInterceptor;
import org.wso2.apk.integration.utils.clients.studentGrpcClient.StudentRequest;
import org.wso2.apk.integration.utils.clients.studentGrpcClient.StudentResponse;
import org.wso2.apk.integration.utils.clients.studentGrpcClient.StudentServiceDefaultVersionGrpc;
import org.wso2.apk.integration.utils.clients.studentGrpcClient.StudentServiceGrpc;
import org.wso2.apk.integration.utils.clients.student_service.StudentRequest;
import org.wso2.apk.integration.utils.clients.student_service.StudentResponse;
import org.wso2.apk.integration.utils.clients.student_service.StudentServiceDefaultVersionGrpc;
import org.wso2.apk.integration.utils.clients.student_service.StudentServiceGrpc;

import javax.net.ssl.SSLException;
import java.util.Map;
Expand Down

This file was deleted.

Loading
Loading