Exemplo n.º 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);
Exemplo n.º 2
0
        public async Task ApiServer_Is_Running_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 operator pod
                    var pods = await kubernetes.ListNamespacedPodAsync(config.Namespace, labelSelector : "app.kubernetes.io/component=operator");

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

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

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

                    // We can connect to port 80 and fetch the status
                    using (var httpClient = new HttpClient(
                               new SocketsHttpHandler()
                    {
                        ConnectCallback = (context, cancellationToken) => client.ConnectToPodPortAsync(pod, 80, cancellationToken),
                    }))
                    {
                        httpClient.BaseAddress = new Uri("http://localhost:80/");

                        var urls = new string[] { "/", "/health/ready", "/health/alive" };

                        foreach (var url in urls)
                        {
                            var response = await httpClient.GetAsync(url).ConfigureAwait(false);

                            Assert.True(response.IsSuccessStatusCode);
                            Assert.True(response.Headers.TryGetValues("X-Kaponata-Version", out var values));
                            Assert.Equal(ThisAssembly.AssemblyInformationalVersion, Assert.Single(values));
                        }
                    }
                }
        }
Exemplo n.º 3
0
        public async Task Registry_Running_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=registry");

                    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);

                    // Try to perform a handshake
                    var httpClient = client.CreatePodHttpClient(pod, 5000);
                    httpClient.BaseAddress = new Uri($"http://{pod.Metadata.Name}:5000/v2/");

                    var response = await httpClient.GetAsync(string.Empty).ConfigureAwait(false);

                    Assert.Equal(HttpStatusCode.OK, response.StatusCode);
                    var apiVersion = Assert.Single(response.Headers.GetValues("Docker-Distribution-Api-Version"));
                    Assert.Equal("registry/2.0", apiVersion);
                }
        }
Exemplo n.º 4
0
        public async Task Guacd_PerformsHandshake_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 guacd pod
                    var pods = await kubernetes.ListNamespacedPodAsync(config.Namespace, labelSelector : "app.kubernetes.io/name=guacamole,app.kubernetes.io/component=guacd");

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

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

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

                    // Try to perform a handshake
                    using (var connection = await client.ConnectToPodPortAsync(pod, 4822, default).ConfigureAwait(false))
                    {
                        GuacdProtocol protocol = new GuacdProtocol(connection);

                        // Handshake phase
                        await protocol.SendInstructionAsync("select", new string[] { "vnc" }, default).ConfigureAwait(false);

                        var response = await protocol.ReadInstructionAsync(default);