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

feat: rewrite e2e test(test-e2e-route-with-management-fields) using ginkgo #1704

Merged

Conversation

bisakhmondal
Copy link
Member

Please answer these questions before submitting a pull request, or your PR will get closed.

Why submit this pull request?

  • Bugfix
  • New feature provided
  • Improve performance
  • Backport patches

Related issues

#1500

Checklist:

  • Did you explain what problem does this PR solve? Or what new features have been added?
  • Have you added corresponding test cases?
  • Have you modified the corresponding document?
  • Is this PR backward compatible? If it is not backward compatible, please discuss on the mailing list first

@juzhiyuan juzhiyuan requested review from Jaycean and nic-chen April 2, 2021 10:10
"upstream": {
"type": "roundrobin",
"nodes": [{
"host": "172.16.238.20",
Copy link
Member

Choose a reason for hiding this comment

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

nodes host please use the base.UpstreamIp

"nodes": {
			"` + base.UpstreamIp + `:1980": 1
		}

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks. Done ✔️

api/test/e2enew/route/route_with_management_fields_test.go Outdated Show resolved Hide resolved
api/test/e2enew/route/route_with_management_fields_test.go Outdated Show resolved Hide resolved
api/test/e2enew/route/route_with_management_fields_test.go Outdated Show resolved Hide resolved
api/test/e2enew/route/route_with_management_fields_test.go Outdated Show resolved Hide resolved
api/test/e2enew/route/route_with_management_fields_test.go Outdated Show resolved Hide resolved
api/test/e2enew/route/route_with_management_fields_test.go Outdated Show resolved Hide resolved
Headers: map[string]string{"Authorization": base.GetToken()},
ExpectStatus: http.StatusOK,
})
})
Copy link
Member

Choose a reason for hiding this comment

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

After the route is deleted, we need to check whether the route is deleted.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done ✔️

@bisakhmondal
Copy link
Member Author

ci fails to pull docker images
cc @Jaycean, @juzhiyuan, @nic-chen

@juzhiyuan
Copy link
Member

ci fails to pull docker images
cc @Jaycean, @juzhiyuan, @nic-chen

ok, just retrigger

Method: http.MethodGet,
Path: "/hello",
Headers: map[string]string{"Authorization": base.GetToken()},
ExpectStatus: http.StatusNotFound,
Copy link
Member

Choose a reason for hiding this comment

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

better to check respond body for each case

Copy link
Member Author

Choose a reason for hiding this comment

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

Done :)

@codecov-io
Copy link

Codecov Report

Merging #1704 (85b01da) into master (9cf91b7) will decrease coverage by 20.33%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           master    #1704       +/-   ##
===========================================
- Coverage   72.63%   52.29%   -20.34%     
===========================================
  Files         133       38       -95     
  Lines        5740     2660     -3080     
  Branches      666        0      -666     
===========================================
- Hits         4169     1391     -2778     
+ Misses       1327     1081      -246     
+ Partials      244      188       -56     
Flag Coverage Δ
backend-e2e-test ?
backend-e2e-test-ginkgo ?
backend-unit-test 52.29% <ø> (+0.03%) ⬆️
frontend-e2e-test ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
api/internal/utils/version.go 0.00% <0.00%> (-100.00%) ⬇️
api/internal/filter/request_id.go 0.00% <0.00%> (-100.00%) ⬇️
api/internal/core/entity/entity.go 0.00% <0.00%> (-100.00%) ⬇️
api/internal/core/store/storehub.go 0.00% <0.00%> (-71.03%) ⬇️
api/internal/filter/cors.go 0.00% <0.00%> (-66.67%) ⬇️
api/internal/filter/schema.go 0.00% <0.00%> (-55.47%) ⬇️
api/internal/utils/consts/api_error.go 0.00% <0.00%> (-50.00%) ⬇️
api/internal/handler/data_loader/route_import.go 27.41% <0.00%> (-37.50%) ⬇️
api/internal/handler/handler.go 42.59% <0.00%> (-35.19%) ⬇️
api/internal/handler/schema/schema.go 66.66% <0.00%> (-33.34%) ⬇️
... and 119 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9cf91b7...85b01da. Read the comment docs.

}`,
Headers: map[string]string{"Authorization": base.GetToken()},
ExpectStatus: http.StatusOK,
Sleep: time.Duration(2) * time.Second,
Copy link
Member

Choose a reason for hiding this comment

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

need to check body too

Copy link
Member Author

@bisakhmondal bisakhmondal Apr 6, 2021

Choose a reason for hiding this comment

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

okay. Just for this one or all other PUTs too

Copy link
Member Author

Choose a reason for hiding this comment

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

Hi Nic, just to make sure, the response body contains dynamic information like timestamp, do we really have to check the body?
However, I have added ExpectCode as somewhat an alternative😄.
eg.

{
    "code": 0,
    "message": "",
    "data": {
        "id": "r1",
        "create_time": 1617804834,
        "update_time": 1617804834,
        "uri": "/hello",
        "name": "new jack",
        "desc": "new desc",
        "upstream": {
            "nodes": {
                "172.16.238.20:1980": 1
            },
            "type": "roundrobin"
        },
        "status": 1
    },
    "request_id": "22fbd110-3e00-4e2b-b267-528bdef67fd5"
}

Copy link
Member

Choose a reason for hiding this comment

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

We can test the fixed part, example:

ExpectBody: []string{`"code":0`, `"name":"new jack"`},

Copy link
Member Author

Choose a reason for hiding this comment

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

Cool. Adding changes.

Copy link
Member Author

Choose a reason for hiding this comment

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

Now, all tests with PUT request have been updated.

@Jaycean Jaycean requested review from starsz and tokers April 7, 2021 01:12
Copy link
Member

@Jaycean Jaycean left a comment

Choose a reason for hiding this comment

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

LGTM

request.Header.Add("Authorization", base.GetToken())
resp, err := http.DefaultClient.Do(request)
if err != nil {
return
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can use gomega to assert the err is nil.

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah sure. Good catch.

Copy link
Contributor

Choose a reason for hiding this comment

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

Well done.Thank you for your contribution.

@bisakhmondal bisakhmondal force-pushed the issue#1500_route_with_management_fields branch from bf776f4 to 347d1e7 Compare April 7, 2021 17:43
@bisakhmondal bisakhmondal requested review from starsz and nic-chen April 8, 2021 04:31
@juzhiyuan juzhiyuan merged commit 166137e into apache:master Apr 9, 2021
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.

8 participants