<commit_before>package url

import (
	"bufio"
	"bytes"
	"encoding/json"
	"fmt"
	"io"
	"io/ioutil"
	"net/http"
	"path/filepath"
	"strings"
	"time"

	o "github.com/onsi/gomega"

	exutil "github.com/openshift/origin/test/extended/util"
	"k8s.io/api/core/v1"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/util/wait"
	kclientset "k8s.io/client-go/kubernetes"
	e2e "k8s.io/kubernetes/test/e2e/framework"
)

type Tester struct {
	client           kclientset.Interface
	namespace        string
	podName          string
	errorPassThrough bool
}

func NewTester(client kclientset.Interface, ns string) *Tester {
	return &Tester{client: client, namespace: ns}
}

func (ut *Tester) Close() {
	if err := ut.client.Core().Pods(ut.namespace).Delete(ut.podName, metav1.NewDeleteOptions(1)); err != nil {
		e2e.Logf("Failed to delete exec pod %s: %v", ut.podName, err)
	}
	ut.podName = ""
}

func (ut *Tester) Response(test *Test) *Response {
	responses := ut.Responses(test)
	if responses == nil {
		return nil
	}
	if len(responses) == 0 {
		return nil
	}
	return responses[0]
}

func (ut *Tester) Responses(tests ...*Test) []*Response {
	if len(ut.podName) == 0 {
		name, err := createExecPod(ut.client, ut.namespace, "execpod")
		// exit even on error passthrough
		o.Expect(err).NotTo(o.HaveOccurred())
		ut.podName = name
	}
	// testToScript needs to run after creating the pod
	// in case we need to rsync files for a post body
	script := testsToScript(tests)
	output, err := e2e.RunHostCmd(ut.namespace, ut.podName, script)<commit_msg>fix for parallel tests creating an execpod<commit_after>package url

import (
	"bufio"
	"bytes"
	"encoding/json"
	"fmt"
	"io"
	"io/ioutil"
	"net/http"
	"path/filepath"
	"strings"
	"time"

	o "github.com/onsi/gomega"

	exutil "github.com/openshift/origin/test/extended/util"
	"k8s.io/api/core/v1"
	apierrs "k8s.io/apimachinery/pkg/api/errors"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/util/wait"
	kclientset "k8s.io/client-go/kubernetes"
	e2e "k8s.io/kubernetes/test/e2e/framework"
)

type Tester struct {
	client           kclientset.Interface
	namespace        string
	podName          string
	errorPassThrough bool
}

func NewTester(client kclientset.Interface, ns string) *Tester {
	return &Tester{client: client, namespace: ns}
}

func (ut *Tester) Close() {
	if err := ut.client.Core().Pods(ut.namespace).Delete(ut.podName, metav1.NewDeleteOptions(1)); err != nil {
		e2e.Logf("Failed to delete exec pod %s: %v", ut.podName, err)
	}
	ut.podName = ""
}

func (ut *Tester) Response(test *Test) *Response {
	responses := ut.Responses(test)
	if responses == nil {
		return nil
	}
	if len(responses) == 0 {
		return nil
	}
	return responses[0]
}

func (ut *Tester) Responses(tests ...*Test) []*Response {
	if len(ut.podName) == 0 {
		_, err := createExecPod(ut.client, ut.namespace, "execpod")
		if err != nil && !apierrs.IsAlreadyExists(err) {
			// exit even on error passthrough, unless the exec pod
			// was already created by a test running in parallel
			o.Expect(err).NotTo(o.HaveOccurred())
		}
		ut.podName = "execpod"
	}
	// testToScript needs to run after creating the pod
	// in case we need to rsync files for a post body
	script := testsToScript(tests)
	output, err := e2e.RunHostCmd(ut.namespace, ut.podName, script)
{'fraction_non_alphanumeric': 0.14238310708898944, 'fraction_numerical': 0.010558069381598794, 'mean_word_length': 3.784992784992785, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3371456', 'n_tokens_mistral': 1331, 'n_tokens_neox': 1292, 'n_words': 293}