Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -35,3 +35,48 @@ func TestIsolationConversion(t *testing.T) {
|
| 35 | 35 |
}) |
| 36 | 36 |
} |
| 37 | 37 |
} |
| 38 |
+ |
|
| 39 |
+func TestContainerLabels(t *testing.T) {
|
|
| 40 |
+ c := &containerConfig{
|
|
| 41 |
+ task: &swarmapi.Task{
|
|
| 42 |
+ ID: "real-task.id", |
|
| 43 |
+ Spec: swarmapi.TaskSpec{
|
|
| 44 |
+ Runtime: &swarmapi.TaskSpec_Container{
|
|
| 45 |
+ Container: &swarmapi.ContainerSpec{
|
|
| 46 |
+ Labels: map[string]string{
|
|
| 47 |
+ "com.docker.swarm.task": "user-specified-task", |
|
| 48 |
+ "com.docker.swarm.task.id": "user-specified-task.id", |
|
| 49 |
+ "com.docker.swarm.task.name": "user-specified-task.name", |
|
| 50 |
+ "com.docker.swarm.node.id": "user-specified-node.id", |
|
| 51 |
+ "com.docker.swarm.service.id": "user-specified-service.id", |
|
| 52 |
+ "com.docker.swarm.service.name": "user-specified-service.name", |
|
| 53 |
+ "this-is-a-user-label": "this is a user label's value", |
|
| 54 |
+ }, |
|
| 55 |
+ }, |
|
| 56 |
+ }, |
|
| 57 |
+ }, |
|
| 58 |
+ ServiceID: "real-service.id", |
|
| 59 |
+ Slot: 123, |
|
| 60 |
+ NodeID: "real-node.id", |
|
| 61 |
+ Annotations: swarmapi.Annotations{
|
|
| 62 |
+ Name: "real-service.name.123.real-task.id", |
|
| 63 |
+ }, |
|
| 64 |
+ ServiceAnnotations: swarmapi.Annotations{
|
|
| 65 |
+ Name: "real-service.name", |
|
| 66 |
+ }, |
|
| 67 |
+ }, |
|
| 68 |
+ } |
|
| 69 |
+ |
|
| 70 |
+ expected := map[string]string{
|
|
| 71 |
+ "com.docker.swarm.task": "", |
|
| 72 |
+ "com.docker.swarm.task.id": "real-task.id", |
|
| 73 |
+ "com.docker.swarm.task.name": "real-service.name.123.real-task.id", |
|
| 74 |
+ "com.docker.swarm.node.id": "real-node.id", |
|
| 75 |
+ "com.docker.swarm.service.id": "real-service.id", |
|
| 76 |
+ "com.docker.swarm.service.name": "real-service.name", |
|
| 77 |
+ "this-is-a-user-label": "this is a user label's value", |
|
| 78 |
+ } |
|
| 79 |
+ |
|
| 80 |
+ labels := c.labels() |
|
| 81 |
+ assert.DeepEqual(t, expected, labels) |
|
| 82 |
+} |