예제 #1
0
def MergeAndPopulateWithContainerNames(composeFiles, testComposeFile):
    DockerComposeTools.MergeComposeFiles(composeFiles, testComposeFile)
    yamlData = YamlTools.GetYamlData([testComposeFile])
    DockerComposeTools.AddContainerNames(yamlData)
    YamlTools.DumpYamlDataToFile(yamlData, testComposeFile)
    containerNames = DockerComposeTools.GetContainerNames(yamlData)
    return containerNames
예제 #2
0
def __GenerateStackFileWithContainerNames(stackFile: str, stackName: str,
                                          version: semantic_version.Version,
                                          stacksFolder: str):
    yamlData: dict = YamlTools.GetYamlData([stackFile])

    random.seed()
    randomId = random.randint(0, 1000)
    prefix = stackName + "_"
    subfix = "_" + str(randomId)
    DockerComposeTools.AddContainerNames(yamlData,
                                         prefix=prefix,
                                         subfix=subfix)
    temporaryStackFile = os.path.join(
        stacksFolder,
        "docker-compose-temp.{0}.{1}.{2}.yml".format(stackName, version,
                                                     randomId))
    YamlTools.DumpYamlDataToFile(yamlData, temporaryStackFile)
    return temporaryStackFile
예제 #3
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')