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 support conduct an API test of plugins #624

Merged
merged 13 commits into from
Jun 15, 2022
Merged

Conversation

jxr98
Copy link
Contributor

@jxr98 jxr98 commented Aug 29, 2021

Make sure that you've checked the boxes below before you submit PR:

Always

  • Make sure you are requesting to pull a topic/feature/bugfix branch (right side) and not your master branch!
  • Written well with PR title, we generate the release notes base on that

For the bug fixes or features only

  • Quality Gate Passed. Change this URL to your PR.
  • The coverage is xxx on the new lines
  • I've tested it by manual in the following platform
    • MacOS
    • Linux
    • Windows
  • Unit Test covered
  • e2e Test covered

@codecov
Copy link

codecov bot commented Aug 29, 2021

Codecov Report

Merging #624 (7458f8a) into master (0a0e878) will not change coverage.
The diff coverage is n/a.

❗ Current head 7458f8a differs from pull request most recent head 51775e6. Consider uploading reports for the commit 51775e6 to get more accurate results

@@           Coverage Diff           @@
##           master     #624   +/-   ##
=======================================
  Coverage   37.98%   37.98%           
=======================================
  Files          13       13           
  Lines         416      416           
=======================================
  Hits          158      158           
  Misses        246      246           
  Partials       12       12           
Flag Coverage Δ
unittests 37.98% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out 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 9dc48d8...51775e6. Read the comment docs.

go.mod Outdated
golang.org/x/text v0.3.6
golang.org/x/tools v0.1.5 // indirect
Copy link
Member

Choose a reason for hiding this comment

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

Do we really need these go modules? I didn't find any import statements.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

toolsindirect
I had run 'go mod tidy' and the go.mod did include golang.org/x/tools. And it was required by another dependency.

Comment on lines 36 to 37
Short: "",
Long: "",
Copy link
Member

Choose a reason for hiding this comment

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

Why empty here?

Comment on lines 28 to 33
var ip string
var port string
var jenkinsPluginTest jenkinsFormula.CustomWarPackage
var pluginsWithProblem []string
var userName string
var token string
Copy link
Member

Choose a reason for hiding this comment

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

@jxr98 jxr98 changed the title Add support conduct an API test of plugins WIP:Add support conduct an API test of plugins Sep 8, 2021
@jxr98 jxr98 changed the title WIP:Add support conduct an API test of plugins Add support conduct an API test of plugins Sep 10, 2021
},
}
getCurrentJenkinsAndClient(&(jClient.JenkinsCore))
jClient.JenkinsCore.URL = fmt.Sprintf("http://%s:%s", pluginAPITestO.ip, pluginAPITestO.port)
Copy link
Member

Choose a reason for hiding this comment

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

What if the scheme of Jenkins URL is https?

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 understand why we need to overwrite the URL here. Becuase I found that the method GetCurrentJenkinsAndClient will set it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because this function is to conduct an API test for plugins in upgraded jenkins which is different with the one clarified in .jenkins-cli.yaml.

RoundTripper: pluginFormulaOption.RoundTripper,
},
}
getCurrentJenkinsAndClient(&(jClient.JenkinsCore))
Copy link
Member

Choose a reason for hiding this comment

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

Please note that the getCurrentJenkinsAndClient is deprecated. Use GetCurrentJenkinsAndClient instead.

},
}
getCurrentJenkinsAndClient(&(jClient.JenkinsCore))
jClient.JenkinsCore.URL = fmt.Sprintf("http://%s:%s", pluginAPITestO.ip, pluginAPITestO.port)
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 understand why we need to overwrite the URL here. Becuase I found that the method GetCurrentJenkinsAndClient will set it.

if statusCode != 200 {
errorAPI, ok := pluginsWithProblemMap[plugin.ArtifactID]
if ok {
pluginsWithProblemMap[plugin.ArtifactID] = errorAPI + " " + api
Copy link
Member

Choose a reason for hiding this comment

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

Why we keep three spaces here.

for _, plugin := range apiTestO.Plugins {
apis := plugin.API
for _, api := range apis {
statusCode, _, err := jClient.JenkinsCore.Request(http.MethodGet, api, nil, nil)
Copy link
Member

Choose a reason for hiding this comment

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

jClient.JenkinsCore.Request -> jClient.Request

if err != nil {
return err
}
pluginsWithProblemMap := make(map[string]string)
Copy link
Member

Choose a reason for hiding this comment

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

I suggest using map type: map[string][]string here.

@jxr98 jxr98 changed the title Add support conduct an API test of plugins WIP: Add support conduct an API test of plugins Sep 26, 2021
yJunS and others added 3 commits September 28, 2021 10:31
@jxr98
Copy link
Contributor Author

jxr98 commented Sep 28, 2021

Sorry, I included some commits that are not mine. Will fix that in a short time.

@jxr98
Copy link
Contributor Author

jxr98 commented Sep 28, 2021

The custom yaml need to follow the format of the following example:
plugins:

  • artifactId: "nameOne"
    api :
    - "/pluginManager/plugin/sshd/api/json"
    - "/urlTwo"
  • artifactId: "nameTwo"
    api :
    - "/urlOne"

@jxr98 jxr98 changed the title WIP: Add support conduct an API test of plugins Add support conduct an API test of plugins Sep 28, 2021
@LinuxSuRen LinuxSuRen merged commit 26b4f1f into jenkins-zh:master Jun 15, 2022
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.

4 participants