(o *options)
| 148 | } |
| 149 | |
| 150 | func Run(o *options) error { |
| 151 | runFilterRegex, err := compileRunFilter(o.runFilter) |
| 152 | if err != nil { |
| 153 | return err |
| 154 | } |
| 155 | |
| 156 | networkPolicyDelay, err := time.ParseDuration(o.networkPolicyDelay) |
| 157 | if err != nil { |
| 158 | return fmt.Errorf("NetworkPolicy delay is not a valid duration string: %w", err) |
| 159 | } |
| 160 | if networkPolicyDelay < minNetworkPolicyDelay { |
| 161 | return fmt.Errorf("NetworkPolicy delay should not be less than %v", minNetworkPolicyDelay) |
| 162 | } |
| 163 | |
| 164 | client, config, clusterName, err := check.NewClient() |
| 165 | if err != nil { |
| 166 | return fmt.Errorf("unable to create Kubernetes client: %w", err) |
| 167 | } |
| 168 | antreaClient, err := antrea.NewForConfig(config) |
| 169 | if err != nil { |
| 170 | return fmt.Errorf("unable to create Antrea client: %w", err) |
| 171 | } |
| 172 | ctx := context.Background() |
| 173 | testContext := NewTestContext(client, antreaClient, config, clusterName, o.antreaNamespace, runFilterRegex, o.testImage, networkPolicyDelay) |
| 174 | defer check.Teardown(ctx, testContext.Logger, testContext.client, testContext.namespace) |
| 175 | if err := testContext.setup(ctx); err != nil { |
| 176 | return err |
| 177 | } |
| 178 | stats := testContext.runTests(ctx) |
| 179 | |
| 180 | testContext.Log("Test finished: %v tests succeeded, %v tests failed, %v tests were skipped", stats.numSuccess, stats.numFailure, stats.numSkipped) |
| 181 | if stats.numFailure > 0 { |
| 182 | return fmt.Errorf("%v/%v tests failed", stats.numFailure, stats.numTotal()) |
| 183 | } |
| 184 | return nil |
| 185 | } |
| 186 | |
| 187 | func tcpProbeCommand(ip string, port int) []string { |
| 188 | return []string{"nc", ip, fmt.Sprint(port), "--wait=3s", "-vz"} |
no test coverage detected