コード例 #1
0
ファイル: DeploymentTest.cs プロジェクト: zmyer/gridgain
        public void TestMissingJarsCauseProperException()
        {
            var dllFolder  = Path.Combine(_tempFolder, "foo");
            var jarFolder  = Path.Combine(_tempFolder, "bar", "libs");
            var homeFolder = Directory.GetParent(jarFolder).FullName;

            DeployTo(dllFolder, jarFolder);

            // Remove some jars.
            Directory.GetFiles(jarFolder, "cache-api-1.0.0.jar").ToList().ForEach(File.Delete);

            // Start a node and check the exception.
            var exePath = Path.Combine(dllFolder, "Apache.Ignite.exe");
            var reader  = new ListDataReader();

            var proc = IgniteProcess.Start(exePath, homeFolder, reader);

            // Wait for process to fail.
            Assert.IsNotNull(proc);
            Assert.IsTrue(proc.WaitForExit(30000));
            Assert.IsTrue(proc.HasExited);
            Assert.AreEqual(-1, proc.ExitCode);

            // Check error message.
            Assert.AreEqual("ERROR: Apache.Ignite.Core.Common.IgniteException: Java class is not found " +
                            "(did you set IGNITE_HOME environment variable?): " +
                            "org/apache/ignite/internal/processors/platform/utils/PlatformUtils",
                            reader.GetOutput().First());
        }
コード例 #2
0
        /// <summary>
        /// Saves the element collection into the repository.
        /// </summary>
        /// <param name="elements">The element's collection to save.</param>
        /// <returns><b>True</b> if the element's collection is saved successfully, <b>False</b> in otherwise.</returns>
        public async Task SaveCollection(List <Element> elements)
        {
            ListDataReader <Element> reader = new ListDataReader <Element>(elements);

            using (var sqlConnection = new SqlConnection(this.sqlServerSettings.ConnectionString))
            {
                sqlConnection.Open();
                using (SqlTransaction transaction = sqlConnection.BeginTransaction())
                {
                    try
                    {
                        using (var sqlBulk = new SqlBulkCopy(sqlConnection, SqlBulkCopyOptions.TableLock, transaction))
                        {
                            sqlBulk.DestinationTableName = "[dbo].[Element]";
                            await sqlBulk.WriteToServerAsync(reader);

                            sqlBulk.BatchSize = this.settings.BatchSize;
                            transaction.Commit();
                        }
                    }
                    catch (Exception ex)
                    {
                        this.logger.LogError(ex, "Error al grabar los registros en base de datos");
                        transaction.Rollback();
                    }
                }
            }
        }
コード例 #3
0
        public void TestMissingJarsCauseProperException()
        {
            // Create temp folder
            var folder = _tempFolder;

            DeployTo(folder);

            // Build classpath
            var classpath = string.Join(";",
                                        Directory.GetFiles(folder).Where(x => !x.Contains("ignite-core-")).Select(Path.GetFileName));

            // Start a node and check the exception.
            var exePath = Path.Combine(folder, "Apache.Ignite.exe");
            var reader  = new ListDataReader();

            var proc = IgniteProcess.Start(exePath, string.Empty, args: new[]
            {
                "-jvmClasspath=" + classpath,
                "-J-ea",
                "-J-Xms512m",
                "-J-Xmx512m"
            }, outReader: reader);

            // Wait for process to fail.
            Assert.IsNotNull(proc);
            Assert.IsTrue(proc.WaitForExit(10000));
            Assert.IsTrue(proc.HasExited);
            Assert.AreEqual(-1, proc.ExitCode);

            // Check error message.
            Assert.AreEqual("ERROR: Apache.Ignite.Core.Common.IgniteException: Java class is not found " +
                            "(did you set IGNITE_HOME environment variable?): " +
                            "org/apache/ignite/internal/processors/platform/PlatformIgnition",
                            reader.GetOutput().First());
        }
