Exemple #1
0
        public async Task Usbmuxd_CanListDevices_Async()
        {
            var config = KubernetesClientConfiguration.BuildDefaultConfig();

            if (config.Namespace == null)
            {
                config.Namespace = "default";
            }

            using (var kubernetes = new KubernetesProtocol(
                       config,
                       this.loggerFactory.CreateLogger <KubernetesProtocol>(),
                       this.loggerFactory))
                using (var client = new KubernetesClient(
                           kubernetes,
                           KubernetesOptions.Default,
                           this.output.BuildLoggerFor <KubernetesClient>(),
                           this.loggerFactory))
                {
                    // There's at least one usbmuxd pod
                    var pods = await kubernetes.ListNamespacedPodAsync(config.Namespace, labelSelector : "app.kubernetes.io/component=usbmuxd");

                    Assert.NotEmpty(pods.Items);
                    var pod = pods.Items[0];

                    // The pod is in the running state
                    pod = await client.WaitForPodRunningAsync(pod, TimeSpan.FromMinutes(2), default).ConfigureAwait(false);

                    Assert.Equal("Running", pod.Status.Phase);

                    // We can connect to port 27015 and retrieve an empty device list
                    var locator     = new KubernetesMuxerSocketLocator(kubernetes, pod, this.loggerFactory.CreateLogger <KubernetesMuxerSocketLocator>(), this.loggerFactory);
                    var muxerClient = new MuxerClient(locator, this.loggerFactory.CreateLogger <MuxerClient>(), this.loggerFactory);

                    var devices = await muxerClient.ListDevicesAsync(default).ConfigureAwait(false);
Exemple #2
0
        public async Task ConnectToMuxerAsync_UsesPortForwarding_Async()
        {
            var pod = new V1Pod()
            {
                Metadata = new V1ObjectMeta()
                {
                    NamespaceProperty = "my-namespace",
                    Name = "usbmuxd-abcd",
                },
            };

            var websocket  = Mock.Of <WebSocket>();
            var kubernetes = new Mock <IKubernetes>(MockBehavior.Strict);

            kubernetes
            .Setup(k => k.WebSocketNamespacedPodPortForwardAsync("usbmuxd-abcd", "my-namespace", new int[] { 27015 }, null, null, default))
            .ReturnsAsync(websocket);

            var locator = new KubernetesMuxerSocketLocator(kubernetes.Object, pod, NullLogger <KubernetesMuxerSocketLocator> .Instance, NullLoggerFactory.Instance);

            using (var stream = await locator.ConnectToMuxerAsync(default))