Skip to content

Commit

Permalink
resolving partionally comments in pr
Browse files Browse the repository at this point in the history
  • Loading branch information
miledxz authored and MileTildeloop committed Jul 4, 2024
1 parent 2d3eec1 commit da784fc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
7 changes: 3 additions & 4 deletions internal/mode/static/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,7 @@ const (
clusterTimeout = 10 * time.Second
)

var (
scheme = runtime.NewScheme()
processHandler = &ngxruntime.ProcessHandlerImpl{}
)
var scheme = runtime.NewScheme()

func init() {
utilruntime.Must(gatewayv1beta1.Install(scheme))
Expand Down Expand Up @@ -147,6 +144,8 @@ func StartManager(cfg config.Config) error {
return fmt.Errorf("cannot clear NGINX configuration folders: %w", err)
}

var processHandler = &ngxruntime.ProcessHandlerImpl{}

// Ensure NGINX is running before registering metrics & starting the manager.
if err := processHandler.EnsureNginxRunning(ctx); err != nil {
return fmt.Errorf("NGINX is not running: %w", err)
Expand Down
10 changes: 6 additions & 4 deletions internal/mode/static/nginx/runtime/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ var _ = Describe("NGINX Runtime Manager", func() {
})

When("MetricsCollector is nil", func() {
It("NGINX configuration reload is successful", func() {
It("Is successful", func() {
Expect(manager.Reload(context.Background(), 1)).To(Succeed())

Expect(process.FindMainProcessCallCount()).To(Equal(1))
Expand All @@ -65,8 +65,8 @@ var _ = Describe("NGINX Runtime Manager", func() {
})
})

When("NGINX configuration reload is not successful", func() {
It("should panic if MetricsCollector not enabled", func() {
When("MetricsCollector is nil", func() {
It("panics", func() {
metrics = nil
manager = runtime.NewManagerImpl(ngxPlusClient, metrics, zap.New(), process, verifyClient)

Expand All @@ -77,8 +77,10 @@ var _ = Describe("NGINX Runtime Manager", func() {
Expect(reload).To(Panic())
Expect(err).ToNot(HaveOccurred())
})
})

It("should panic if VerifyClient not enabled", func() {
When("VerifyClient is nil", func() {
It("panics", func() {
metrics = &runtimefakes.FakeMetricsCollector{}
verifyClient = nil
manager = runtime.NewManagerImpl(ngxPlusClient, metrics, zap.New(), process, verifyClient)
Expand Down

0 comments on commit da784fc

Please sign in to comment.