Skip to content

Commit 75e440c

Browse files
committed
feat: #31 Adding the --filteredOperations flag and preparing release 0.5.3
Signed-off-by: Laurent Broudoux <[email protected]>
1 parent 74a58ed commit 75e440c

File tree

6 files changed

+37
-10
lines changed

6 files changed

+37
-10
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@
1010

1111
# Output of the go coverage tool, specifically when used with LiteIDE
1212
*.out
13+
14+
# Ouput of the build-binaries script
15+
build/_output

cmd/test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ func (c *testComamnd) Execute() {
6565
var keycloakClientSecret string
6666
var waitFor string
6767
var secretName string
68+
var filteredOperations string
6869
var operationsHeaders string
6970
var insecureTLS bool
7071
var caCertPaths string
@@ -75,6 +76,7 @@ func (c *testComamnd) Execute() {
7576
testCmd.StringVar(&keycloakClientSecret, "keycloakClientSecret", "", "Keycloak Realm Service Account ClientSecret")
7677
testCmd.StringVar(&waitFor, "waitFor", "5sec", "Time to wait for test to finish")
7778
testCmd.StringVar(&secretName, "secretName", "", "Secret to use for connecting test endpoint")
79+
testCmd.StringVar(&filteredOperations, "filteredOperations", "", "List of operations to launch a test for")
7880
testCmd.StringVar(&operationsHeaders, "operationsHeaders", "", "Override of operations headers as JSON string")
7981
testCmd.BoolVar(&insecureTLS, "insecure", false, "Whether to accept insecure HTTPS connection")
8082
testCmd.StringVar(&caCertPaths, "caCerts", "", "Comma separated paths of CRT files to add to Root CAs")
@@ -148,7 +150,7 @@ func (c *testComamnd) Execute() {
148150
mc.SetOAuthToken(oauthToken)
149151

150152
var testResultID string
151-
testResultID, err = mc.CreateTestResult(serviceRef, testEndpoint, runnerType, secretName, waitForMilliseconds, operationsHeaders)
153+
testResultID, err = mc.CreateTestResult(serviceRef, testEndpoint, runnerType, secretName, waitForMilliseconds, filteredOperations, operationsHeaders)
152154
if err != nil {
153155
fmt.Printf("Got error when invoking Microcks client creating Test: %s", err)
154156
os.Exit(1)

pkg/connectors/microcks_client.go

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
type MicrocksClient interface {
2222
GetKeycloakURL() (string, error)
2323
SetOAuthToken(oauthToken string)
24-
CreateTestResult(serviceID string, testEndpoint string, runnerType string, secretName string, timeout int64, operationsHeaders string) (string, error)
24+
CreateTestResult(serviceID string, testEndpoint string, runnerType string, secretName string, timeout int64, filteredOperations string, operationsHeaders string) (string, error)
2525
GetTestResult(testResultID string) (*TestResultSummary, error)
2626
UploadArtifact(specificationFilePath string, mainArtifact bool) (string, error)
2727
}
@@ -122,7 +122,7 @@ func (c *microcksClient) SetOAuthToken(oauthToken string) {
122122
c.OAuthToken = oauthToken
123123
}
124124

125-
func (c *microcksClient) CreateTestResult(serviceID string, testEndpoint string, runnerType string, secretName string, timeout int64, operationsHeaders string) (string, error) {
125+
func (c *microcksClient) CreateTestResult(serviceID string, testEndpoint string, runnerType string, secretName string, timeout int64, filteredOperations string, operationsHeaders string) (string, error) {
126126
// Ensure we have a correct URL.
127127
rel := &url.URL{Path: "tests"}
128128
u := c.APIURL.ResolveReference(rel)
@@ -136,7 +136,10 @@ func (c *microcksClient) CreateTestResult(serviceID string, testEndpoint string,
136136
if len(secretName) > 0 {
137137
input += (", \"secretName\": \"" + secretName + "\"")
138138
}
139-
if len(operationsHeaders) > 0 && ensureValid(operationsHeaders) {
139+
if len(filteredOperations) > 0 && ensureValidOperationsList(filteredOperations) {
140+
input += (", \"filteredOperations\": " + filteredOperations)
141+
}
142+
if len(operationsHeaders) > 0 && ensureValidOperationsHeaders(operationsHeaders) {
140143
input += (", \"operationsHeaders\": " + operationsHeaders)
141144
}
142145

@@ -272,7 +275,18 @@ func (c *microcksClient) UploadArtifact(specificationFilePath string, mainArtifa
272275
return string(respBody), err
273276
}
274277

275-
func ensureValid(operationsHeaders string) bool {
278+
func ensureValidOperationsList(filteredOperations string) bool {
279+
// Unmarshal using a generic interface
280+
var list = []string{}
281+
err := json.Unmarshal([]byte(filteredOperations), &list)
282+
if err != nil {
283+
fmt.Println("Error parsing JSON in filteredOperations: ", err)
284+
return false
285+
}
286+
return true
287+
}
288+
289+
func ensureValidOperationsHeaders(operationsHeaders string) bool {
276290
// Unmarshal using a generic interface
277291
var headers = map[string][]HeaderDTO{}
278292
err := json.Unmarshal([]byte(operationsHeaders), &headers)

tekton/microcks-test-customcerts-task.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ spec:
3030
type: string
3131
description: "Time to wait for test to finish (int + one of: milli, sec, min)"
3232
default: 5sec
33+
- name: filteredOperations
34+
type: string
35+
description: "JSON array of the operations' names to consider during the tests"
36+
default: ""
3337
- name: operationsHeaders
3438
type: string
3539
description: "JSON that override some operations headers for the tests to launch"
@@ -39,7 +43,7 @@ spec:
3943
description: "Paths to additional certificates CRT files to add to trusted roots ones"
4044
steps:
4145
- name: microcks-test
42-
image: quay.io/microcks/microcks-cli:0.5.1
46+
image: quay.io/microcks/microcks-cli:0.5.3
4347
volumeMounts:
4448
- name: microcks-test-customcerts
4549
mountPath: /var/run/secrets/customcerts
@@ -51,7 +55,7 @@ spec:
5155
microcks-cli test '$(params.apiNameAndVersion)' $(params.testEndpoint) $(params.runner) \
5256
--microcksURL=$(params.microcksURL) --waitFor=$(params.waitFor) \
5357
--keycloakClientId=$(params.keycloakClientId) --keycloakClientSecret=$(params.keycloakClientSecret) \
54-
--caCerts=/var/run/secrets/customcerts/ca.crt --operationsHeaders='$(params.operationsHeaders)'
58+
--caCerts=/var/run/secrets/customcerts/ca.crt --filteredOperations='$(params.filteredOperations)' --operationsHeaders='$(params.operationsHeaders)'
5559
volumes:
5660
- name: microcks-test-customcerts
5761
secret:

tekton/microcks-test-task.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,17 @@ spec:
3030
type: string
3131
description: "Time to wait for test to finish (int + one of: milli, sec, min)"
3232
default: 5sec
33+
- name: filteredOperations
34+
type: string
35+
description: "JSON array of the operations' names to consider during the tests"
36+
default: ""
3337
- name: operationsHeaders
3438
type: string
3539
description: "JSON that override some operations headers for the tests to launch"
3640
default: ""
3741
steps:
3842
- name: microcks-test
39-
image: quay.io/microcks/microcks-cli:0.5.1
43+
image: quay.io/microcks/microcks-cli:0.5.3
4044
command:
4145
- /usr/bin/bash
4246
args:
@@ -45,4 +49,4 @@ spec:
4549
microcks-cli test '$(params.apiNameAndVersion)' $(params.testEndpoint) $(params.runner) \
4650
--microcksURL=$(params.microcksURL) --waitFor=$(params.waitFor) \
4751
--keycloakClientId=$(params.keycloakClientId) --keycloakClientSecret=$(params.keycloakClientSecret) \
48-
--insecure --operationsHeaders='$(params.operationsHeaders)'
52+
--insecure --filteredOperations='$(params.filteredOperations)' --operationsHeaders='$(params.operationsHeaders)'

version/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package version
22

33
var (
4-
Version = "0.5.2"
4+
Version = "0.5.3"
55
)

0 commit comments

Comments
 (0)