コード例 #4
0
ファイル: TestUtils.cs プロジェクト: wiltonlazary/ignite
        public static void RunTestInNewProcess(string fixtureName, string testName)
        {
            var procStart = new ProcessStartInfo
            {
                FileName               = typeof(TestUtils).Assembly.Location,
                Arguments              = fixtureName + " " + testName,
                CreateNoWindow         = true,
                UseShellExecute        = false,
                RedirectStandardOutput = true,
                RedirectStandardError  = true
            };

            var proc = System.Diagnostics.Process.Start(procStart);

            Assert.IsNotNull(proc);

            try
            {
                var reader = new ListDataReader();
                proc.AttachProcessConsoleReader(reader, new IgniteProcessConsoleOutputReader());

                Assert.IsTrue(proc.WaitForExit(50000), string.Join("\n", reader.GetOutput()));
                Assert.AreEqual(0, proc.ExitCode, string.Join("\n", reader.GetOutput()));
            }
            finally
            {
                if (!proc.HasExited)
                {
                    proc.Kill();
                }
            }
        }
コード例 #5
0
        public void TestEntityConvert()
        {
            var type   = typeof(Student);
            var reader = new ListDataReader <Student>(_Students);

            foreach (var item in _Students)
            {
                reader.Read();
                Student s = _Converter.GetConverter <Student>(reader)(reader);
                Assert.Equal(item.ClassNumber, s.ClassNumber);
                Assert.Equal(item.Age, s.Age);
                Assert.Equal(item.Bool, s.Bool);
                Assert.Equal(item.Byte, s.Byte);
                Assert.Equal(item.Name, s.Name);
                Assert.Equal(item.DateTime, s.DateTime);
                Assert.Equal(item.Decimal, s.Decimal);
                Assert.Equal(item.Double, s.Double);
                Assert.Equal(item.Float, s.Float);
                Assert.Equal(item.Guid, s.Guid);
                Assert.Equal(item.Long, s.Long);
                Assert.Equal(item.Short, s.Short);
                Assert.Equal(item.Bool2, s.Bool2);
                Assert.Equal(item.Byte2, s.Byte2);
                Assert.Equal(item.DateTime2, s.DateTime2);
                Assert.Equal(item.Decimal2, s.Decimal2);
                Assert.Equal(item.Double2, s.Double2);
                Assert.Equal(item.Float2, s.Float2);
                Assert.Equal(item.Guid2, s.Guid2);
                Assert.Equal(item.Long2, s.Long2);
                Assert.Equal(item.Short2, s.Short2);
                Assert.NotSame(item, s);
            }
        }
コード例 #6
0
        public async void TestGetDateTime()
        {
            var reader = new ListDataReader <Student>(_Students);
            var ps     = _Properties.Where(i => i.CanRead).ToArray();

            foreach (var st in _Students)
            {
                await reader.ReadAsync();

                var index = 0;
                foreach (var p in ps)
                {
                    if (p.PropertyType == typeof(DateTime) || (p.PropertyType == typeof(DateTime?) && p.GetMethod.Invoke(st, new object[0]) != null))
                    {
                        Assert.Equal(p.GetMethod.Invoke(st, new object[0]), reader.GetDateTime(index));
                    }
                    else if (p.PropertyType.GetTypeInfo().IsGenericType &&
                             p.PropertyType.GetGenericTypeDefinition() == typeof(Nullable <>) &&
                             p.GetMethod.Invoke(st, new object[0]) == null)
                    {
                        Assert.ThrowsAny <RuntimeBinderException>(() => reader.GetDateTime(index));
                    }
                    else
                    {
                        Assert.ThrowsAny <RuntimeBinderException>(() => reader.GetDateTime(index));
                    }
                    index++;
                }
            }
        }
コード例 #7
0
        public void TestRead()
        {
            var reader = new ListDataReader <Student>(_Students);

            foreach (var st in _Students)
            {
                Assert.True(reader.Read());
            }
            Assert.False(reader.Read());
        }
