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

wip: ODS-xxxx expose dashboard 8080 and curl to it #52

Closed
wants to merge 1 commit into from

Conversation

jiridanek
Copy link
Collaborator

@jiridanek jiridanek commented Jan 10, 2024

Step Expected Result
Expose additional port for RHODS Dashboard:

oc patch -n redhat-ods-applications service rhods-dashboard -p '{"spec": {"ports": [{"name": "8443-tcp", "protocol": "TCP", "port": 8443, "targetPort": 8443}]}}'

oc patch -n redhat-ods-applications service rhods-dashboard -p '{"spec": {"ports": [{"name": "8080-tcp", "protocol": "TCP", "port": 8080, "targetPort": 8080}]}}'

We can see the service conf with this command:
oc get -n redhat-ods-applications service rhods-dashboard -o json
Expose additional route for RHODS Dashboard

oc apply -f rhods-dashboard-internal-route.yaml

apiVersion: route.openshift.io/v1
kind: Route
metadata:
  name: rhods-dashboard-internal
  namespace: redhat-ods-applications
  labels:
    app: rhods-dashboard
    app.kubernetes.io/part-of: rhods-dashboard  
spec:
  port:
    targetPort: 8080-tcp
  to:
    kind: Service
    name: rhods-dashboard
  wildcardPolicy: None
Make a query to the new route, using a wrong oauth token

curl --location --request GET 'http://rhods-dashboard-internal-redhat-ods-applications.apps.{cluster_name}.xxx.com/api/status'  --header 'x-forwarded-access-token: asdfadsfasd'
Answer from the test call should have error code 401

Verify response status code is error 401, similar to this:
{"statusCode":401,"code":"401","error":"Unauthorized","message":"Failed to retrieve username: Error getting Oauth Info for user, Unauthorized"}

Note: in RHODS 1.18 and before, the response was error 500, provoking alert RHODS Dashboard Route Error to fire

{"statusCode":500,"code":"500","error":"Internal Server Error","message":"Failed to retrieve username: Error getting Oauth Info for user, undefined - HTTP request failed"}
Remove the additional route and additional ports added before
oc delete route rhods-dashboard-internal -n redhat-ods-applications

@jiridanek
Copy link
Collaborator Author

jiridanek commented Jan 10, 2024

It runs...

2024-01-10T18:15:00 INFO  [Environment:92] USER: jdanek
2024-01-10T18:15:00 DEBUG [KubeClient:52] Creating client in namespace: default
2024-01-10T18:15:01 INFO  [TestPlanExecutionListener:21] =======================================================================
2024-01-10T18:15:01 INFO  [TestPlanExecutionListener:22] =======================================================================
2024-01-10T18:15:01 INFO  [TestPlanExecutionListener:23]                         Test run started
2024-01-10T18:15:01 INFO  [TestPlanExecutionListener:24] =======================================================================
2024-01-10T18:15:01 INFO  [TestPlanExecutionListener:25] =======================================================================
2024-01-10T18:15:01 INFO  [TestVisualSeparator:24] ############################################################################
2024-01-10T18:15:01 INFO  [TestVisualSeparator:25] io.odh.test.e2e.continuous.DataScienceDashboardST.checkDataScienceProjects-STARTED
2024-01-10T18:15:03 DEBUG [DataScienceDashboardST:104] Making request http://rhods-dashboard-internal-redhat-ods-applications.apps.xxx.com/api/status GET
2024-01-10T18:15:04 DEBUG [DataScienceDashboardST:107] Got response (GET http://rhods-dashboard-internal-redhat-ods-applications.apps.xxx.com/api/status) 401
2024-01-10T18:15:04 INFO  [TestVisualSeparator:31] io.odh.test.e2e.continuous.DataScienceDashboardST.checkDataScienceProjects-FINISHED
2024-01-10T18:15:04 INFO  [TestVisualSeparator:33] ############################################################################

static final Logger LOGGER = LoggerFactory.getLogger(DataScienceDashboardST.class);

@Test
void checkDataScienceProjects() throws IOException, InterruptedException {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@Tag("ODS-1860")?

Comment on lines +111 to +112
service.edit().editSpec().removeFromPorts(port1, port2).endSpec().build();
kubeClient.routes().resource(route).delete();
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't like this teardown. I can put it either in finally or do @nested test class and make it regular @after... teardown?

LOGGER.debug("Making request {}", request);
HttpClient httpClient = HttpClient.newHttpClient();
HttpResponse<Void> response = httpClient.send(request, HttpResponse.BodyHandlers.discarding());
LOGGER.debug("Got response {}", response);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Regarding the test scenario itself. Maybe run this curl directly in the container the service is fronting? Or put my own container that contains curl there, and don't expose any routes...?

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

Successfully merging this pull request may close these issues.

1 participant