Beispiel #1
0
        public async Task CreateTaskWithRangeFromFakeHandlerReturnTheGoodUuid()
        {
            CreateConfiguration config = new CreateConfiguration(ConfigType.Task, CommandApi.Create);

            config.Range = "1-2";
            await LaunchCreateTaskFromFakeHandler(config);
        }
Beispiel #2
0
        public async Task CreateTaskWithPoolFromFakeHandlerReturnTheGoodUuid()
        {
            CreateConfiguration config = new CreateConfiguration(ConfigType.Task, CommandApi.Create);

            config.PoolUuidOrShortname = "f78fdff8-0000-0000-0000-d9cd4e185ece";
            config.InstanceCount       = 1;
            await LaunchCreateTaskFromFakeHandler(config);
        }
Beispiel #3
0
        public async Task CreateTaskWithJobRangeFromFakeHandlerReturnTheGoodUuid()
        {
            CreateConfiguration config = new CreateConfiguration(ConfigType.Task, CommandApi.Create);

            config.JobUuidOrShortname = "f78fdff8-0000-0000-0000-d9cd4e185ece";
            config.Range = "1-2";
            await LaunchCreateTaskFromFakeHandler(config);
        }
Beispiel #4
0
        public async Task CreateTaskFromFakeHandlerReturnTheGoodUuid()
        {
            CreateConfiguration config = new CreateConfiguration(ConfigType.Task, CommandApi.Create);

            config.WaitForPoolResourcesSynchronization = true;
            config.InstanceCount = 1;
            await LaunchCreateTaskFromFakeHandler(config);
        }
Beispiel #5
0
        public void CheckJobInvalidMissingName()
        {
            IConfiguration config = new CreateConfiguration(ConfigType.Job, CommandApi.Create)
            {
                Type = ConfigType.Job
            };

            Assert.IsFalse(CommandLineParser.CheckJob(config));
        }
Beispiel #6
0
        public void CheckJobValidArgumentsList()
        {
            IConfiguration config = new CreateConfiguration(ConfigType.Job, CommandApi.Create)
            {
                Type = ConfigType.Job, Name = "bob"
            };

            Assert.IsTrue(CommandLineParser.CheckJob(config));
        }
Beispiel #7
0
        public void CheckTaskInvalidMissingName()
        {
            IConfiguration config = new CreateConfiguration(ConfigType.Task, CommandApi.Create)
            {
                Type = ConfigType.Task, Profile = "Bob", InstanceCount = 2
            };

            Assert.IsFalse(CommandLineParser.CheckTask(config));
        }
Beispiel #8
0
        public void CheckPoolCreateConfigurationValidArgumentsList()
        {
            IConfiguration config = new CreateConfiguration(ConfigType.Pool, CommandApi.Create)
            {
                Type = ConfigType.Pool, Name = "bob", Profile = "Bob", InstanceCount = 2
            };

            Assert.IsTrue(CommandLineParser.CheckPool(config));
        }
Beispiel #9
0
        public void CheckPoolInvalidMissingProfile()
        {
            IConfiguration config = new CreateConfiguration(ConfigType.Pool, CommandApi.Create)
            {
                Type = ConfigType.Pool, Name = "bob", InstanceCount = 2
            };

            Assert.IsFalse(CommandLineParser.CheckPool(config));
        }
Beispiel #10
0
        public async Task CreateTask_WithMaxRetriesPerInstance_PrintsSomethingOnStdout()
        {
            CreateConfiguration config = new CreateConfiguration(ConfigType.Task, CommandApi.Create);

            config.InstanceCount         = 1;
            config.SnapshotPeriodicSec   = 5;
            config.MaxRetriesPerInstance = 19;
            await LaunchCreateTaskFromFakeHandler(config);
        }
Beispiel #11
0
        public void CheckTaskInvalidInstanceNodesAdRangeSetTogether()
        {
            IConfiguration config = new CreateConfiguration(ConfigType.Task, CommandApi.Create)
            {
                Type = ConfigType.Task, Name = "bob", Profile = "Bob", Range = "2", InstanceCount = 2
            };

            Assert.IsFalse(CommandLineParser.CheckTask(config));
        }