コード例 #8
0
        public void TestInvalidCmdArgs()
        {
            var ignoredWarns = new[]
            {
                "WARNING: An illegal reflective access operation has occurred",
                "WARNING: Illegal reflective access by org.apache.ignite.internal.util.GridUnsafe$2 " +
                "(file:/C:/w/incubator-ignite/modules/core/target/classes/) to field java.nio.Buffer.address",
                "WARNING: Please consider reporting this to the maintainers of org.apache.ignite.internal.util." +
                "GridUnsafe$2",
                "WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations",
                "WARNING: All illegal access operations will be denied in a future release"
            };

            Action <string, string> checkError = (args, err) =>
            {
                var reader = new ListDataReader();
                var proc   = new IgniteProcess(reader, args);

                int exitCode;
                Assert.IsTrue(proc.Join(30000, out exitCode));
                Assert.AreEqual(-1, exitCode);

                Assert.AreEqual(err, reader.GetOutput()
                                .Except(ignoredWarns)
                                .FirstOrDefault(x => !string.IsNullOrWhiteSpace(x)));
            };

            checkError("blabla", "ERROR: Apache.Ignite.Core.Common.IgniteException: Missing argument value: " +
                       "'blabla'. See 'Apache.Ignite.exe /help'");

            checkError("blabla=foo", "ERROR: Apache.Ignite.Core.Common.IgniteException: " +
                       "Unknown argument: 'blabla'. See 'Apache.Ignite.exe /help'");

            checkError("assembly=", "ERROR: Apache.Ignite.Core.Common.IgniteException: Missing argument value: " +
                       "'assembly'. See 'Apache.Ignite.exe /help'");

            checkError("assembly=x.dll", "ERROR: Apache.Ignite.Core.Common.IgniteException: Failed to start " +
                       "Ignite.NET, check inner exception for details ---> Apache.Ignite.Core." +
                       "Common.IgniteException: Failed to load assembly: x.dll");

            checkError("configFileName=wrong.config", "ERROR: System.Configuration.ConfigurationErrorsException: " +
                       "Specified config file does not exist: wrong.config");

            checkError("configSectionName=wrongSection", "ERROR: System.Configuration.ConfigurationErrorsException: " +
                       "Could not find IgniteConfigurationSection " +
                       "in current application configuration");

            checkError("JvmInitialMemoryMB=A_LOT", "ERROR: System.InvalidOperationException: Failed to configure " +
                       "Ignite: property 'JvmInitialMemoryMB' has value 'A_LOT', " +
                       "which is not an integer.");

            checkError("JvmMaxMemoryMB=ALL_OF_IT", "ERROR: System.InvalidOperationException: Failed to configure " +
                       "Ignite: property 'JvmMaxMemoryMB' has value 'ALL_OF_IT', " +
                       "which is not an integer.");
        }
コード例 #9
0
        public void TestGetStringWithIsDBNullCheck()
        {
            var reader = new ListDataReader <Student>(_Students);

            reader.Read();
            Assert.Null(reader.GetStringWithNull("Name"));
            reader.Read();
            Assert.NotNull(reader.GetStringWithNull("Name"));
            reader.Read();
            Assert.NotNull(reader.GetStringWithNull("Name"));
        }
コード例 #10
0
        public void TestGetDouble()
        {
            var reader = new ListDataReader <Student>(_Students);

            reader.Read();
            var col = "Double2";

            Assert.Equal(4.4, reader.GetDouble(col));
            reader.Read();
            reader.Read();
            Assert.Equal(5.5, reader.GetDouble(col));
        }
コード例 #11
0
        public void TestGetDecimal()
        {
            var reader = new ListDataReader <Student>(_Students);

            reader.Read();
            var col = "Decimal2";

            Assert.Equal(4M, reader.GetDecimal(col));
            reader.Read();
            reader.Read();
            Assert.Equal(5M, reader.GetDecimal(col));
        }
コード例 #12
0
        public void TestGetDateTime()
        {
            var reader = new ListDataReader <Student>(_Students);

            reader.Read();
            var col = "DateTime2";

            Assert.Equal(new DateTime(1990, 2, 3), reader.GetDateTime(col));
            reader.Read();
            reader.Read();
            Assert.Equal(new DateTime(1991, 2, 3), reader.GetDateTime(col));
        }
コード例 #13
0
        public void TestGetChar()
        {
            var reader = new ListDataReader <Student>(_Students);

            reader.Read();
            var col = "Char";

            Assert.Equal('2', reader.GetChar(col));
            reader.Read();
            reader.Read();
            Assert.Equal('3', reader.GetChar(col));
        }
