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

add e2e testing. #121

Merged
merged 4 commits into from
Jun 20, 2024
Merged

add e2e testing. #121

merged 4 commits into from
Jun 20, 2024

Conversation

morvencao
Copy link
Contributor

@morvencao morvencao commented Jun 11, 2024

  1. Add spec resync testing for agent restart
  2. Add status resync testing for server restart
  3. Add gRPC API testing
  4. Enable MTLS auth for MQTT broker.
  5. Add resync test after reconnecting for Maestro agent.

@morvencao morvencao force-pushed the br_e2e_test branch 6 times, most recently from 3a1e6e0 to f70ca5d Compare June 13, 2024 15:08
@morvencao
Copy link
Contributor Author

morvencao commented Jun 13, 2024

/assign @qiujian16 @clyang82 @skeeey

@morvencao morvencao force-pushed the br_e2e_test branch 5 times, most recently from 9faf013 to 8ebc1d1 Compare June 15, 2024 05:00
tar -xzvf step_0.26.2_amd64.tar.gz
chmod +x ./step_0.26.2/bin/step
sudo mv ./step_0.26.2/bin/step /usr/local/bin/step
rm -rf ./step_0.26.2_amd64.tar.gz ./step_0.26.2
Copy link
Contributor

Choose a reason for hiding this comment

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

It is worth extracting a version variable to define 0.26.2.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

@morvencao morvencao force-pushed the br_e2e_test branch 4 times, most recently from 6ecf1a7 to a46b394 Compare June 17, 2024 05:32

# create secret containing the client certs to mqtt broker and patch the maestro deployment
kubectl create secret generic maestro-server-certs -n $namespace --from-file=ca.crt=${certDir}/ca.crt --from-file=client.crt=${certDir}/server-client.crt --from-file=client.key=${certDir}/server-client.key
kubectl create secret generic maestro-server-invalid-certs -n $namespace --from-file=ca.crt=${certDir}/ca.crt --from-file=client.crt=${certDir}/invalid-client.crt --from-file=client.key=${certDir}/invalid-client.key
Copy link
Contributor

Choose a reason for hiding this comment

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

why do you need maestro-server-invalid-certs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This certificate will be expired in 1 minute, it is used to replace the client certificate, to simulate the case:

  1. the MQTT client certificate is expired, the connection to broker will be broken
  2. then we replace the expired certificate with the valid certificate, after that the maestro agent should be able to reload the valid certificate and then resync the resources during disconnected time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is mainly used to test:

  1. agent reload certificate.
  2. agent resync spec after reconnect to broker.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

as we discussed, removed this for now.

@@ -70,4 +77,6 @@ func addFlags(fs *pflag.FlagSet) {
commonOptions.SpokeClusterName, "Name of the consumer")
fs.BoolVar(&commonOptions.CommoOpts.CmdConfig.DisableLeaderElection, "disable-leader-election",
true, "Disable leader election.")
fs.DurationVar(&certRefreshDuration, "cert-refresh-duration",
certRefreshDuration, "Client certificate refresh duration for MQTT broker.")
Copy link
Contributor

Choose a reason for hiding this comment

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

add default value 5 minutes in the message.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

looks like cobra flag will add this, if you try --help, you will see:

# go run ./cmd/maestro/main.go agent --help
Start the Maestro Agent

Usage:
  maestro agent [flags]

Flags:
      --add-dir-header                                       If true, adds the file directory to the header of the log messages
      --alsologtostderr                                      log to standard error as well as files (no effect when -logtostderr=true)
      --appliedmanifestwork-eviction-grace-period duration   Grace period for appliedmanifestwork eviction (default 1h0m0s)
      --cert-refresh-duration duration                       Client certificate refresh duration for MQTT broker. (default 5m0s)

}

return fmt.Errorf("maestro-agent logs does not have 'expired certificate'")
}, 3*time.Minute, 3*time.Second).ShouldNot(HaveOccurred())
Copy link
Contributor

Choose a reason for hiding this comment

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

will not refresh the certificates if they are expired?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you mean deploying a cert-manager for certificate rotation?

Copy link
Contributor

Choose a reason for hiding this comment

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

no. i mean the current behaviour. we do not refresh the certificate. correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we don't refresh the certificate, only replace 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.

as we discussed, removed the certificate test for now.