Beispiel #12
0
        public void CheckTaskInvalidMissingInstanceNodesOrRange()
        {
            IConfiguration config = new CreateConfiguration(ConfigType.Task, CommandApi.Create)
            {
                Type = ConfigType.Task, Name = "bob", Profile = "Bob"
            };

            Assert.IsFalse(CommandLineParser.CheckTask(config));
        }
Beispiel #13
0
        public async Task CreateTaskWithWhitelistBlacklistAndPeriodicFromFakeHandlerReturnTheGoodUuid()
        {
            CreateConfiguration config = new CreateConfiguration(ConfigType.Task, CommandApi.Create);

            config.InstanceCount       = 1;
            config.SnapshotPeriodicSec = 5;
            config.Whitelist           = "white_a";
            config.Blacklist           = "black_a";
            await LaunchCreateTaskFromFakeHandler(config);
        }
Beispiel #14
0
        public void CreatejobCheckWallTime(string walltime, int day, int hour, int minute, int second)
        {
            TimeSpan          waitValue = new TimeSpan(day, hour, minute, second);
            CommandLineParser parser    = new CommandLineParser(new OptionConverter(new JsonDeserializer()), new CommandLine.Parser(), new ParserUsage(), new VerbFormater());

            string[]            argv    = new string[] { "job", "create", "--name", "name", "--pool", "poolUuid", "--shortname", "shortname", "--max-wall-time", walltime };
            CreateConfiguration confset = parser.Parse(argv) as CreateConfiguration;

            Assert.AreEqual(confset.MaximumWallTime, waitValue);
        }
Beispiel #15
0
        public void CreatePoolCheckTestParsArg()
        {
            string name      = "NAME";
            string shortname = "SHORT";
            string instance  = "42";
            string profile   = "PROFILE";

            string[]          tags              = new[] { "TAG1", "TAG2", "TAG3" };
            string[]          constants         = new[] { "CONSTANT" };
            string[]          constraints       = new[] { "CONSTRAINTS" };
            string[]          argv              = null;
            var               commandLineParser = new CommandLine.Parser();
            CommandLineParser parser            = new CommandLineParser(new OptionConverter(new JsonDeserializer()), commandLineParser, new ParserUsage(), new VerbFormater());
            IConfiguration    iConfSet          = null;

            argv     = new string[] { "pool", "create", "--name", name, "--shortname", shortname, "--instanceNodes", instance, "--profile", profile, "--tags", tags[0], tags[1], tags[2], "--constants", constants[0], "--constraints", constraints[0], "--tasks-wait-for-synchronization", "false" };
            argv     = new string[] { "pool", "create", "--name=" + name, "--shortname=" + shortname, "--instanceNodes=" + instance, "--profile=" + profile, "--tags=" + tags[0], tags[1], tags[2], "--constants=" + constants[0], "--constraints=" + constraints[0], "--tasks-wait-for-synchronization", "true" };
            iConfSet = parser.Parse(argv);

            if (!(iConfSet is CreateConfiguration))
            {
                throw new Exception("return value is not CreateConfiguration ");
            }

            CreateConfiguration confset = (CreateConfiguration)iConfSet;

            Assert.AreEqual(confset.Type, ConfigType.Pool);
            Assert.AreEqual(confset.Name, name);
            Assert.AreEqual(confset.Shortname, shortname);
            Assert.AreEqual(confset.Profile, profile);
            CollectionAssert.AreEqual(confset.Tags, tags);
            CollectionAssert.AreEqual(confset.Constants, constants);
            CollectionAssert.AreEqual(confset.Constraints, constraints);
            Assert.AreEqual(confset.InstanceCount, 42);
            Assert.AreEqual(confset.TasksDefaultWaitForPoolResourcesSynchronization, true);

            argv     = new string[] { "pool", "create", "-n", name, "-s", shortname, "-i", instance, "-p", profile, "-t", tags[0], tags[1], tags[2], "-c", constants[0] };
            iConfSet = parser.Parse(argv);

            if (!(iConfSet is CreateConfiguration))
            {
                throw new Exception("return value is not CreateConfiguration ");
            }

            confset = (CreateConfiguration)iConfSet;
            Assert.AreEqual(confset.Type, ConfigType.Pool);
            Assert.AreEqual(confset.Name, name);
            Assert.AreEqual(confset.Shortname, shortname);
            Assert.AreEqual(confset.Profile, profile);
            CollectionAssert.AreEqual(confset.Tags, tags);
            CollectionAssert.AreEqual(confset.Constants, constants);
            Assert.AreEqual(confset.InstanceCount, 42);
            Assert.AreEqual(confset.TasksDefaultWaitForPoolResourcesSynchronization, false);
            commandLineParser.Dispose();
        }