コード例 #14
0
        public void TestGetFloat()
        {
            var reader = new ListDataReader <Student>(_Students);

            reader.Read();
            var col = "Float2";

            Assert.Equal(33.3F, reader.GetFloat(col));
            reader.Read();
            reader.Read();
            Assert.Equal(33.43F, reader.GetFloat(col));
        }
コード例 #15
0
        public void TestGetGuid()
        {
            var reader = new ListDataReader <Student>(_Students);

            reader.Read();
            var col = "Guid2";

            Assert.Equal(Guid.Parse("E82E26DA-AED1-4FD3-BFF9-73BE66F28EED"), reader.GetGuid(col));
            reader.Read();
            reader.Read();
            Assert.Equal(Guid.Parse("A82E26DA-AED1-4FD3-BFF9-73BE66F28EED"), reader.GetGuid(col));
        }
コード例 #16
0
        public void TestGetInt64()
        {
            var reader = new ListDataReader <Student>(_Students);

            reader.Read();
            var col = "Long2";

            Assert.Equal(2, reader.GetInt64(col));
            reader.Read();
            reader.Read();
            Assert.Equal(3, reader.GetInt64(col));
        }
コード例 #17
0
        public void TestGetGetByte()
        {
            var reader = new ListDataReader <Student>(_Students);

            reader.Read();
            var col = "Byte2";

            Assert.Equal(2, reader.GetByte(col));
            reader.Read();
            reader.Read();
            Assert.Equal(3, reader.GetByte(col));
        }
コード例 #18
0
        public void TestGetBoolean()
        {
            var reader = new ListDataReader <Student>(_Students);

            reader.Read();
            var col = "Bool2";

            Assert.True(reader.GetBoolean(col));
            reader.Read();
            reader.Read();
            Assert.False(reader.GetBoolean(col));
        }
コード例 #19
0
        public void TestGetInt32()
        {
            var reader = new ListDataReader <Student>(_Students);

            reader.Read();
            var col = "ClassNumber";

            Assert.Equal(2, reader.GetInt32(col));
            reader.Read();
            reader.Read();
            Assert.Equal(3, reader.GetInt32(col));
        }
コード例 #20
0
        public void TestGetInt16()
        {
            var reader = new ListDataReader <Student>(_Students);

            reader.Read();
            var col = "Short2";

            Assert.Equal(77, reader.GetInt16(col));
            reader.Read();
            reader.Read();
            Assert.Equal(76, reader.GetInt16(col));
        }
コード例 #21
0
        public void TestNextResult()
        {
            var reader = new ListDataReader <Student>(_Students);

            Assert.False(reader.NextResult());
            foreach (var st in _Students)
            {
                reader.Read();
                Assert.False(reader.NextResult());
            }
            Assert.False(reader.NextResult());
        }
コード例 #22
0
        public void TestGetFloatWithIsDBNullCheck()
        {
            var reader = new ListDataReader <Student>(_Students);

            reader.Read();
            var col = "Float2";

            Assert.Equal(33.3F, reader.GetFloatWithNull(col).Value);
            reader.Read();
            Assert.False(reader.GetFloatWithNull(col).HasValue);
            reader.Read();
            Assert.Equal(33.43F, reader.GetFloatWithNull(col).Value);
        }
コード例 #23
0
        public void TestGetCharWithIsDBNullCheck()
        {
            var reader = new ListDataReader <Student>(_Students);

            reader.Read();
            var col = "Char";

            Assert.Equal('2', reader.GetCharWithNull(col).Value);
            reader.Read();
            Assert.False(reader.GetCharWithNull(col).HasValue);
            reader.Read();
            Assert.Equal('3', reader.GetCharWithNull(col).Value);
        }
コード例 #24
0
        public void TestGetDateTimeWithIsDBNullCheck()
        {
            var reader = new ListDataReader <Student>(_Students);

            reader.Read();
            var col = "DateTime2";

            Assert.Equal(new DateTime(1990, 2, 3), reader.GetDateTimeWithNull(col).Value);
            reader.Read();
            Assert.False(reader.GetDateTimeWithNull(col).HasValue);
            reader.Read();
            Assert.Equal(new DateTime(1991, 2, 3), reader.GetDateTimeWithNull(col).Value);
        }
