pharo-project / pharo-launcher

Lets you manage your pharo images and download new ones
https://pharo-project.github.io/pharo-launcher/
MIT License
108 stars 46 forks source link

[cmd-line]: CI Jenkins job failing on branch feature/cmd-line #552

Closed Bajger closed 2 years ago

Bajger commented 2 years ago

Describe the bug CI job fails due to falining shell unit tests as part of Jenkins job on branch feature/cmd-line.

To Reproduce Steps to reproduce the behavior:

  1. On local linux environment, execute following:
    gh repo clone pharo-project/pharo-launcher
    cd pharo-launcher
    git checkout feature/cmd-line
    PHARO=100 ARCHITECTURE=64 ./build.sh prepare
    PHARO=100 ARCHITECTURE=64 ./build.sh test
  2. Console output prints following error:
    testLauncherProcessListCommandWhenImageIsLaunchedShouldReturnOneImage
    NotFound: Please enter a correct local image.
    ASSERT:Actual: "", expected: "PhLTestImage". Not found:<PhLTestImage>
    shunit2:ERROR testLauncherProcessListCommandWhenImageIsLaunchedShouldReturnOneImage() returned non-zero return code.

    Expected behavior Shell unit tests pass.

Version information:

Additional context Error occurs due to fact that template list is outdated and image template for P10 stable is not found.

Bajger commented 2 years ago

@demarey: Let me know, which option you'd like better. Quick way is to remove sources.list

demarey commented 2 years ago

@Bajger I think the best option would be to use our own sources.list file for testing. That way, sources will not change from time to time leading to CI errors. In the setup, I would force the copy of our own sources.list file (with only a a few categories and entries with different kind) to the specified location, or better, configure an alternate location of sources file for the execution of the test (the previous one being restored at the end of the test) that will point to the test sources.list file.

Bajger commented 2 years ago
  1. we can use hardcoded sources.list that would be e.g. in test directory
  2. Original file would be backed up in e.g. ROOT/backup (backup will be done during one time setup of tests)
  3. Hardcoded file would overwrite original sources.list in ~/Pharo/sources.list
  4. Tear down will replace again sources.list with file from backup directory

@demarey: Is it ok this approach? I don't know if we can force launcher execution to use "own" sources list from different than expected directory (therefore to use backup dir).

demarey commented 2 years ago
  1. is ok.
  2. not needed in fact (we are on a CI server)
  3. not needed: we will just set a new location for the sources files using PhLTemplateSources launcherCoreDir: (FileLocator workingDirectory / 'test') asFileReference.
  4. we can just set the default location back : PhLTemplateSources launcherCoreDir: FileLocator launcherUserFilesLocation.
Bajger commented 2 years ago

@demarey : Ok, but how would you set 3) and 4) during a shell test (without modifying original image)? Shell unit tests just invoke production commands (not test specific). I'm not sure when and where these snippets should be executed (e.g. something ./pharo-launcher eval code-snippet?).

demarey commented 2 years ago

yes, David, you're right. I forgot you are doing black-box testing. In this case, the best would be to copy your sources file for testing at the default location in the setup and remove it in the teardown.

Bajger commented 2 years ago

@demarey : Found that rewriting sources.list file is not enough :( If I use own file, refresh on template repository must be invoked. Otherwise cache with templates becomes somehow invalid and I have error during template lookup: "Official distributions not found, please enter a correct category name". Probably some check, if sources.list file was changed so template repository should be updated? Its becoming more complicated... I don't know if it is worth to change logic of core pharo launcher in this way. Probably it simpler to just delete sources file (if file is missing, it downloads and refreshes template repository). WDYT?

Bajger commented 2 years ago

This is modified sources.list file for testing purposes (deleted most of contents). Maybe there is something wrong here:

OrderedCollection [
    PhLTemplateSource {
        #type : #Cache,
        #name : 'Templates'
    },
    PhLTemplateSource {
        #type : #URLGroup,
        #name : 'Official distributions',
        #templates : [
            PhLTemplateSource {
                #type : #URL,
                #name : 'Pharo 11.0 - 64bit (development version, latest)',
                #url : 'https://files.pharo.org/image/110/latest-64.zip'
            },
            PhLTemplateSource {
                #type : #URL,
                #name : 'Pharo 11.0 - 32bit (development version, latest)',
                #url : 'https://files.pharo.org/image/110/latest-32.zip'
            },(stable)
            PhLTemplateSource {
                #type : #URL,
                #name : 'Pharo 10.0 - 64bit (stable)',
                #url : 'https://files.pharo.org/image/100/latest-64.zip'
            },
            PhLTemplateSource {
                #type : #URL,
                #name : 'Pharo 10.0 - 32bit (stable)',
                #url : 'https://files.pharo.org/image/100/latest-32.zip'
            },
            PhLTemplateSource {
                #type : #URL,
                #name : 'Pharo 9.0 - 64bit (old stable)',
                #url : 'https://files.pharo.org/image/90/stable-64.zip'
            },
            PhLTemplateSource {
                #type : #URL,
                #name : 'Pharo 9.0 - 32bit (old stable)',
                #url : 'https://files.pharo.org/image/90/stable-32.zip'
            }
        ],
        #expanded : true
    },
    PhLTemplateSource {
        #type : #HttpListing,
        #name : 'Pharo 10.0 (stable)',
        #url : 'https://files.pharo.org/image/100/',
                #filterPattern : 'href="(Pharo-?10-SNAPSHOT.build.[^"]*.zip)"'
    },
    PhLTemplateSource {
        #type : #HttpListing,
        #name : 'Pharo 11.0 (development version)',
        #url : 'https://files.pharo.org/image/110/',
        #filterPattern : 'href="(Pharo-?11-SNAPSHOT.build.[^"]*.zip)"'
    }
]