77 "fmt"
88 "math/rand"
99 "net"
10- "os"
1110 "os/exec"
1211 "path/filepath"
1312 "strconv"
@@ -21,7 +20,6 @@ import (
2120 projectv1 "github.com/openshift/api/project/v1"
2221 configv1client "github.com/openshift/client-go/config/clientset/versioned"
2322 networkclient "github.com/openshift/client-go/network/clientset/versioned/typed/network/v1"
24- "github.com/openshift/library-go/pkg/network/networkutils"
2523 exutil "github.com/openshift/origin/test/extended/util"
2624 appsv1 "k8s.io/api/apps/v1"
2725 corev1 "k8s.io/api/core/v1"
@@ -33,7 +31,6 @@ import (
3331 "k8s.io/apimachinery/pkg/util/intstr"
3432 "k8s.io/apimachinery/pkg/util/sets"
3533 "k8s.io/apimachinery/pkg/util/wait"
36- "k8s.io/apiserver/pkg/storage/names"
3734 "k8s.io/client-go/dynamic"
3835 "k8s.io/client-go/kubernetes"
3936 k8sclient "k8s.io/client-go/kubernetes"
@@ -282,29 +279,6 @@ func networkPluginName() string {
282279 return * cachedNetworkPluginName
283280}
284281
285- func pluginIsolatesNamespaces () bool {
286- if os .Getenv ("NETWORKING_E2E_ISOLATION" ) == "true" {
287- return true
288- }
289- // Assume that only the OpenShift SDN "multitenant" plugin isolates by default
290- return openshiftSDNMode () == networkutils .MultiTenantPluginName
291- }
292-
293- func pluginImplementsNetworkPolicy () bool {
294- switch {
295- case os .Getenv ("NETWORKING_E2E_NETWORKPOLICY" ) == "true" :
296- return true
297- case networkPluginName () == OpenshiftSDNPluginName && openshiftSDNMode () == networkutils .NetworkPolicyPluginName :
298- return true
299- case networkPluginName () == OVNKubernetesPluginName :
300- return true
301- default :
302- // If we can't detect the plugin, we assume it doesn't support
303- // NetworkPolicy, so the tests will work under kubenet
304- return false
305- }
306- }
307-
308282func makeNamespaceGlobal (oc * exutil.CLI , ns * corev1.Namespace ) {
309283 clientConfig := oc .AdminConfig ()
310284 networkClient := networkclient .NewForConfigOrDie (clientConfig )
@@ -432,92 +406,6 @@ func findAppropriateNodes(f *e2e.Framework, nodeType NodeType) (*corev1.Node, *c
432406 return & candidates [0 ], & candidates [0 ], nil
433407}
434408
435- func checkPodIsolation (f1 , f2 * e2e.Framework , nodeType NodeType ) error {
436- makeNamespaceScheduleToAllNodes (f1 )
437- makeNamespaceScheduleToAllNodes (f2 )
438- serverNode , clientNode , err := findAppropriateNodes (f1 , nodeType )
439- if err != nil {
440- return err
441- }
442- podName := "isolation-webserver"
443- defer f1 .ClientSet .CoreV1 ().Pods (f1 .Namespace .Name ).Delete (context .Background (), podName , metav1.DeleteOptions {})
444- ip := exutil .LaunchWebserverPod (f1 .ClientSet , f1 .Namespace .Name , podName , serverNode .Name )
445-
446- return checkConnectivityToHost (f2 , clientNode .Name , "isolation-wget" , ip , 10 * time .Second )
447- }
448-
449- func checkServiceConnectivity (serverFramework , clientFramework * e2e.Framework , nodeType NodeType ) error {
450- makeNamespaceScheduleToAllNodes (serverFramework )
451- makeNamespaceScheduleToAllNodes (clientFramework )
452- serverNode , clientNode , err := findAppropriateNodes (serverFramework , nodeType )
453- if err != nil {
454- return err
455- }
456- podName := names .SimpleNameGenerator .GenerateName ("service-" )
457- defer serverFramework .ClientSet .CoreV1 ().Pods (serverFramework .Namespace .Name ).Delete (context .Background (), podName , metav1.DeleteOptions {})
458- defer serverFramework .ClientSet .CoreV1 ().Services (serverFramework .Namespace .Name ).Delete (context .Background (), podName , metav1.DeleteOptions {})
459- ip := launchWebserverService (serverFramework .ClientSet , serverFramework .Namespace .Name , podName , serverNode .Name )
460-
461- return checkConnectivityToHost (clientFramework , clientNode .Name , "service-wget" , ip , 10 * time .Second )
462- }
463-
464- func InNonIsolatingContext (body func ()) {
465- Context ("when using a plugin in a mode that does not isolate namespaces by default" , func () {
466- BeforeEach (func () {
467- if pluginIsolatesNamespaces () {
468- e2eskipper .Skipf ("This plugin isolates namespaces by default." )
469- }
470- })
471-
472- body ()
473- })
474- }
475-
476- func InIsolatingContext (body func ()) {
477- Context ("when using a plugin in a mode that isolates namespaces by default" , func () {
478- BeforeEach (func () {
479- if ! pluginIsolatesNamespaces () {
480- e2eskipper .Skipf ("This plugin does not isolate namespaces by default." )
481- }
482- })
483-
484- body ()
485- })
486- }
487-
488- func InNetworkPolicyContext (body func ()) {
489- Context ("when using a plugin that implements NetworkPolicy" , func () {
490- BeforeEach (func () {
491- if ! pluginImplementsNetworkPolicy () {
492- e2eskipper .Skipf ("This plugin does not implement NetworkPolicy." )
493- }
494- })
495-
496- body ()
497- })
498- }
499-
500- func InopenshiftSDNModeContext (plugins []string , body func ()) {
501- Context (fmt .Sprintf ("when using one of the OpenshiftSDN modes '%s'" , strings .Join (plugins , ", " )),
502- func () {
503- BeforeEach (func () {
504- found := false
505- for _ , plugin := range plugins {
506- if openshiftSDNMode () == plugin {
507- found = true
508- break
509- }
510- }
511- if ! found {
512- e2eskipper .Skipf ("Not using one of the specified OpenshiftSDN modes" )
513- }
514- })
515-
516- body ()
517- },
518- )
519- }
520-
521409func InOpenShiftSDNContext (body func ()) {
522410 Context ("when using openshift-sdn" ,
523411 func () {
0 commit comments