...

Text file src/github.com/docker/distribution/contrib/docker-integration/plugins.bats

Documentation: github.com/docker/distribution/contrib/docker-integration

     1#!/usr/bin/env bats
     2
     3# This tests pushing and pulling plugins
     4
     5load helpers
     6
     7user="testuser"
     8password="testpassword"
     9base="hello-world"
    10
    11#TODO: Create plugin image
    12function create_plugin() {
    13	plugindir=$(mktemp -d)
    14
    15	cat - > $plugindir/config.json <<CONFIGJSON
    16{
    17	"manifestVersion": "v0",
    18	"description": "A test plugin for integration tests",
    19	"entrypoint": ["/usr/bin/ncat", "-l", "-U", "//run/docker/plugins/plugin.sock"],
    20	"interface" : {
    21		"types": ["docker.volumedriver/1.0"],
    22		"socket": "plugin.sock"
    23	}
    24}
    25CONFIGJSON
    26
    27	cid=$(docker create dmcgowan/ncat:latest /bin/sh)
    28
    29	mkdir $plugindir/rootfs
    30
    31	docker export $cid | tar -x -C $plugindir/rootfs
    32
    33	docker rm $cid
    34
    35	daemontmp=$(docker exec dockerdaemon mktemp -d)
    36
    37	tar -c -C $plugindir . | docker exec -i dockerdaemon tar -x -C $daemontmp
    38
    39	docker exec dockerdaemon docker plugin create $1 $daemontmp
    40
    41	docker exec dockerdaemon rm -rf $daemontmp
    42
    43	rm -rf $plugindir
    44}
    45
    46@test "Test plugin push and pull" {
    47	version_check docker "$GOLEM_DIND_VERSION" "1.13.0-rc3"
    48	version_check docker "$GOLEM_DISTRIBUTION_VERSION" "2.6.0"
    49
    50	login_oauth localregistry:5558
    51	image="localregistry:5558/testuser/plugin1"
    52
    53	create_plugin $image
    54
    55	run docker_t plugin push $image
    56	echo $output
    57	[ "$status" -eq 0 ]
    58
    59	docker_t plugin rm $image
    60
    61	docker_t plugin install --grant-all-permissions $image
    62}
    63
    64@test "Test plugin push and failed image pull" {
    65	version_check docker "$GOLEM_DIND_VERSION" "1.13.0-rc3"
    66	version_check docker "$GOLEM_DISTRIBUTION_VERSION" "2.6.0"
    67
    68
    69	login_oauth localregistry:5558
    70	image="localregistry:5558/testuser/plugin-not-image"
    71
    72	create_plugin $image
    73
    74	run docker_t plugin push $image
    75	echo $output
    76	[ "$status" -eq 0 ]
    77
    78	docker_t plugin rm $image
    79
    80	run docker_t pull $image
    81
    82	[ "$status" -ne 0 ]
    83}
    84
    85@test "Test image push and failed plugin pull" {
    86	version_check docker "$GOLEM_DIND_VERSION" "1.13.0-rc3"
    87	version_check docker "$GOLEM_DISTRIBUTION_VERSION" "2.6.0"
    88
    89	login_oauth localregistry:5558
    90	image="localregistry:5558/testuser/image-not-plugin"
    91
    92	build $image "$base:latest"
    93
    94	run docker_t push $image
    95	echo $output
    96	[ "$status" -eq 0 ]
    97
    98	docker_t rmi $image
    99
   100	run docker_t plugin install --grant-all-permissions $image
   101
   102	[ "$status" -ne 0 ]
   103}

View as plain text