Ejemplo n.º 1
0
def BuildDocker(buildSelection):
    VersionTools.ExportVersionFromChangelogToEnvironment('CHANGELOG.md', 'VERSION')
    composeFiles = [
        'docker-compose.yml'
    ]

    if buildSelection == "run":
        DockerComposeTools.DockerComposeUp(composeFiles)

    if buildSelection == "run":
        DockerComposeTools.DockerComposeUp(composeFiles)

    elif buildSelection == "test":
        testContainerNames = ['my-service']
        DockerComposeTools.ExecuteComposeTests(composeFiles, testContainerNames)

    elif buildSelection == "publish":
        BuildDocker("build")
        DockerComposeTools.DockerComposePush(composeFiles)
        DockerComposeTools.PublishDockerImagesWithNewTag(composeFiles, 'latest')

    elif buildSelection == "help":
        TerminalTools.PrintAvailableCommands(AvailableCommands)

    else:
        print("Please provide a valid build argument: ")
        BuildDocker("help")
Ejemplo n.º 2
0
def TestSelection(testSelection):
    cwd = BuildTools.TryChangeToDirectoryAndGetCwd(testSelection)
    DockerComposeTools.ExecuteComposeTests(
        testSelection[BuildTools.FILES_KEY],
        testSelection[CONTAINER_NAMES_KEY],
        BuildTools.TryGetFromDictionary(testSelection, REMOVE_CONTAINERS_KEY,
                                        True))
    os.chdir(cwd)
Ejemplo n.º 3
0
 def test_f_ComposeTest(self):
     print('COMPOSE TEST')
     TerminalTools.LoadEnvironmentVariables(
         os.path.join(TestTools.TEST_SAMPLE_FOLDER, '.env'))
     DockerComposeTools.ExecuteComposeTests(
         [os.path.join(TestTools.TEST_SAMPLE_FOLDER, 'docker-compose.yml')],
         ['my-service'])
     print('DONE COMPOSE TEST')
Ejemplo n.º 4
0
def BuildDocker(buildSelection):
    VersionTools.ExportVersionFromChangelogToEnvironment(
        'CHANGELOG.md', 'VERSION')
    srcFolder = ['src', '..']
    miniSwarmManagementFile = 'swarm-management.yml'
    migratorComposeFiles = ['docker-compose.migrator.yml']
    nugetDockerComposeFiles = ['docker-compose.publish.nuget.yml']
    generalComposeFiles = [
        'docker-compose.message.handler.yml',
        'docker-compose.outboxcleaner.yml',
        'docker-compose.message.spammer.yml'
    ]

    if buildSelection == 'run':
        os.chdir(srcFolder[0])
        DockerComposeTools.DockerComposeUp(migratorComposeFiles)
        DockerComposeTools.DockerComposeUp(generalComposeFiles)
        os.chdir(srcFolder[1])

    elif buildSelection == 'build':
        os.chdir(srcFolder[0])
        DockerComposeTools.DockerComposeBuild(generalComposeFiles +
                                              migratorComposeFiles)
        os.chdir(srcFolder[1])

    elif buildSelection == 'test':
        os.chdir(srcFolder[0])
        DockerComposeTools.ExecuteComposeTests(['docker-compose.tests.yml'],
                                               ['saferebus-tests'])
        os.chdir(srcFolder[1])

    elif buildSelection == 'publish':
        os.chdir(srcFolder[0])
        DockerComposeTools.DockerComposeBuild(nugetDockerComposeFiles)
        DockerComposeTools.DockerComposeUp(nugetDockerComposeFiles, False)
        os.chdir(srcFolder[1])

    elif buildSelection == 'start-dev':
        os.chdir(srcFolder[0] + '/ServiceDependencies')
        SwarmManager.HandleManagement(
            ['-start', '-f', miniSwarmManagementFile])
        os.chdir(srcFolder[1] + '/..')

    elif buildSelection == 'stop-dev':
        os.chdir(srcFolder[0] + '/ServiceDependencies')
        SwarmManager.HandleManagement(['-stop', '-f', miniSwarmManagementFile])
        os.chdir(srcFolder[1] + '/..')

    elif buildSelection == 'help':
        TerminalTools.PrintAvailableCommands(AvailableCommands)

    else:
        print('Please provide a valid build argument: ')
        BuildDocker('help')
Ejemplo n.º 5
0
def TestSelection(testSelection):
    cwd = BuildTools.TryChangeToDirectoryAndGetCwd(testSelection)
    BuildTools.HandleTerminalCommandsSelection(testSelection)

    if BuildTools.FILES_KEY in testSelection:
        DockerComposeTools.ExecuteComposeTests(
            testSelection[BuildTools.FILES_KEY], 
            testSelection[CONTAINER_NAMES_KEY], False)

        BuildTools.HandleCopyFromContainer(testSelection)

        if BuildTools.TryGetFromDictionary(testSelection, REMOVE_CONTAINERS_KEY, False):
            DockerComposeTools.DockerComposeRemove(
                testSelection[BuildTools.FILES_KEY])

    os.chdir(cwd)
