Exemplo n.º 1
0
        private void Launch(Type fixtureType)
        {
            var starter = new ProcessStarter ();

            var projectPath = Path.GetFullPath ("../../").TrimEnd('/'); // Use this line if the test is running in a temporary directory
            //var projectPath = Path.GetFullPath ("../../../../"); // Use this line if temporary directories are disabled

            var assemblyName = Path.GetFileName(fixtureType.Assembly.Location);

            var buildMode = "Release";
            #if DEBUG
            buildMode = "Debug";
            #endif

            Console.WriteLine ("Project path: " + projectPath);
            // TODO: Clean ups
            //var command = String.Format("cp /ipfs-cs /ipfs-cs-staging -r && cd /ipfs-cs-staging && rm bin/* -r && sh build.sh {0} && cd bin/{0} && mono LaunchIntegrationTest.exe /assembly:\"{1}\" /type:\"{2}\"", buildMode, assemblyName, fixtureType.FullName);

            var command = String.Format("cd /ipfs-cs && sh start-integration-test.sh {0} {1} {2}", buildMode, assemblyName, fixtureType.FullName);

            command = String.Format ("docker run -v /var/run/docker.sock:/var/run/docker.sock -v {0}:/ipfs-cs {1} /bin/bash -c '{2}'", projectPath, ImageName, command);
            starter.WriteToConsole = true;
            starter.Start (
                command
            );
            Console.WriteLine (starter.Output);
            if (starter.IsError)
                throw new Exception ("Error launching docker based test");
        }
Exemplo n.º 2
0
        public string AddFolder(string folderPath)
        {
            Console.WriteLine ("Attempting to add folder:");
            Console.WriteLine (folderPath);
            Console.WriteLine ("Current directory:");
            Console.WriteLine (Environment.CurrentDirectory);

            if (!Directory.Exists (Path.GetFullPath(folderPath)))
                throw new ArgumentException ("Folder not found: " + folderPath);

            var starter = new ProcessStarter ();

            // TODO: Clean up code
            //var originalDirectory = Environment.CurrentDirectory;

            //Directory.SetCurrentDirectory (folder);

            starter.Start (
                String.Format("{0} add -r {1}", IpfsCommand, folderPath)
            );

            Console.WriteLine (starter.Output);
            //Directory.SetCurrentDirectory (originalDirectory);

            var hash = ExtractHashAfterAddFolder(starter.Output);

            return hash;
        }
Exemplo n.º 3
0
        public string AddFolder(string folderPath)
        {
            Console.WriteLine("Attempting to add folder:");
            Console.WriteLine(folderPath);
            Console.WriteLine("Current directory:");
            Console.WriteLine(Environment.CurrentDirectory);

            if (!Directory.Exists(Path.GetFullPath(folderPath)))
            {
                throw new ArgumentException("Folder not found: " + folderPath);
            }


            var starter = new ProcessStarter();

            // TODO: Clean up code
            //var originalDirectory = Environment.CurrentDirectory;

            //Directory.SetCurrentDirectory (folder);

            starter.Start(
                String.Format("{0} add -r {1}", IpfsCommand, folderPath)
                );

            Console.WriteLine(starter.Output);
            //Directory.SetCurrentDirectory (originalDirectory);

            var hash = ExtractHashAfterAddFolder(starter.Output);

            return(hash);
        }
Exemplo n.º 4
0
        public string AddFile(string filePath)
        {
            Console.WriteLine("Attempting to add file:");
            Console.WriteLine(filePath);

            if (!File.Exists(filePath))
            {
                throw new ArgumentException("File not found: " + filePath);
            }

            var starter = new ProcessStarter();

            starter.Start(
                String.Format("{0} add {1}", IpfsCommand, Path.GetFileName(filePath))
                );

            Console.WriteLine(starter.Output);

            // TODO: Fixture out a way to reduce this duration
            Thread.Sleep(5000);

            var hash = ExtractHashAfterAddFile(starter.Output);

            return(hash);
        }
Exemplo n.º 5
0
        public void Init()
        {
            IsInit = true;

            Console.WriteLine("Initializing ipfs client.");

            if (!Directory.Exists(IpfsDataPath))
            {
                Directory.CreateDirectory(IpfsDataPath);
            }

            var originalDirectory = Environment.CurrentDirectory;

            Directory.SetCurrentDirectory(IpfsDataPath);

            var starter = new ProcessStarter();

            starter.Start(
                String.Format("{0} init", IpfsCommand)
                );

            Console.WriteLine(starter.Output);

            Directory.SetCurrentDirectory(originalDirectory);
        }
Exemplo n.º 6
0
        public string Publish(string hash)
        {
            Console.WriteLine("Attempting to publish:");
            Console.WriteLine(hash);

            var starter = new ProcessStarter();

            starter.Start(
                String.Format("{0} name publish {1}", IpfsCommand, hash)
                );

            Console.WriteLine(starter.Output);

            var peerId = ExtractHashAfterPublish(starter.Output);

            //starter.Start (
            //	String.Format ("ipfs name resolve {0}", peerId)
            //);

            return(peerId);
        }
Exemplo n.º 7
0
        public string AddFile(string filePath)
        {
            Console.WriteLine ("Attempting to add file:");
            Console.WriteLine (filePath);

            if (!File.Exists (filePath))
                throw new ArgumentException ("File not found: " + filePath);

            var starter = new ProcessStarter ();

            starter.Start (
                String.Format ("{0} add {1}", IpfsCommand, Path.GetFileName (filePath))
            );

            Console.WriteLine (starter.Output);

            // TODO: Fixture out a way to reduce this duration
            Thread.Sleep (5000);

            var hash = ExtractHashAfterAddFile(starter.Output);

            return hash;
        }
Exemplo n.º 8
0
        public string Publish(string hash)
        {
            Console.WriteLine ("Attempting to publish:");
            Console.WriteLine (hash);

            var starter = new ProcessStarter ();

            starter.Start (
                String.Format ("{0} name publish {1}", IpfsCommand, hash)
            );

            Console.WriteLine (starter.Output);

            var peerId = ExtractHashAfterPublish(starter.Output);

            //starter.Start (
            //	String.Format ("ipfs name resolve {0}", peerId)
            //);

            return peerId;
        }
Exemplo n.º 9
0
        public void Init()
        {
            IsInit = true;

            Console.WriteLine ("Initializing ipfs client.");

            if (!Directory.Exists (IpfsDataPath))
                Directory.CreateDirectory (IpfsDataPath);

            var originalDirectory = Environment.CurrentDirectory;

            Directory.SetCurrentDirectory (IpfsDataPath);

            var starter = new ProcessStarter ();

            starter.Start (
                String.Format ("{0} init", IpfsCommand)
            );

            Console.WriteLine (starter.Output);

            Directory.SetCurrentDirectory (originalDirectory);
        }