konveyor / tackle-pathfinder

Tackle Pathfinder application
Apache License 2.0
16 stars 23 forks source link

tackle-76-get-assessment #25

Closed jonathanvila closed 3 years ago

jonathanvila commented 3 years ago

Issue : https://github.com/konveyor/tackle-pathfinder/issues/12

Features covered

Pre steps :

  1. Install minikube : https://minikube.sigs.k8s.io/docs/start/
  2. Start minikube : minikube start --kubernetes-version=v1.20.2 --cpus 4 --memory 12000
  3. Enable ingress addons : minikube addons enable ingress
  4. Create tackle namespace
    kubectl create namespace tackle
  5. Deploy tackle ( to have the keycloak instance running ) on your K8s cluster
    $ kubectl apply -f  https://raw.githubusercontent.com/konveyor/tackle/main/kubernetes/kubernetes-tackle.yaml -n tackle
  6. Edit the Ingress object to allow direct request to Pathfinder API
    $ kubectl edit ingress tackle -n tackle

    Add this below paths:

     - backend:
          service:
            name: tackle-pathfinder
            port:
              number: 8080 
        path: /pathfinder
        pathType: ImplementationSpecific
  7. Build and push
    $ ./mvnw -U -B package -Dquarkus.container-image.push=true -Dquarkus.container-image.group={your quay user} -Dquarkus.container-image.registry=quay.io -Dquarkus.container-image.username={your quay user} -Dquarkus.container-image.password={your quay pwd} -Pnative
  8. Change the image in the deployment tackle-pathfinder to be the one you have pushed
  9. Rollout to update the image
    $ kubectl rollout restart deployment tackle-pathfinder -n tackle

    Envrioment vars for convenience with the cluster IP

    export api_ip={cluster ip}
    export kc_ip={cluster ip}

    Test case 1 : Obtain Keycloak secret

    $ export access_token=$(\
    curl -X POST http://$kc_ip/auth/realms/quarkus/protocol/openid-connect/token \
    --user backend-service:secret \
    -H 'content-type: application/x-www-form-urlencoded' \
    -d 'username=alice&password=alice&grant_type=password' | jq --raw-output '.access_token' \
    )

    Expectation test case 1

    % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
    Dload  Upload   Total   Spent    Left  Speed
    100  1825  100  1776  100    49  18500    510 --:--:-- --:--:-- --:--:-- 19010

Test case 2 : Create assessment for applicationId=20

curl "http://$api_ip/pathfinder/assessments" \
  -H 'Content-Type: application/json' -H 'Accept: application/json' -H "Authorization: Bearer "$access_token \
  -d "{ \"applicationId\": 20 }" \
  -s -i

Expectation Test case 2


HTTP/1.1 201 Created
Date: Mon, 22 Mar 2021 11:05:29 GMT
Content-Type: application/json
Content-Length: 46
Connection: keep-alive

{"id": {any ID},"applicationId":20,"status":"STARTED"}


### Test case 3 : Get the created Assessment
```Shell
curl -X GET "http://$api_ip/pathfinder/assessments/{previous ID}" \
  -H 'Content-Type: application/json' -H 'Accept: application/json' -H "Authorization: Bearer $access_token"  -s -i

Expectation Test Case 3 ( something similar to this output )


HTTP/1.1 200 OK
Date: Wed, 14 Apr 2021 12:23:23 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive

{"id":418,"applicationId":92,"status":"STARTED","stakeholders":[],"stakeholderGroups":[],"questionnaire":{"categories":[{"id":420,"order":1,"title":"Application Details","questions":[{"id":421,"order":1,"question":"Does the application development team understand and actively develop the application?","options":[{"id":422,"order":0,"option":"Unknown","checked":false},{"id":423,"order":1,"option":"External ..........