Beispiel #16
0
        public async Task LaunchCreateTaskFromFakeHandler(CreateConfiguration config)
        {
            FakeHTTP.ReturnMessage = HttpTaskObject.TaskResponseBody;
            var    createTask      = new ApiObjectCreator.CreateNewTask(Tool);
            var    commandLauncher = new CreateCommandLauncher(createTask, FormatTable, FakeApi);
            string ret             = await commandLauncher.RunAndPrintCommandAsync(config, FalsePrinter);

            string expected = "Uuid : f78fdff8-7081-46e1-bb2f-d9cd4e185ece" + Environment.NewLine + "Message : New task created, state : Success" + Environment.NewLine;

            Assert.AreEqual(ret, expected);
        }
Beispiel #17
0
        public void CreatejobCheckWallTimeWithFullDate(int secondToAdd)
        {
            string            walltime = DateTime.Now.AddSeconds(secondToAdd).ToString("yyyy/MM/dd HH:mm:ss");
            CommandLineParser parser   = new CommandLineParser(new OptionConverter(new JsonDeserializer()), new CommandLine.Parser(), new ParserUsage(), new VerbFormater());

            string[]            argv      = new string[] { "job", "create", "--name", "name", "--pool", "poolUuid", "--shortname", "shortname", "--max-wall-time", walltime };
            CreateConfiguration confset   = parser.Parse(argv) as CreateConfiguration;
            TimeSpan            waitValue = new TimeSpan(0, 0, 0, secondToAdd);

            Assert.That(confset.MaximumWallTime.Value, Is.EqualTo(waitValue).Within(TimeSpan.FromSeconds(10)));
        }
Beispiel #18
0
        public async Task CreateTaskWithDependenciesFromFakeHandlerReturnTheGoodUuid()
        {
            CreateConfiguration config = new CreateConfiguration(ConfigType.Task, CommandApi.Create);

            config.Range = "1-2";
            config.JobUuidOrShortname = "f78fdff8-0000-0000-0000-d9cd4e185ece";
            config.Dependents         = new List <string>()
            {
                "f78fdff8-0000-0000-0000-d9cd4e185ece", "f78fdff8-0000-0000-0000-d9cd4e185ece"
            };
            await LaunchCreateTaskFromFakeHandler(config);
        }
Beispiel #19
0
        public async Task CreateJobFromFakeHandlerReturnTheGoodUuid()
        {
            FakeHTTP.ReturnMessage = HttpJobObject.JobResponseBody;
            CreateConfiguration config = new CreateConfiguration(ConfigType.Job, CommandApi.Create);
            var    createJob           = new ApiObjectCreator.CreateNewJob(Tool);
            var    commandLauncher     = new CreateCommandLauncher(createJob, FormatTable, FakeApi);
            string ret = await commandLauncher.RunAndPrintCommandAsync(config, FalsePrinter);

            string expected = "Uuid : f78fdff8-7081-46e1-bb2f-d9cd4e185ece" + Environment.NewLine + "Message : New job created, state : Success" + Environment.NewLine;

            Assert.AreEqual(ret, expected);
        }
