Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add name attribute to ServicePort #2572

Merged
merged 9 commits into from
Feb 9, 2023
3 changes: 3 additions & 0 deletions experiments/experiment.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,9 @@ func (ec *experimentContext) createTemplateService(template *v1alpha1.TemplateSp
Port: port.ContainerPort,
TargetPort: intstr.FromInt(int(port.ContainerPort)),
}
if port.Name != "" {
servicePort.Name = port.Name
}
ports = append(ports, servicePort)
}
}
Expand Down
1 change: 1 addition & 0 deletions experiments/experiment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func setExperimentService(template *v1alpha1.TemplateSpec) {
template.Service = &v1alpha1.TemplateService{}
template.Template.Spec.Containers[0].Ports = []corev1.ContainerPort{
{
Name: "testport",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not needed any more

ContainerPort: 80,
Protocol: "TCP",
},
Expand Down
17 changes: 17 additions & 0 deletions test/e2e/experiment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,23 @@ func (s *ExperimentSuite) TestExperimentWithServiceAndScaleDownDelay() {
ExpectExperimentServiceCount("experiment-with-service", 0)
}

func (s *ExperimentSuite) TestExperimentWithMultiportServiceAndScaleDownDelay() {
g := s.Given()
g.ApplyManifests("@functional/experiment-with-multiport-service.yaml")
g.When().
WaitForExperimentPhase("experiment-with-multiport-service", "Running").
Sleep(time.Second*5).
Copy link
Collaborator

@zachaller zachaller Feb 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Sleep(time.Second*5).
WaitForExperimentCondition("experiment-with-service", func(ex *rov1.Experiment) bool {
return s.GetReplicaSetFromExperiment(ex, "test").Status.Replicas == 1
}, "number-of-rs-pods-meet", fixtures.E2EWaitTimeout).

I saw a few test have these long waits I would rather not slow down the e2e tests any more, I think this is what you where trying to accomplish if so could you switch to it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexef what do you think about this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the proposed change makes sense, most of the time rs gets ready in less than 5 seconds

Then().
ExpectExperimentTemplateReplicaSetNumReplicas("experiment-with-multiport-service", "test", 1).
ExpectExperimentServiceCount("experiment-with-multiport-service", 1).
When().
WaitForExperimentPhase("experiment-with-multiport-service", "Successful").
Sleep(time.Second*15).
Copy link
Collaborator

@zachaller zachaller Feb 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Sleep(time.Second*15).
WaitForExperimentCondition("experiment-with-service", func(ex *rov1.Experiment) bool {
return s.GetReplicaSetFromExperiment(ex, "test").Status.Replicas == 0
}, "number-of-rs-pods-meet", fixtures.E2EWaitTimeout).

I saw a few test have these long waits I would rather not slow down the e2e tests any more, I think this is what you where trying to accomplish if so could you switch to it?

Then().
ExpectExperimentTemplateReplicaSetNumReplicas("experiment-with-multiport-service", "test", 0).
ExpectExperimentServiceCount("experiment-with-multiport-service", 0)
}

func (s *ExperimentSuite) TestExperimentWithDryRunMetrics() {
g := s.Given()
g.ApplyManifests("@functional/experiment-dry-run-analysis.yaml")
Expand Down
37 changes: 37 additions & 0 deletions test/e2e/functional/experiment-with-multiport-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
apiVersion: argoproj.io/v1alpha1
kind: Experiment
metadata:
name: experiment-with-multiport-service
spec:
duration: 10s
scaleDownDelaySeconds: 5
# List of pod template specs to run in the experiment as ReplicaSets
templates:
- name: test
replicas: 1
service: {}
selector:
matchLabels:
app: experiment-with-multiport-service
template:
metadata:
labels:
app: experiment-with-multiport-service
spec:
containers:
- name: experiment-with-multiport-service
image: nginx:1.19-alpine
resources:
requests:
memory: 16Mi
cpu: 1m
ports:
- name: testport1
protocol: TCP
containerPort: 8080
- name: testport2
protocol: TCP
containerPort: 8081
- name: testport3
protocol: TCP
containerPort: 8082