CreateEndpoints creates and returns a randon number of endpoints in a schema structure
()
| 54 | |
| 55 | // CreateEndpoints creates and returns a randon number of endpoints in a schema structure |
| 56 | func (devfile *TestDevfile) CreateEndpoints() []schema.Endpoint { |
| 57 | |
| 58 | numEndpoints := GetRandomNumber(1, 5) |
| 59 | endpoints := make([]schema.Endpoint, numEndpoints) |
| 60 | |
| 61 | commonPort := devfile.getUniquePort() |
| 62 | |
| 63 | for i := 0; i < numEndpoints; i++ { |
| 64 | |
| 65 | endpoint := schema.Endpoint{} |
| 66 | |
| 67 | endpoint.Name = GetRandomUniqueString(GetRandomNumber(5, 10), true) |
| 68 | LogInfoMessage(fmt.Sprintf(" ....... add endpoint %d name : %s", i, endpoint.Name)) |
| 69 | |
| 70 | if GetBinaryDecision() { |
| 71 | endpoint.TargetPort = devfile.getUniquePort() |
| 72 | } else { |
| 73 | endpoint.TargetPort = commonPort |
| 74 | } |
| 75 | LogInfoMessage(fmt.Sprintf(" ....... add endpoint %d targetPort: %d", i, endpoint.TargetPort)) |
| 76 | |
| 77 | if GetBinaryDecision() { |
| 78 | endpoint.Exposure = getRandomExposure() |
| 79 | LogInfoMessage(fmt.Sprintf(" ....... add endpoint %d exposure: %s", i, endpoint.Exposure)) |
| 80 | } |
| 81 | |
| 82 | if GetBinaryDecision() { |
| 83 | endpoint.Protocol = getRandomProtocol() |
| 84 | LogInfoMessage(fmt.Sprintf(" ....... add endpoint %d protocol: %s", i, endpoint.Protocol)) |
| 85 | } |
| 86 | |
| 87 | value := GetBinaryDecision() |
| 88 | endpoint.Secure = &value |
| 89 | LogInfoMessage(fmt.Sprintf(" ....... add endpoint %d secure: %t", i, *endpoint.Secure)) |
| 90 | |
| 91 | if GetBinaryDecision() { |
| 92 | endpoint.Path = "/Path_" + GetRandomString(GetRandomNumber(3, 15), false) |
| 93 | LogInfoMessage(fmt.Sprintf(" ....... add endpoint %d path: %s", i, endpoint.Path)) |
| 94 | } |
| 95 | |
| 96 | endpoints[i] = endpoint |
| 97 | |
| 98 | } |
| 99 | |
| 100 | return endpoints |
| 101 | } |
no test coverage detected