Beispiel #20
0
        public void CreatejobCheckWallTimeWithPartMDate(int dayToAdd)
        {
            string            walltime  = DateTime.Now.AddDays(dayToAdd).ToString("yyyy/MM/dd");
            TimeSpan          waitValue = new TimeSpan(dayToAdd, 0, 0, 0) - DateTime.Now.TimeOfDay;
            CommandLineParser parser    = new CommandLineParser(new OptionConverter(new JsonDeserializer()), new CommandLine.Parser(), new ParserUsage(), new VerbFormater());

            Console.WriteLine(walltime);
            Console.WriteLine(waitValue.TotalDays);
            string[]            argv    = new string[] { "job", "create", "--name", "name", "--pool", "poolUuid", "--shortname", "shortname", "--max-wall-time", walltime };
            CreateConfiguration confset = parser.Parse(argv) as CreateConfiguration;

            Console.WriteLine(confset.MaximumWallTime.Value.TotalDays);
            Assert.That(confset.MaximumWallTime.Value, Is.EqualTo(waitValue).Within(TimeSpan.FromSeconds(10)));
        }
Beispiel #21
0
        public void CreatejobCheckWallTimeWithOnlyMinutes(int minuteToAdd)
        {
            string            walltime  = "0.0:" + minuteToAdd.ToString();
            TimeSpan          waitValue = new TimeSpan(0, 0, minuteToAdd, 0);
            CommandLineParser parser    = new CommandLineParser(new OptionConverter(new JsonDeserializer()), new CommandLine.Parser(), new ParserUsage(), new VerbFormater());

            Console.WriteLine(walltime);
            Console.WriteLine(waitValue.TotalMinutes);
            string[]            argv    = new string[] { "job", "create", "--name", "name", "--pool", "poolUuid", "--shortname", "shortname", "--max-wall-time", walltime };
            CreateConfiguration confset = parser.Parse(argv) as CreateConfiguration;

            Console.WriteLine(confset.MaximumWallTime.Value.TotalMinutes);
            Assert.AreEqual(confset.MaximumWallTime.Value.TotalMinutes, waitValue.TotalMinutes);
        }
Beispiel #22
0
        public void CreateJobSimpleTestParsArg()
        {
            string[]          argv = new string[] { "job", "create", "-n", "name" };
            var               commandLineParser = new CommandLine.Parser();
            CommandLineParser parser            = new CommandLineParser(new OptionConverter(new JsonDeserializer()), commandLineParser, new ParserUsage(), new VerbFormater());
            IConfiguration    iConfSet          = parser.Parse(argv);

            if (!(iConfSet is CreateConfiguration))
            {
                throw new Exception("return value is not CreateConfiguration ");
            }

            CreateConfiguration confset = (CreateConfiguration)iConfSet;

            Assert.AreEqual(confset.Type, ConfigType.Job);
            commandLineParser.Dispose();
        }
Beispiel #23
0
        public static async Task Returns_short_lead_time_spaces_count()
        {
            var configuration = CreateConfiguration.With(shortLeadTimeSpaces: 2);

            var activeDates = new[] { 15.February(2021) };

            var controller = new ReservationsController(
                CreateConfigurationRepository.WithConfiguration(configuration),
                CreateDateCalculator.WithActiveDates(activeDates),
                CreateReservationRepository.WithReservations(activeDates, new List <Reservation>()),
                CreateUserRepository.WithUsers(new List <User>()));

            var result = await controller.GetAsync();

            var resultValue = GetResultValue <ReservationsResponse>(result);

            Assert.Equal(2, resultValue.ShortLeadTimeSpaces);
        }
Beispiel #24
0
        public async Task CreateTaskWithConstantAndContraintFromFakeHandlerReturnTheGoodUuid()
        {
            CreateConfiguration config = new CreateConfiguration(ConfigType.Task, CommandApi.Create);

            config.Range = "1-2";
            config.Tags  = new List <string>()
            {
                "tag1", "tag2"
            };
            config.Constants = new List <string>()
            {
                "key1=val1", "key2=val2"
            };
            config.Constraints = new List <string>()
            {
                "key1=val1", "key2=val2"
            };
            await LaunchCreateTaskFromFakeHandler(config);
        }
