Rename a couple things for obviousness

This commit is contained in:
Tim Hockin 2016-01-29 14:56:37 -08:00
parent 8d8de2efb4
commit fd5cbdf73f
4 changed files with 21 additions and 19 deletions

View File

@ -162,7 +162,7 @@ var _ = Describe("Upgrade [Feature:Upgrade]", func() {
})
f := NewFramework("cluster-upgrade")
var w *ServerTest
var w *ServiceTestFixture
BeforeEach(func() {
By("Setting up the service, RC, and pods")
w = NewServerTest(f.Client, f.Namespace.Name, svcName)

View File

@ -112,7 +112,7 @@ func ServeImageOrFail(f *Framework, test string, image string) {
By("Trying to dial each unique pod")
retryTimeout := 2 * time.Minute
retryInterval := 5 * time.Second
err = wait.Poll(retryInterval, retryTimeout, podResponseChecker{f.Client, f.Namespace.Name, label, name, true, pods}.checkAllResponses)
err = wait.Poll(retryInterval, retryTimeout, podProxyResponseChecker{f.Client, f.Namespace.Name, label, name, true, pods}.checkAllResponses)
if err != nil {
Failf("Did not get expected responses within the timeout period of %.2f seconds.", retryTimeout.Seconds())
}

View File

@ -1503,7 +1503,7 @@ func httpGetNoConnectionPool(url string) (*http.Response, error) {
}
// Simple helper class to avoid too much boilerplate in tests
type ServerTest struct {
type ServiceTestFixture struct {
ServiceName string
Namespace string
Client *client.Client
@ -1517,8 +1517,8 @@ type ServerTest struct {
image string
}
func NewServerTest(client *client.Client, namespace string, serviceName string) *ServerTest {
t := &ServerTest{}
func NewServerTest(client *client.Client, namespace string, serviceName string) *ServiceTestFixture {
t := &ServiceTestFixture{}
t.Client = client
t.Namespace = namespace
t.ServiceName = serviceName
@ -1536,8 +1536,8 @@ func NewServerTest(client *client.Client, namespace string, serviceName string)
return t
}
func NewNetcatTest(client *client.Client, namespace string, serviceName string) *ServerTest {
t := &ServerTest{}
func NewNetcatTest(client *client.Client, namespace string, serviceName string) *ServiceTestFixture {
t := &ServiceTestFixture{}
t.Client = client
t.Namespace = namespace
t.ServiceName = serviceName
@ -1556,7 +1556,7 @@ func NewNetcatTest(client *client.Client, namespace string, serviceName string)
}
// Build default config for a service (which can then be changed)
func (t *ServerTest) BuildServiceSpec() *api.Service {
func (t *ServiceTestFixture) BuildServiceSpec() *api.Service {
service := &api.Service{
ObjectMeta: api.ObjectMeta{
Name: t.ServiceName,
@ -1575,7 +1575,7 @@ func (t *ServerTest) BuildServiceSpec() *api.Service {
// CreateWebserverRC creates rc-backed pods with the well-known webserver
// configuration and records it for cleanup.
func (t *ServerTest) CreateWebserverRC(replicas int) *api.ReplicationController {
func (t *ServiceTestFixture) CreateWebserverRC(replicas int) *api.ReplicationController {
rcSpec := rcByNamePort(t.name, replicas, t.image, 80, api.ProtocolTCP, t.Labels)
rcAct, err := t.createRC(rcSpec)
if err != nil {
@ -1589,7 +1589,7 @@ func (t *ServerTest) CreateWebserverRC(replicas int) *api.ReplicationController
// CreateNetcatRC creates rc-backed pods with a netcat listener
// configuration and records it for cleanup.
func (t *ServerTest) CreateNetcatRC(replicas int) *api.ReplicationController {
func (t *ServiceTestFixture) CreateNetcatRC(replicas int) *api.ReplicationController {
rcSpec := rcByNamePort(t.name, replicas, t.image, 80, api.ProtocolUDP, t.Labels)
rcSpec.Spec.Template.Spec.Containers[0].Command = []string{"/bin/bash"}
rcSpec.Spec.Template.Spec.Containers[0].Args = []string{"-c", "echo SUCCESS | nc -q 0 -u -l 0.0.0.0 80"}
@ -1604,7 +1604,7 @@ func (t *ServerTest) CreateNetcatRC(replicas int) *api.ReplicationController {
}
// createRC creates a replication controller and records it for cleanup.
func (t *ServerTest) createRC(rc *api.ReplicationController) (*api.ReplicationController, error) {
func (t *ServiceTestFixture) createRC(rc *api.ReplicationController) (*api.ReplicationController, error) {
rc, err := t.Client.ReplicationControllers(t.Namespace).Create(rc)
if err == nil {
t.rcs[rc.Name] = true
@ -1613,7 +1613,7 @@ func (t *ServerTest) createRC(rc *api.ReplicationController) (*api.ReplicationCo
}
// Create a service, and record it for cleanup
func (t *ServerTest) CreateService(service *api.Service) (*api.Service, error) {
func (t *ServiceTestFixture) CreateService(service *api.Service) (*api.Service, error) {
result, err := t.Client.Services(t.Namespace).Create(service)
if err == nil {
t.services[service.Name] = true
@ -1622,7 +1622,7 @@ func (t *ServerTest) CreateService(service *api.Service) (*api.Service, error) {
}
// Delete a service, and remove it from the cleanup list
func (t *ServerTest) DeleteService(serviceName string) error {
func (t *ServiceTestFixture) DeleteService(serviceName string) error {
err := t.Client.Services(t.Namespace).Delete(serviceName)
if err == nil {
delete(t.services, serviceName)
@ -1630,7 +1630,7 @@ func (t *ServerTest) DeleteService(serviceName string) error {
return err
}
func (t *ServerTest) Cleanup() []error {
func (t *ServiceTestFixture) Cleanup() []error {
var errs []error
for rcName := range t.rcs {
By("stopping RC " + rcName + " in namespace " + t.Namespace)

View File

@ -946,8 +946,9 @@ func waitForEndpoint(c *client.Client, ns, name string) error {
return fmt.Errorf("Failed to get entpoints for %s/%s", ns, name)
}
// Context for checking pods responses by issuing GETs to them and verifying if the answer with pod name.
type podResponseChecker struct {
// Context for checking pods responses by issuing GETs to them (via the API
// proxy) and verifying that they answer with ther own pod name.
type podProxyResponseChecker struct {
c *client.Client
ns string
label labels.Selector
@ -956,8 +957,9 @@ type podResponseChecker struct {
pods *api.PodList
}
// checkAllResponses issues GETs to all pods in the context and verify they reply with pod name.
func (r podResponseChecker) checkAllResponses() (done bool, err error) {
// checkAllResponses issues GETs to all pods in the context and verify they
// reply with their own pod name.
func (r podProxyResponseChecker) checkAllResponses() (done bool, err error) {
successes := 0
options := api.ListOptions{LabelSelector: r.label}
currentPods, err := r.c.Pods(r.ns).List(options)
@ -1042,7 +1044,7 @@ func serverVersionGTE(v semver.Version, c client.ServerVersionInterface) (bool,
func podsResponding(c *client.Client, ns, name string, wantName bool, pods *api.PodList) error {
By("trying to dial each unique pod")
label := labels.SelectorFromSet(labels.Set(map[string]string{"name": name}))
return wait.PollImmediate(poll, podRespondingTimeout, podResponseChecker{c, ns, label, name, wantName, pods}.checkAllResponses)
return wait.PollImmediate(poll, podRespondingTimeout, podProxyResponseChecker{c, ns, label, name, wantName, pods}.checkAllResponses)
}
func serviceResponding(c *client.Client, ns, name string) error {