Ejemplo n.º 1
0
        public void Operator_HasCorrectLabels()
        {
            var builder = UIAutomatorOperators.BuildPodOperator(this.host.Services);

            Assert.Equal("kaponata.io/automation-name=uiautomator2", builder.Configuration.ParentLabelSelector);
            Assert.Collection(
                builder.Configuration.ChildLabels,
                c =>
            {
                Assert.Equal("app.kubernetes.io/managed-by", c.Key);
                Assert.Equal("WebDriverSession-UIAutomator2Driver-PodOperator", c.Value);
            });
        }
Ejemplo n.º 2
0
        public async Task ConnectsDevice_Async()
        {
            var builder      = UIAutomatorOperators.BuildPodOperator(this.host.Services);
            var feedbackLoop = Assert.Single(builder.FeedbackLoops);

            var session = new WebDriverSession()
            {
                Spec = new WebDriverSessionSpec()
                {
                    Capabilities = "{}",
                    DeviceHost   = "1.2.3.4",
                },
            };

            var pod = new V1Pod()
            {
                Status = new V1PodStatus()
                {
                    Phase             = "Running",
                    ContainerStatuses = new V1ContainerStatus[] { },
                },
            };

            var adbStream = new Mock <Stream>();

            this.kubernetes
            .Setup(c => c.ConnectToPodPortAsync(pod, 5037, It.IsAny <CancellationToken>()))
            .ReturnsAsync(adbStream.Object);

            var context = new ChildOperatorContext <WebDriverSession, V1Pod>(
                parent: session,
                child: pod,
                this.host.Services);

            this.adbClient
            .Setup(c => c.ConnectDeviceAsync(new DnsEndPoint("1.2.3.4", 5555), default))
            .Returns(Task.CompletedTask)
            .Verifiable();

            this.adbClient
            .Setup(c => c.GetDevicesAsync(default))
Ejemplo n.º 3
0
 public void BuildPodOperator_ValidatesArguments()
 {
     Assert.Throws <ArgumentNullException>("services", () => UIAutomatorOperators.BuildPodOperator(null));
 }
Ejemplo n.º 4
0
        public void Operator_ConfiguresPod()
        {
            var builder = UIAutomatorOperators.BuildPodOperator(this.host.Services);

            var session = new WebDriverSession()
            {
                Metadata = new V1ObjectMeta()
                {
                    Name = "my-session",
                },
            };

            var child = new V1Pod();

            builder.ChildFactory(session, child);

            Assert.Collection(
                child.Metadata.Labels,
                a =>
            {
                Assert.Equal("kaponata.io/session-name", a.Key);
                Assert.Equal("my-session", a.Value);
            });

            Assert.Collection(
                child.Spec.Containers,
                c =>
            {
                Assert.Equal("quay.io/kaponata/appium-android:1.20.2", c.Image);
                Assert.Equal("appium", c.Name);
                Assert.Collection(
                    c.Args,
                    a => Assert.Equal("/app/appium/build/lib/main.js", a));

                var port = Assert.Single(c.Ports);
                Assert.Equal(4723, port.ContainerPort);
                Assert.Equal("http", port.Name);

                Assert.Equal("/wd/hub/status", c.ReadinessProbe.HttpGet.Path);
                Assert.Equal("4723", c.ReadinessProbe.HttpGet.Port);
            },
                c =>
            {
                Assert.Equal("quay.io/kaponata/appium-android:1.20.2", c.Image);
                Assert.Equal("adb", c.Name);
                Assert.Collection(
                    c.Command,
                    a => Assert.Equal("/bin/tini", a),
                    a => Assert.Equal("--", a),
                    a => Assert.Equal("/android/platform-tools/adb", a));
                Assert.Collection(
                    c.Args,
                    a => Assert.Equal("-a", a),
                    a => Assert.Equal("-P", a),
                    a => Assert.Equal("5037", a),
                    a => Assert.Equal("server", a),
                    a => Assert.Equal("nodaemon", a));

                var port = Assert.Single(c.Ports);
                Assert.Equal(5037, port.ContainerPort);
                Assert.Equal("adb", port.Name);

                Assert.Equal("5037", c.ReadinessProbe.TcpSocket.Port);
            });
        }