OSDU Platform Validation CI_CD_Notes.md 4.32 KB
Newer Older
Kamlesh Todai's avatar
Kamlesh Todai committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
OSDU Platform Validation CI/CD pipeline settings notes and assumptions:

We are using a continuous service offered by GitLab to trigger CI
pipeline for each push.

Ensure that project is configured to use a Runner, as it will be used to
run the jobs defined in file

.gitlab-ci.yml.

In order to do that we have added file .gitlab-ci.yml to the
repository’s root directory.

Only project Maintainer and Admin users have the permissions to access
the project settings. 

The pipeline appears under the project’s **CI/CD \> Pipelines** page. If
everything runs OK (no non-zero return values), you get a green check
mark associated with the commit. This makes it easy to see whether a
commit caused any of the tests to fail before one even looks at the job
(test) log.

Certain variables to run the collection need protection and hence are
not defined in the postman_environment.json files. Variables left
undefined in the files and gets define in the
settings-\>CI/CD-\>variables section. The variable type is set to file
and values contains the JSON string defining those protected variables.

The protected variables are:

> TENANT_ID, CLIENT_ID and CLIENT_SECRECT

Example JSON string would be

> \[
>
> {
>
> "TENANT_ID": "Actual Tenant ID goes here",
>
> "CLIENT_ID": "Actual Client ID goes here",
>
> "CLIENT_SECRET": "Actual Client Secret goes here"
>
> }
>
> \]

The cloud providers usually provide the values for these variables.

For this project, at present there are four variables defined in
settings-\>CI/CD-\>variables section, one for each cloud provider.

-   AWS_TEST_COLLECTION_CONFIG for Amazon cloud

-   AZURE_TEST_COLLECTION_CONFIG for Microsoft Azure cloud

-   GCP_TEST_COLLECTION_CONFIG for Google cloud

-   IBM_TEST_COLLECTION_CONFIG for IBM cloud

Have added the python script, generate-pipeline.py to the repository’s
root directory. This script generates the pipeline for each configured
64
cloud provider and test job for each collection in the repository.
Kamlesh Todai's avatar
Kamlesh Todai committed
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87

The python script is making the following assumptions:

Configuration file for each cloud provider is named as follows:

> cloudProviderName.someString.**postman_environment.json**
>
> Where,
>
> cloudProvider = {aws, azure, gcp, ibm}
>
> someString = e.g. “OSDU R3 PROD v2.4”
>
> e.g. azure. OSDU R3 PROD v2.4.postman_environment.json

The collections files name are as follows:

> Collection file names end with **.postman_collection.json**
>
> e.g. Well CI-CD v2.6.postman_collection.json
>
> Trajectory CI-CD v1.3.3.postman_collection.json

88
Python script generates “test-execution.gitlab-ci.yml” file in build
89
environment to execute pipelines and run the tests. The generated
90
91
92
93
file would have stages for each cloud platform and then each stage would
have tests to run each collection using “newman”

“.gitlab-ci.yml” file has two stages - generate and test. The generate
94
stage, executes the above-mentioned python script that configures the
95
pipelines and tests to be run for each collection and on each cloud
96
97
platform. The test stage uses the generated file to execute the pipelines
and run the tests
Kamlesh Todai's avatar
Kamlesh Todai committed
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129

Detail reference for GitLab Ci/CD refer to following link

<https://docs.gitlab.com/ee/ci/quick_start/>

**Side notes and current status:**

When pipeline executes the collection, it uses” newman” utility,
provided by Postman to run the collection.

For details on how use newman

[<u>https://www.npmjs.com/package/newman\#getting-started</u>](https://www.npmjs.com/package/newman#getting-started)

Newman can generate variety kind of reports like cli, html, htmlextra,
junit to name few. For each of this type a plugin needs to be loaded in
the system to generate the report.

At present, we will start with junit and htmlextra. Junit is easy to
integrate with git merge request and htmlextra generates reports
providing nice dashboard kind of look with summary and detail tabs.

In generate-pipeline.py script, the lines responsible to generate these
reports are commented out, because the docker image
**postman/newman_alpine33** that is being used does not have the
required plugins installed. Once that docker images or some other docker
images with correct plugin is available, one can uncomment the commented
lines to generate these reports.

Also in .gitlab-ci.yml file the pipeline for gcp and ibm are commented
out as at this point in time the environments are not available for
these platforms.