Ejemplo n.º 6
0
 def test_g_ComposeTestWithContainerNamesNotSet(self):
     print('COMPOSE TEST UNKNOWN NAME')
     TerminalTools.LoadEnvironmentVariables(
         os.path.join(TestTools.TEST_SAMPLE_FOLDER, '.env'))
     yamlData = YamlTools.GetYamlData([
         os.path.join(TestTools.TEST_SAMPLE_FOLDER,
                      'docker-compose.test.yml')
     ])
     DockerComposeTools.AddContainerNames(yamlData)
     YamlTools.DumpYamlDataToFile(
         yamlData,
         os.path.join(TestTools.TEST_SAMPLE_FOLDER,
                      'docker-compose.test.temp.yml'))
     DockerComposeTools.ExecuteComposeTests([
         os.path.join(TestTools.TEST_SAMPLE_FOLDER,
                      'docker-compose.test.temp.yml')
     ])
     print('DONE COMPOSE TEST UNKNOWN NAME')
Ejemplo n.º 7
0
def BuildDocker(buildSelection):
    srcFolder = ['src', '..']
    miniSwarmManagementFile = 'swarm-management.yml'
    migratorComposeFiles = [
        'docker-compose.migrator.yml'
    ]
    generalComposeFiles = [
        'docker-compose.yml'
    ]

    if buildSelection == 'run':
        os.chdir(srcFolder[0])
        DockerComposeTools.DockerComposeUp(migratorComposeFiles)
        DockerComposeTools.DockerComposeUp(generalComposeFiles)
        os.chdir(srcFolder[1])
    
    elif buildSelection == 'build':
        os.chdir(srcFolder[0])
        DockerComposeTools.DockerComposeBuild(generalComposeFiles + migratorComposeFiles)
        os.chdir(srcFolder[1])

    elif buildSelection == 'test':
        os.chdir(srcFolder[0])
        DockerComposeTools.ExecuteComposeTests(
            ['docker-compose.tests.yml'], ['kafkaoncontainers-tests'])
        os.chdir(srcFolder[1])

    elif buildSelection == 'start-dev':
        os.chdir(srcFolder[0] + '/ServiceDependencies')
        SwarmManager.HandleManagement(['-start', '-f', miniSwarmManagementFile])
        os.chdir(srcFolder[1] + '/..')

    elif buildSelection == 'stop-dev':
        os.chdir(srcFolder[0] + '/ServiceDependencies')
        SwarmManager.HandleManagement(['-stop', '-f', miniSwarmManagementFile])
        os.chdir(srcFolder[1] + '/..')

    elif buildSelection == 'help':
        TerminalTools.PrintAvailableCommands(AvailableCommands)

    else:
        print('Please provide a valid build argument: ')
        BuildDocker('help')
def TestSelection(testSelection, selectionToTest):
    cwd = BuildTools.TryChangeToDirectoryAndGetCwd(testSelection)
    oldEnvironmentVariable = BuildTools.AddEnvironmentVariablesFromSelection(
        testSelection)
    BuildTools.HandleTerminalCommandsSelection(testSelection)
    TerminalTools.LoadDefaultEnvironmentVariablesFile()

    if BuildTools.FILES_KEY in testSelection:
        testComposeFile = BuildTools.GetAvailableComposeFilename(
            'test', selectionToTest)
        composeFiles = testSelection[BuildTools.FILES_KEY]
        containerNames = BuildTools.MergeAndPopulateWithContainerNames(
            composeFiles, testComposeFile)
        if BuildTools.CONTAINER_NAMES_KEY in testSelection:
            containerNames = testSelection[BuildTools.CONTAINER_NAMES_KEY]

        try:
            DockerComposeTools.ExecuteComposeTests(
                [testComposeFile],
                testContainerNames=containerNames,
                removeTestContainers=False,
                buildCompose=True,
                downCompose=False)
        except:
            BuildTools.RemoveComposeFileIfNotPreserved(testComposeFile,
                                                       testSelection)
            raise

        BuildTools.HandleCopyFromContainer(testSelection)
        DockerComposeTools.DockerComposeDown([testComposeFile])
        if YamlTools.TryGetFromDictionary(testSelection,
                                          BuildTools.REMOVE_CONTAINERS_KEY,
                                          False):
            DockerComposeTools.DockerComposeRemove([testComposeFile])

        BuildTools.RemoveComposeFileIfNotPreserved(testComposeFile,
                                                   testSelection)

    BuildTools.RemoveEnvironmentVariables(oldEnvironmentVariable)
    os.chdir(cwd)