TestServiceListServiceStatus tests that the ServiceStatus struct is correctly propagated. For older API versions, the ServiceStatus is calculated locally, based on the tasks that are present in the swarm, and the nodes that they are running on. If the list command is ran with `--quiet` option, no at
(t *testing.T)
| 43 | // propagate the ServiceStatus struct if not present, and it should be set to an |
| 44 | // empty struct. |
| 45 | func TestServiceListServiceStatus(t *testing.T) { |
| 46 | type listResponse struct { |
| 47 | ID string |
| 48 | Replicas string |
| 49 | } |
| 50 | |
| 51 | type testCase struct { |
| 52 | doc string |
| 53 | withQuiet bool |
| 54 | opts clusterOpts |
| 55 | cluster *cluster |
| 56 | expected []listResponse |
| 57 | } |
| 58 | |
| 59 | tests := []testCase{ |
| 60 | { |
| 61 | // Getting no nodes, services or tasks back from the daemon should |
| 62 | // not cause any problems |
| 63 | doc: "empty cluster", |
| 64 | cluster: &cluster{}, // force an empty cluster |
| 65 | expected: []listResponse{}, |
| 66 | }, |
| 67 | { |
| 68 | // Services are running, but no active nodes were found. On API v1.41 |
| 69 | // and up, the ServiceStatus is sent by the daemon, so this should not |
| 70 | // affect the results. |
| 71 | doc: "no active nodes", |
| 72 | opts: clusterOpts{ |
| 73 | activeNodes: 0, |
| 74 | runningTasks: 2, |
| 75 | desiredTasks: 4, |
| 76 | }, |
| 77 | expected: []listResponse{ |
| 78 | {ID: "replicated", Replicas: "2/4"}, |
| 79 | {ID: "global", Replicas: "0/0"}, |
| 80 | {ID: "none-id", Replicas: "0/0"}, |
| 81 | }, |
| 82 | }, |
| 83 | { |
| 84 | doc: "active nodes, 1 task running", |
| 85 | opts: clusterOpts{ |
| 86 | activeNodes: 3, |
| 87 | runningTasks: 1, |
| 88 | desiredTasks: 2, |
| 89 | }, |
| 90 | expected: []listResponse{ |
| 91 | {ID: "replicated", Replicas: "1/2"}, |
| 92 | {ID: "global", Replicas: "1/3"}, |
| 93 | {ID: "none-id", Replicas: "0/0"}, |
| 94 | }, |
| 95 | }, |
| 96 | { |
| 97 | doc: "active nodes, all tasks running", |
| 98 | opts: clusterOpts{ |
| 99 | activeNodes: 3, |
| 100 | runningTasks: 3, |
| 101 | desiredTasks: 3, |
| 102 | }, |
nothing calls this directly
no test coverage detected
searching dependent graphs…