Beispiel #25
0
        public void CreatejobCheckTestParsArg()
        {
            string poolUuid  = "PoolUUID";
            string name      = "NAME";
            string shortname = "SHORT";

            string[]          argv = null;
            var               commandLineParser = new CommandLine.Parser();
            CommandLineParser parser            = new CommandLineParser(new OptionConverter(new JsonDeserializer()), commandLineParser, new ParserUsage(), new VerbFormater());
            IConfiguration    iConfSet          = null;

            argv     = new string[] { "job", "create", "--name", name, "--pool", poolUuid, "--shortname", shortname };
            iConfSet = parser.Parse(argv);

            if (!(iConfSet is CreateConfiguration))
            {
                throw new Exception("return value is not CreateConfiguration ");
            }

            CreateConfiguration confset = (CreateConfiguration)iConfSet;

            Assert.AreEqual(confset.Type, ConfigType.Job);
            Assert.AreEqual(confset.Name, name);
            Assert.AreEqual(confset.Shortname, shortname);
            Assert.AreEqual(confset.PoolUuid, poolUuid);

            argv     = new string[] { "job", "create", "-n", name, "--pool", poolUuid, "-s", shortname };
            iConfSet = parser.Parse(argv);

            if (!(iConfSet is CreateConfiguration))
            {
                throw new Exception("return value is not CreateConfiguration ");
            }

            confset = (CreateConfiguration)iConfSet;
            Assert.AreEqual(confset.Type, ConfigType.Job);
            Assert.AreEqual(confset.Name, name);
            Assert.AreEqual(confset.Shortname, shortname);
            Assert.AreEqual(confset.PoolUuid, poolUuid);
            commandLineParser.Dispose();
        }
Beispiel #26
0
        public void CreatePoolFullTestParsArg()
        {
            string[]          argv              = new string[] { "pool", "create", "-n", "name", "-s", "shortname", "-f", string.Empty, "-t", "tag1,tag2", "-c", "constants", "-p", "profile", "-i", "5" };
            string[]          argvFull          = new string[] { "pool", "create", "--name", "name", "--shortname", "shortname", "--file", string.Empty, "--tags", "tag1,tag2", "--constants", "constants", "--profile", "profile", "--instanceNodes", "5" };
            var               commandLineParser = new CommandLine.Parser();
            CommandLineParser parser            = new CommandLineParser(new OptionConverter(new JsonDeserializer()), commandLineParser, new ParserUsage(), new VerbFormater());
            IConfiguration    iConfSet          = parser.Parse(argv);
            IConfiguration    iConfSetFull      = parser.Parse(argvFull);

            if (!(iConfSet is CreateConfiguration) || !(iConfSetFull is CreateConfiguration))
            {
                throw new Exception("return value is not CreateConfiguration ");
            }

            CreateConfiguration confset = (CreateConfiguration)iConfSet;

            Assert.AreEqual(confset.Type, ConfigType.Pool);
            confset = (CreateConfiguration)iConfSetFull;
            Assert.AreEqual(confset.Type, ConfigType.Pool);
            commandLineParser.Dispose();
        }
Beispiel #27
0
        public async Task CreatePoolFromFakeHandlerReturnTheGoodUuid()
        {
            FakeHTTP.ReturnMessage = HttpPoolObject.PoolResponseBody;
            CreateConfiguration config = new CreateConfiguration(ConfigType.Pool, CommandApi.Create);

            config.Constants = new List <string>()
            {
                "key1=val1", "key2=val2"
            };
            config.Constraints = new List <string>()
            {
                "key1=val1", "key2=val2"
            };
            config.TasksDefaultWaitForPoolResourcesSynchronization = true;
            var    createPool      = new ApiObjectCreator.CreateNewPool(Tool);
            var    commandLauncher = new CreateCommandLauncher(createPool, FormatTable, FakeApi);
            string ret             = await commandLauncher.RunAndPrintCommandAsync(config, FalsePrinter);

            string expected = "Uuid : f78fdff8-7081-46e1-bb2f-d9cd4e185ece" + Environment.NewLine + "Message : New pool created, state : Success" + Environment.NewLine;

            Assert.AreEqual(ret, expected);
        }
