Exemplo n.º 1
0
        public virtual void TestMultipleContainersLaunch()
        {
            containerManager.Start();
            IList <StartContainerRequest> list = new AList <StartContainerRequest>();
            ContainerLaunchContext        containerLaunchContext = recordFactory.NewRecordInstance <ContainerLaunchContext
                                                                                                    >();

            for (int i = 0; i < 10; i++)
            {
                ContainerId cId        = CreateContainerId(i);
                long        identifier = 0;
                if ((i & 1) == 0)
                {
                    // container with even id fail
                    identifier = ResourceManagerConstants.RmInvalidIdentifier;
                }
                else
                {
                    identifier = DummyRmIdentifier;
                }
                Token containerToken = CreateContainerToken(cId, identifier, context.GetNodeId(),
                                                            user, context.GetContainerTokenSecretManager());
                StartContainerRequest request = StartContainerRequest.NewInstance(containerLaunchContext
                                                                                  , containerToken);
                list.AddItem(request);
            }
            StartContainersRequest  requestList = StartContainersRequest.NewInstance(list);
            StartContainersResponse response    = containerManager.StartContainers(requestList);

            NUnit.Framework.Assert.AreEqual(5, response.GetSuccessfullyStartedContainers().Count
                                            );
            foreach (ContainerId id in response.GetSuccessfullyStartedContainers())
            {
                // Containers with odd id should succeed.
                NUnit.Framework.Assert.AreEqual(1, id.GetContainerId() & 1);
            }
            NUnit.Framework.Assert.AreEqual(5, response.GetFailedRequests().Count);
            foreach (KeyValuePair <ContainerId, SerializedException> entry in response.GetFailedRequests
                         ())
            {
                // Containers with even id should fail.
                NUnit.Framework.Assert.AreEqual(0, entry.Key.GetContainerId() & 1);
                NUnit.Framework.Assert.IsTrue(entry.Value.GetMessage().Contains("Container " + entry
                                                                                .Key + " rejected as it is allocated by a previous RM"));
            }
        }
Exemplo n.º 2
0
        public virtual void TestStartContainerFailureWithUnknownAuxService()
        {
            conf.SetStrings(YarnConfiguration.NmAuxServices, new string[] { "existService" });
            conf.SetClass(string.Format(YarnConfiguration.NmAuxServiceFmt, "existService"), typeof(
                              TestAuxServices.ServiceA), typeof(Org.Apache.Hadoop.Service.Service));
            containerManager.Start();
            IList <StartContainerRequest> startRequest           = new AList <StartContainerRequest>();
            ContainerLaunchContext        containerLaunchContext = recordFactory.NewRecordInstance <ContainerLaunchContext
                                                                                                    >();
            IDictionary <string, ByteBuffer> serviceData = new Dictionary <string, ByteBuffer>(
                );
            string serviceName = "non_exist_auxService";

            serviceData[serviceName] = ByteBuffer.Wrap(Sharpen.Runtime.GetBytesForString(serviceName
                                                                                         ));
            containerLaunchContext.SetServiceData(serviceData);
            ContainerId cId            = CreateContainerId(0);
            string      user           = "******";
            Token       containerToken = CreateContainerToken(cId, DummyRmIdentifier, context.GetNodeId
                                                                  (), user, context.GetContainerTokenSecretManager());
            StartContainerRequest request = StartContainerRequest.NewInstance(containerLaunchContext
                                                                              , containerToken);

            // start containers
            startRequest.AddItem(request);
            StartContainersRequest requestList = StartContainersRequest.NewInstance(startRequest
                                                                                    );
            StartContainersResponse response = containerManager.StartContainers(requestList);

            NUnit.Framework.Assert.IsTrue(response.GetFailedRequests().Count == 1);
            NUnit.Framework.Assert.IsTrue(response.GetSuccessfullyStartedContainers().Count ==
                                          0);
            NUnit.Framework.Assert.IsTrue(response.GetFailedRequests().Contains(cId));
            NUnit.Framework.Assert.IsTrue(response.GetFailedRequests()[cId].GetMessage().Contains
                                              ("The auxService:" + serviceName + " does not exist"));
        }