You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

queue_test.go 937B

Graceful Queues: Issue Indexing and Tasks (#9363) * Queue: Add generic graceful queues with settings * Queue & Setting: Add worker pool implementation * Queue: Add worker settings * Queue: Make resizing worker pools * Queue: Add name variable to queues * Queue: Add monitoring * Queue: Improve logging * Issues: Gracefulise the issues indexer Remove the old now unused specific queues * Task: Move to generic queue and gracefulise * Issues: Standardise the issues indexer queue settings * Fix test * Queue: Allow Redis to connect to unix * Prevent deadlock during early shutdown of issue indexer * Add MaxWorker settings to queues * Merge branch 'master' into graceful-queues * Update modules/indexer/issues/indexer.go Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com> * Update modules/indexer/issues/indexer.go Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com> * Update modules/queue/queue_channel.go Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com> * Update modules/queue/queue_disk.go * Update modules/queue/queue_disk_channel.go Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com> * Rename queue.Description to queue.ManagedQueue as per @guillep2k * Cancel pool workers when removed * Remove dependency on queue from setting * Update modules/queue/queue_redis.go Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com> * As per @guillep2k add mutex locks on shutdown/terminate * move unlocking out of setInternal * Add warning if number of workers < 0 * Small changes as per @guillep2k * No redis host specified not found * Clean up documentation for queues * Update docs/content/doc/advanced/config-cheat-sheet.en-us.md * Update modules/indexer/issues/indexer_test.go * Ensure that persistable channel queue is added to manager * Rename QUEUE_NAME REDIS_QUEUE_NAME * Revert "Rename QUEUE_NAME REDIS_QUEUE_NAME" This reverts commit 1f83b4fc9b9dabda186257b38c265fe7012f90df. Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com> Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: techknowlogick <matti@mdranta.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
4 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Copyright 2019 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package queue
  5. import (
  6. "encoding/json"
  7. "testing"
  8. "github.com/stretchr/testify/assert"
  9. )
  10. type testData struct {
  11. TestString string
  12. TestInt int
  13. }
  14. func TestToConfig(t *testing.T) {
  15. cfg := testData{
  16. TestString: "Config",
  17. TestInt: 10,
  18. }
  19. exemplar := testData{}
  20. cfg2I, err := toConfig(exemplar, cfg)
  21. assert.NoError(t, err)
  22. cfg2, ok := (cfg2I).(testData)
  23. assert.True(t, ok)
  24. assert.NotEqual(t, cfg2, exemplar)
  25. assert.Equal(t, &cfg, &cfg2)
  26. cfgString, err := json.Marshal(cfg)
  27. assert.NoError(t, err)
  28. cfg3I, err := toConfig(exemplar, cfgString)
  29. assert.NoError(t, err)
  30. cfg3, ok := (cfg3I).(testData)
  31. assert.True(t, ok)
  32. assert.Equal(t, cfg.TestString, cfg3.TestString)
  33. assert.Equal(t, cfg.TestInt, cfg3.TestInt)
  34. assert.NotEqual(t, cfg3, exemplar)
  35. }