Beispiel #28
0
        public void CheckTaskWithAValidArgumentsList()
        {
            IConfiguration config = new CreateConfiguration(ConfigType.Task, CommandApi.Create)
            {
                Type = ConfigType.Task, Name = "bob", Profile = "Bob", InstanceCount = 2
            };

            Assert.IsTrue(CommandLineParser.CheckTask(config));
            config = new CreateConfiguration(ConfigType.Task, CommandApi.Create)
            {
                Type = ConfigType.Task, Name = "bob", JobUuid = "Bob", InstanceCount = 2
            };
            Assert.IsTrue(CommandLineParser.CheckTask(config));
            config = new CreateConfiguration(ConfigType.Task, CommandApi.Create)
            {
                Type = ConfigType.Task, Name = "bob", PoolUuid = "Bob", InstanceCount = 2
            };
            Assert.IsTrue(CommandLineParser.CheckTask(config));
            config = new CreateConfiguration(ConfigType.Task, CommandApi.Create)
            {
                Type = ConfigType.Task, Name = "bob", Profile = "Bob", Range = "2"
            };
            Assert.IsTrue(CommandLineParser.CheckTask(config));
        }
    /// <summary>
    ///
    /// </summary>
    void ShowPlatformConfigurationManager()
    {
        GUI.Box(new Rect(0, 0, 260, 140), "Platform Configuration: ");

        index = EditorGUI.Popup(new Rect(0, 25, 255, 15), "Configurations:", index, platFormConfigs);

        if (GUI.Button(new Rect(5, 65, 55, 24), "Create"))
        {
            CreateConfiguration createConfigurationWindow =
                (CreateConfiguration)EditorWindow.GetWindow(typeof(CreateConfiguration), true,
                                                            "Create Configuration");
            createConfigurationWindow.SetDataManager(this.PlatformDataManager);
            createConfigurationWindow.Show();
        }

        if (GUI.Button(new Rect(65, 65, 55, 24), "Edit"))
        {
            Debug.Log("Edit index:" + index);
            EditPlatformDataWindow editConfigurationWindow =
                (EditPlatformDataWindow)EditorWindow.GetWindow(typeof(EditPlatformDataWindow), true,
                                                               "Edit Configuration");
            editConfigurationWindow.SetDataManager(this.PlatformDataManager);
            //editConfigurationWindow.SetPlatformDataToEdit(this.PlatformDataManager.getPlatformDataFromIndex(this.index));
            editConfigurationWindow.SetIndex(index);
            editConfigurationWindow.Show();
        }

        if (GUI.Button(new Rect(5, 95, 55, 24), "Save"))
        {
            PlatformDataManager.saveData();
            this.Close();
        }

        if (GUI.Button(new Rect(65, 95, 55, 24), "Delete"))
        {
            DeleteSelectedPlatformConfiguration(index);
        }

        GUI.Box(new Rect(265, 0, 120, 200), "Load Configurations: ");

        if (GUI.Button(new Rect(267, 65, 115, 24), "Open Selected"))
        {
            Debug.Log("Load index:" + index);
            PrepareLoadConfigurationSetup(index);
        }

        if (GUI.Button(new Rect(267, 95, 115, 24), "Build Selected"))
        {
            build.BuildConfiguration();
        }

        GUI.Box(new Rect(390, 0, 125, 200), "Buildsystem WebApp: ");

        if (GUI.Button(new Rect(392, 40, 120, 24), "Load"))
        {
        }

        if (GUI.Button(new Rect(392, 70, 120, 24), "Store"))
        {
            StoreToBuildsystemServer();
        }

        if (GUI.Button(new Rect(392, 100, 120, 24), "Store Selected"))
        {
            StoreSelectedToBuildsystemServer();
        }


        if (GUI.Button(new Rect(392, 130, 120, 24), "WebApp"))
        {
            Application.OpenURL("http://localhost:3000/");
        }

        GUI.Box(new Rect(0, 145, 260, 55), "");
        if (GUI.Button(new Rect(5, 165, 117, 24), "Close"))
        {
            this.Close();
        }
    }
Beispiel #30
0
        public async Task <ActionResult> Post(CreateConfiguration command)
        {
            await _dispatcher.SendAsync(command);

            return(Accepted());
        }