@@ -175,13 +193,13 @@ var _ = Describe("Resources", Ordered, Label("e2e-tests-resources"), func() {
Consistently(func() error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Here is using Consistently. Consistently blocks when called for a specified duration. During that duration Consistently repeatedly polls its matcher and ensures that it is satisfied. If the matcher is consistently satisfied, then Consistently will pass. Otherwise Consistently will fail.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, I updated the Consistently check to avoid intermittent error to break the check when getting nginx deployment.

}, 30*time.Second, 2*time.Second).ShouldNot(HaveOccurred())
})

It("start maestro agent", func() {
Copy link
Contributor

Choose a reason for hiding this comment

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

why do you need to shutdown maestro agent repeatedly? to trigger re-sync?

Copy link
Contributor

Choose a reason for hiding this comment

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

if so, how about use Consistently?

Copy link
Contributor Author

@morvencao morvencao Jun 17, 2024

Choose a reason for hiding this comment

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

Updated this to only restart agent once, to resync spec for created resource, updated resource and deleted resource.

@morvencao morvencao force-pushed the br_e2e_test branch 5 times, most recently from 75c704a to 768daa5 Compare June 19, 2024 02:17
@morvencao morvencao force-pushed the br_e2e_test branch 4 times, most recently from 8f38127 to d48b2a6 Compare June 19, 2024 09:49
@morvencao morvencao force-pushed the br_e2e_test branch 3 times, most recently from e3339e1 to fc3620a Compare June 20, 2024 03:34
@morvencao
Copy link
Contributor Author

morvencao commented Jun 20, 2024

@clyang82 Another look?

@clyang82
Copy link
Contributor

/ok-to-test

@clyang82
Copy link
Contributor

Status resync Resource resync resource status after maestro server reconnects ensure the resource status is resynced [e2e-tests-status-resync]
/home/runner/work/maestro/maestro/test/e2e/pkg/status_resync_test.go:336
• [117.135 seconds]

Resources Resource CreateOnly UpdateStrategy Tests patch the nginx resource [e2e-tests-resources]
/home/runner/work/maestro/maestro/test/e2e/pkg/resources_test.go:184
• [30.017 seconds]

Spec resync Resource resync resource spec after maestro agent restarts ensure the nginx-1 resource is not updated [e2e-tests-spec-resync]
/home/runner/work/maestro/maestro/test/e2e/pkg/spec_resync_test.go:108
• [30.001 seconds]

Spec resync Resource resync resource spec after maestro agent restarts ensure the nginx-2 resource is not deleted [e2e-tests-spec-resync]
/home/runner/work/maestro/maestro/test/e2e/pkg/spec_resync_test.go:130
• [30.001 seconds]

Spec resync Resource resync resource spec after maestro agent restarts ensure the nginx-3 resource is not created [e2e-tests-spec-resync]
/home/runner/work/maestro/maestro/test/e2e/pkg/spec_resync_test.go:155
• [30.001 seconds]

Spec resync Resource resync resource spec after maestro agent reconnects ensure the nginx-1 resource is not updated [e2e-tests-spec-resync]
/home/runner/work/maestro/maestro/test/e2e/pkg/spec_resync_test.go:402
• [30.001 seconds]
------------------------------
Spec resync Resource resync resource spec after maestro agent reconnects ensure the nginx-2 resource is not deleted [e2e-tests-spec-resync]
/home/runner/work/maestro/maestro/test/e2e/pkg/spec_resync_test.go:424
• [30.000 seconds]
------------------------------
Spec resync Resource resync resource spec after maestro agent reconnects ensure the nginx-3 resource is not created [e2e-tests-spec-resync]
/home/runner/work/maestro/maestro/test/e2e/pkg/spec_resync_test.go:449
• [30.001 seconds]

I listed some cases that take a longer time to complete. Is this desired? Can the time be reduced?

@morvencao morvencao force-pushed the br_e2e_test branch 5 times, most recently from eec9217 to 1cfc614 Compare June 20, 2024 10:55
Copy link
Contributor

@clyang82 clyang82 left a comment

Choose a reason for hiding this comment

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

LGTM

@clyang82 clyang82 merged commit 85524b1 into openshift-online:main Jun 20, 2024
5 checks passed
@morvencao morvencao deleted the br_e2e_test branch June 20, 2024 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants