Allow setting tolerations in test framework
This commit is contained in:
		@@ -1277,7 +1277,7 @@ func doPut(url, content string) (string, error) {
 | 
				
			|||||||
	return strBody, nil
 | 
						return strBody, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func reserveMemory(f *framework.Framework, id string, replicas, megabytes int, expectRunning bool, timeout time.Duration, selector map[string]string, priorityClassName string) func() error {
 | 
					func reserveMemory(f *framework.Framework, id string, replicas, megabytes int, expectRunning bool, timeout time.Duration, selector map[string]string, tolerations []v1.Toleration, priorityClassName string) func() error {
 | 
				
			||||||
	By(fmt.Sprintf("Running RC which reserves %v MB of memory", megabytes))
 | 
						By(fmt.Sprintf("Running RC which reserves %v MB of memory", megabytes))
 | 
				
			||||||
	request := int64(1024 * 1024 * megabytes / replicas)
 | 
						request := int64(1024 * 1024 * megabytes / replicas)
 | 
				
			||||||
	config := &testutils.RCConfig{
 | 
						config := &testutils.RCConfig{
 | 
				
			||||||
@@ -1290,6 +1290,7 @@ func reserveMemory(f *framework.Framework, id string, replicas, megabytes int, e
 | 
				
			|||||||
		Replicas:          replicas,
 | 
							Replicas:          replicas,
 | 
				
			||||||
		MemRequest:        request,
 | 
							MemRequest:        request,
 | 
				
			||||||
		NodeSelector:      selector,
 | 
							NodeSelector:      selector,
 | 
				
			||||||
 | 
							Tolerations:       tolerations,
 | 
				
			||||||
		PriorityClassName: priorityClassName,
 | 
							PriorityClassName: priorityClassName,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	for start := time.Now(); time.Since(start) < rcCreationRetryTimeout; time.Sleep(rcCreationRetryDelay) {
 | 
						for start := time.Now(); time.Since(start) < rcCreationRetryTimeout; time.Sleep(rcCreationRetryDelay) {
 | 
				
			||||||
@@ -1312,19 +1313,19 @@ func reserveMemory(f *framework.Framework, id string, replicas, megabytes int, e
 | 
				
			|||||||
// ReserveMemoryWithPriority creates a replication controller with pods with priority that, in summation,
 | 
					// ReserveMemoryWithPriority creates a replication controller with pods with priority that, in summation,
 | 
				
			||||||
// request the specified amount of memory.
 | 
					// request the specified amount of memory.
 | 
				
			||||||
func ReserveMemoryWithPriority(f *framework.Framework, id string, replicas, megabytes int, expectRunning bool, timeout time.Duration, priorityClassName string) func() error {
 | 
					func ReserveMemoryWithPriority(f *framework.Framework, id string, replicas, megabytes int, expectRunning bool, timeout time.Duration, priorityClassName string) func() error {
 | 
				
			||||||
	return reserveMemory(f, id, replicas, megabytes, expectRunning, timeout, nil, priorityClassName)
 | 
						return reserveMemory(f, id, replicas, megabytes, expectRunning, timeout, nil, nil, priorityClassName)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// ReserveMemoryWithSelector creates a replication controller with pods with node selector that, in summation,
 | 
					// ReserveMemoryWithSelector creates a replication controller with pods with node selector that, in summation,
 | 
				
			||||||
// request the specified amount of memory.
 | 
					// request the specified amount of memory.
 | 
				
			||||||
func ReserveMemoryWithSelector(f *framework.Framework, id string, replicas, megabytes int, expectRunning bool, timeout time.Duration, selector map[string]string) func() error {
 | 
					func ReserveMemoryWithSelectorAndTolerations(f *framework.Framework, id string, replicas, megabytes int, expectRunning bool, timeout time.Duration, selector map[string]string, tolerations []v1.Toleration) func() error {
 | 
				
			||||||
	return reserveMemory(f, id, replicas, megabytes, expectRunning, timeout, selector, "")
 | 
						return reserveMemory(f, id, replicas, megabytes, expectRunning, timeout, selector, tolerations, "")
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// ReserveMemory creates a replication controller with pods that, in summation,
 | 
					// ReserveMemory creates a replication controller with pods that, in summation,
 | 
				
			||||||
// request the specified amount of memory.
 | 
					// request the specified amount of memory.
 | 
				
			||||||
func ReserveMemory(f *framework.Framework, id string, replicas, megabytes int, expectRunning bool, timeout time.Duration) func() error {
 | 
					func ReserveMemory(f *framework.Framework, id string, replicas, megabytes int, expectRunning bool, timeout time.Duration) func() error {
 | 
				
			||||||
	return reserveMemory(f, id, replicas, megabytes, expectRunning, timeout, nil, "")
 | 
						return reserveMemory(f, id, replicas, megabytes, expectRunning, timeout, nil, nil, "")
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// WaitForClusterSizeFunc waits until the cluster size matches the given function.
 | 
					// WaitForClusterSizeFunc waits until the cluster size matches the given function.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -139,6 +139,9 @@ type RCConfig struct {
 | 
				
			|||||||
	// Node selector for pods in the RC.
 | 
						// Node selector for pods in the RC.
 | 
				
			||||||
	NodeSelector map[string]string
 | 
						NodeSelector map[string]string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// Tolerations for pods in the RC.
 | 
				
			||||||
 | 
						Tolerations []v1.Toleration
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Ports to declare in the container (map of name to containerPort).
 | 
						// Ports to declare in the container (map of name to containerPort).
 | 
				
			||||||
	Ports map[string]int
 | 
						Ports map[string]int
 | 
				
			||||||
	// Ports to declare in the container as host and container ports.
 | 
						// Ports to declare in the container as host and container ports.
 | 
				
			||||||
@@ -563,6 +566,7 @@ func (config *RCConfig) create() error {
 | 
				
			|||||||
					},
 | 
										},
 | 
				
			||||||
					DNSPolicy:                     *config.DNSPolicy,
 | 
										DNSPolicy:                     *config.DNSPolicy,
 | 
				
			||||||
					NodeSelector:                  config.NodeSelector,
 | 
										NodeSelector:                  config.NodeSelector,
 | 
				
			||||||
 | 
										Tolerations:                   config.Tolerations,
 | 
				
			||||||
					TerminationGracePeriodSeconds: &one,
 | 
										TerminationGracePeriodSeconds: &one,
 | 
				
			||||||
					PriorityClassName:             config.PriorityClassName,
 | 
										PriorityClassName:             config.PriorityClassName,
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
@@ -604,6 +608,9 @@ func (config *RCConfig) applyTo(template *v1.PodTemplateSpec) {
 | 
				
			|||||||
			template.Spec.NodeSelector[k] = v
 | 
								template.Spec.NodeSelector[k] = v
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						if config.Tolerations != nil {
 | 
				
			||||||
 | 
							template.Spec.Tolerations = append([]v1.Toleration{}, config.Tolerations...)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	if config.Ports != nil {
 | 
						if config.Ports != nil {
 | 
				
			||||||
		for k, v := range config.Ports {
 | 
							for k, v := range config.Ports {
 | 
				
			||||||
			c := &template.Spec.Containers[0]
 | 
								c := &template.Spec.Containers[0]
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user