コード例 #25
0
        public void TestGetBooleanWithIsDBNullCheck()
        {
            var reader = new ListDataReader <Student>(_Students);

            reader.Read();
            var col = "Bool2";

            Assert.True(reader.GetBooleanWithNull(col).Value);
            reader.Read();
            Assert.False(reader.GetBooleanWithNull(col).HasValue);
            reader.Read();
            Assert.False(reader.GetBooleanWithNull(col).Value);
        }
コード例 #26
0
        public void TestGetDoubleWithIsDBNullCheck()
        {
            var reader = new ListDataReader <Student>(_Students);

            reader.Read();
            var col = "Double2";

            Assert.Equal(4.4, reader.GetDoubleWithNull(col).Value);
            reader.Read();
            Assert.False(reader.GetDoubleWithNull(col).HasValue);
            reader.Read();
            Assert.Equal(5.5, reader.GetDoubleWithNull(col).Value);
        }
コード例 #27
0
        public void TesGetInt64WithIsDBNullCheck()
        {
            var reader = new ListDataReader <Student>(_Students);

            reader.Read();
            var col = "Long2";

            Assert.Equal(2, reader.GetInt64WithNull(col).Value);
            reader.Read();
            Assert.False(reader.GetInt64WithNull(col).HasValue);
            reader.Read();
            Assert.Equal(3, reader.GetInt64WithNull(col).Value);
        }
コード例 #28
0
        public void TesGetGuidWithIsDBNullCheck()
        {
            var reader = new ListDataReader <Student>(_Students);

            reader.Read();
            var col = "Guid2";

            Assert.Equal(Guid.Parse("E82E26DA-AED1-4FD3-BFF9-73BE66F28EED"), reader.GetGuidWithNull(col).Value);
            reader.Read();
            Assert.False(reader.GetGuidWithNull(col).HasValue);
            reader.Read();
            Assert.Equal(Guid.Parse("A82E26DA-AED1-4FD3-BFF9-73BE66F28EED"), reader.GetGuidWithNull(col).Value);
        }
コード例 #29
0
        /// <summary>
        /// Starts a server node with a given version.
        /// </summary>
        /// <param name="groupId">Maven artifact group id.</param>
        /// <param name="version">Product version.</param>
        /// <returns>Disposable object to stop the server.</returns>
        public static IDisposable Start(string groupId, string version)
        {
            IgniteArgumentCheck.NotNullOrEmpty(version, "version");

            var pomWrapper =
                ReplaceIgniteVersionInPomFile(groupId, version, Path.Combine(JavaServerSourcePath, "pom.xml"));

            var process = new System.Diagnostics.Process
            {
                StartInfo = new ProcessStartInfo
                {
                    FileName  = Os.IsWindows ? "cmd.exe" : "/bin/bash",
                    Arguments = Os.IsWindows
                        ? string.Format("/c \"{0} {1}\"", MavenPath, MavenCommandExec)
                        : string.Format("-c \"{0} {1}\"", MavenPath, MavenCommandExec.Replace("\"", "\\\"")),
                    UseShellExecute        = false,
                    CreateNoWindow         = true,
                    WorkingDirectory       = JavaServerSourcePath,
                    RedirectStandardOutput = true,
                    RedirectStandardError  = true
                }
            };

            process.Start();

            var processWrapper = new DisposeAction(() =>
            {
                process.KillProcessTree();
                pomWrapper.Dispose();
            });

            try
            {
                var listDataReader = new ListDataReader();
                process.AttachProcessConsoleReader(listDataReader, new IgniteProcessConsoleOutputReader());

                // Wait for node to come up with a thin client connection.
                if (WaitForStart(listDataReader))
                {
                    return(processWrapper);
                }

                throw new Exception("Failed to start Java node: " + string.Join(",", listDataReader.GetOutput()));
            }
            catch (Exception)
            {
                processWrapper.Dispose();
                throw;
            }
        }
コード例 #30
0
        public void TestGetOrdinal()
        {
            var reader = new ListDataReader <Student>(_Students);
            var ps     = _Properties.Where(i => i.CanRead).ToArray();

            while (reader.Read())
            {
                var index = 0;
                foreach (var p in ps)
                {
                    Assert.Equal(index++, reader.GetOrdinal(p.Name));
                }
            }
        }